Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions analyzer-views/src/colors.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// The colours VisualText gives NLP++ tokens, as the VS Code extension sets them.
//
// The extension's grammars name scopes of their own -- keyword.node.tree,
// keyword.rewrite.tree, keyword.concept.kbb2 -- which no theme knows, so VS Code themes
// would colour them all as plain keywords. The extension therefore ships
// The grammars use standard TextMate scope names (nlpplus-tmbundle#3), so any theme
// colours NLP++ reasonably. On top of that the extension ships its own
// editor.tokenColorCustomizations in the .vscode/settings.json of its repository and of
// the analyzer repositories (vscode-nlp/.vscode/settings.json), with one set of rules for
// light themes and one for dark. Parse trees are the clearest case: node names green,
// rewrites bold, offsets blue, "fired" red.
// rewrites bold, offsets blue, "fired" red. A rule for an old scope name that covered
// several things lists all of their new names (vscode-nlp src/language/scopeMigration.ts).
//
// Copied from there rule for rule, so the two can be compared, and folded into the shiki
// themes in highlight.ts. PURE: no DOM.
Expand All @@ -18,41 +18,41 @@ export interface TokenRule {
export const LIGHT_RULES: TokenRule[] = [
{ scope: "entity.name.function.letter.nlp", settings: { foreground: "#dc1b1b" } },
{ scope: "entity.name.function.nlp", settings: { foreground: "#000000" } },
{ scope: "variable.parameter.nlp", settings: { foreground: "#696969", fontStyle: "bold" } },
{ scope: "keyword.attribute.nlp", settings: { foreground: "#e655f3" } },
{ scope: "keyword.constants.nlp", settings: { foreground: "#0a7b83", fontStyle: "bold" } },
{ scope: ["variable.parameter.nlp", "keyword.control.kb"], settings: { foreground: "#696969", fontStyle: "bold" } },
{ scope: "entity.other.attribute-name.nlp", settings: { foreground: "#e655f3" } },
{ scope: "constant.language.nlp", settings: { foreground: "#0a7b83", fontStyle: "bold" } },
{ scope: ["keyword.operator.nlp", "keyword.operator.word.nlp"], settings: { foreground: "#1f6feb" } },
{ scope: "constant.numeric.tree", settings: { foreground: "#5596f0" } },
{ scope: "keyword.fired.tree", settings: { foreground: "#dc1b1b", fontStyle: "bold" } },
{ scope: "keyword.rewrite.tree", settings: { foreground: "#000000", fontStyle: "bold" } },
{ scope: "keyword.node.tree", settings: { foreground: "#4e8e3c", fontStyle: "bold" } },
{ scope: ["constant.numeric.tree", "constant.numeric.kbb"], settings: { foreground: "#5596f0" } },
{ scope: "keyword.other.fired.tree", settings: { foreground: "#dc1b1b", fontStyle: "bold" } },
{ scope: "entity.name.type.tree", settings: { foreground: "#000000", fontStyle: "bold" } },
{ scope: "string.unquoted.token.tree", settings: { foreground: "#4e8e3c", fontStyle: "bold" } },
{ scope: "source.txxt", settings: { foreground: "#a5a5a5" } },
{ scope: "keyword.other.txxt", settings: { foreground: "#6e60eb", fontStyle: "bold" } },
{ scope: "comment.line.txxt", settings: { foreground: "#dd2c2c", fontStyle: "bold" } },
{ scope: "variable.parameter.txxt", settings: { foreground: "#535353", fontStyle: "bold" } },
{ scope: "keyword.other.kbb", settings: { foreground: "#5d00d6", fontStyle: "bold" } },
{ scope: "keyword.concept.kbb", settings: { foreground: "#7e7e7e", fontStyle: "bold" } },
{ scope: "keyword.concept.kbb1", settings: { foreground: "#2eb657", fontStyle: "bold" } },
{ scope: "keyword.concept.kbb2", settings: { foreground: "#e049d9", fontStyle: "bold" } },
{ scope: "entity.name.type.level0.kbb", settings: { foreground: "#5d00d6", fontStyle: "bold" } },
{ scope: "entity.name.type.level1.kbb", settings: { foreground: "#7e7e7e", fontStyle: "bold" } },
{ scope: "entity.name.type.level2.kbb", settings: { foreground: "#2eb657", fontStyle: "bold" } },
{ scope: "entity.name.type.level3.kbb", settings: { foreground: "#e049d9", fontStyle: "bold" } },
];

export const DARK_RULES: TokenRule[] = [
{ scope: "entity.name.function.letter.nlp", settings: { foreground: "#dc1b1b" } },
{ scope: "entity.name.function.nlp", settings: { foreground: "#8f8f8f", fontStyle: "bold" } },
{ scope: "variable.parameter.nlp", settings: { foreground: "#f8fa87", fontStyle: "bold" } },
{ scope: "keyword.attribute.nlp", settings: { foreground: "#f293fb" } },
{ scope: "keyword.constants.nlp", settings: { foreground: "#4ec9b0", fontStyle: "bold" } },
{ scope: ["variable.parameter.nlp", "keyword.control.kb"], settings: { foreground: "#f8fa87", fontStyle: "bold" } },
{ scope: "entity.other.attribute-name.nlp", settings: { foreground: "#f293fb" } },
{ scope: "constant.language.nlp", settings: { foreground: "#4ec9b0", fontStyle: "bold" } },
{ scope: ["keyword.operator.nlp", "keyword.operator.word.nlp"], settings: { foreground: "#8ab4f8" } },
{ scope: "constant.numeric.tree", settings: { foreground: "#93bffb" } },
{ scope: "keyword.fired.tree", settings: { foreground: "#dc1b1b", fontStyle: "bold" } },
{ scope: "keyword.rewrite.tree", settings: { foreground: "#f8fa87", fontStyle: "bold" } },
{ scope: "keyword.node.tree", settings: { foreground: "#4e8e3c", fontStyle: "bold" } },
{ scope: ["constant.numeric.tree", "constant.numeric.kbb"], settings: { foreground: "#93bffb" } },
{ scope: "keyword.other.fired.tree", settings: { foreground: "#dc1b1b", fontStyle: "bold" } },
{ scope: "entity.name.type.tree", settings: { foreground: "#f8fa87", fontStyle: "bold" } },
{ scope: "string.unquoted.token.tree", settings: { foreground: "#4e8e3c", fontStyle: "bold" } },
{ scope: "source.txxt", settings: { foreground: "#7e7e7e" } },
{ scope: "variable.parameter.txxt", settings: { foreground: "#f8fa87" } },
{ scope: "keyword.other.kbb", settings: { foreground: "#896eff", fontStyle: "bold" } },
{ scope: "keyword.concept.kbb", settings: { foreground: "#e3ee50", fontStyle: "bold" } },
{ scope: "keyword.concept.kbb1", settings: { foreground: "#2eb657", fontStyle: "bold" } },
{ scope: "keyword.concept.kbb2", settings: { foreground: "#e049d9", fontStyle: "bold" } },
{ scope: "entity.name.type.level0.kbb", settings: { foreground: "#896eff", fontStyle: "bold" } },
{ scope: "entity.name.type.level1.kbb", settings: { foreground: "#e3ee50", fontStyle: "bold" } },
{ scope: "entity.name.type.level2.kbb", settings: { foreground: "#2eb657", fontStyle: "bold" } },
{ scope: "entity.name.type.level3.kbb", settings: { foreground: "#e049d9", fontStyle: "bold" } },
];

// The tree scopes the extension's rules colour, for the self test to check they arrived.
Expand Down
2 changes: 1 addition & 1 deletion analyzer-views/src/grammars/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NLP++ TextMate grammars

A copy of `syntaxes/` from [VisualText/nlpplus-tmbundle](https://github.com/VisualText/nlpplus-tmbundle)
at `ab5328e`, under its MIT license (`LICENSE`, beside this file). These are the grammars the NLP++
at `655c78d`, under its MIT license (`LICENSE`, beside this file). These are the grammars the NLP++
VS Code extension uses. Shiki tokenizes with them (`../highlight.ts`), for `<nlp-code>` and for
NLP Studio's Monaco editor.
36 changes: 27 additions & 9 deletions analyzer-views/src/grammars/dict.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"patterns": [
{
"include": "#comment-line"
},
},
{
"include": "#comment-block"
},
{
"include": "#attribute-equals"
},
Expand All @@ -37,16 +40,16 @@
"match": "^([^=]+)(\\s)([\\w\\d]+)(\\s)*(=)",
"captures": {
"1": {
"name": "comment.line.dict"
"name": "entity.name.tag.dict"
},
"2": {
"name": "entity.nothing.dict"
"name": "meta.whitespace.dict"
},
"3": {
"name": "keyword.region.dict"
"name": "support.type.property-name.dict"
},
"4": {
"name": "keyword.region.dict"
"name": "meta.whitespace.dict"
},
"5": {
"name": "keyword.operator.dict"
Expand All @@ -55,16 +58,16 @@
},
"value": {
"match": "[\\w\\d]+",
"name": "entity.name.function.dict"
"name": "string.unquoted.value.dict"
},
"other-attrs": {
"match": "([\\w]+)(\\s)*(=)",
"captures": {
"1": {
"name": "keyword.region.dict"
"name": "support.type.property-name.dict"
},
"2": {
"name": "keyword.region.dict"
"name": "meta.whitespace.dict"
},
"3": {
"name": "keyword.operator.dict"
Expand All @@ -75,10 +78,25 @@
"match": "\\s*#.*$\\n?",
"name": "comment.line.dict"
},
"comment-block": {
"begin": "/\\*",
"beginCaptures": {
"0": {
"name": "comment.block.begin.dict"
}
},
"end": "\\*/",
"endCaptures": {
"0": {
"name": "comment.block.end.dict"
}
},
"name": "comment.block.dict"
},
"qstring-double": {
"begin": "\"",
"end": "\\\"|(?:[^\\\\\\n]$)",
"name": "string.double.dict",
"name": "string.quoted.double.dict",
"patterns": [
{
"include": "#string-character-escape"
Expand Down
24 changes: 21 additions & 3 deletions analyzer-views/src/grammars/kb.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "kb",
"patterns": [
{
"name": "variable.parameter.nlp",
"name": "keyword.control.kb",
"match": "\\b(?i:(add|bind|ind|quit|take))\\b"
},
{
Expand All @@ -28,6 +28,9 @@
{
"include": "#comment-line"
},
{
"include": "#comment-block"
},
{
"include": "#number"
},
Expand All @@ -46,7 +49,7 @@
"qstring-double": {
"begin": "\"",
"end": "\\\"|(?:[^\\\\\\n]$)",
"name": "string.double.kb",
"name": "string.quoted.double.kb",
"patterns": [
{
"include": "#string-character-escape"
Expand All @@ -63,7 +66,22 @@
},
"comment-line": {
"match": "\\s*#.*$\\n?",
"name": "comment.line.dict"
"name": "comment.line.kb"
},
"comment-block": {
"begin": "/\\*",
"beginCaptures": {
"0": {
"name": "comment.block.begin.kb"
}
},
"end": "\\*/",
"endCaptures": {
"0": {
"name": "comment.block.end.kb"
}
},
"name": "comment.block.kb"
}
}
}
32 changes: 25 additions & 7 deletions analyzer-views/src/grammars/kbb.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
{
"include": "#comment-line"
},
{
"include": "#comment-block"
},
{
"include": "#top-concept"
},
Expand All @@ -41,22 +44,22 @@
},
"top-concept": {
"match": "^([\\w\\d]+)$",
"name": "keyword.other.kbb"
"name": "entity.name.type.level0.kbb"
},
"concept-name": {
"name": "keyword.concept.kbb",
"name": "entity.name.type.level1.kbb",
"match": "^[\\s][\\s][\\w\\d][^:^\\[]+[:]?"
},
"concept-name1": {
"name": "keyword.concept.kbb1",
"name": "entity.name.type.level2.kbb",
"match": "^[\\s][\\s][\\s][\\s][\\w\\d][^:^\\[]+[:]?"
},
"concept-name2": {
"name": "keyword.concept.kbb2",
"name": "entity.name.type.level3.kbb",
"match": "^[\\s][\\s][\\s][\\s][\\s][\\s][\\w\\d][^:^\\[]+[:]?"
},
"attribute-name": {
"name": "constant.numeric.tree",
"name": "constant.numeric.kbb",
"match": "\\b[\\w\\d]+="
},
"attributes": {
Expand All @@ -75,7 +78,7 @@
"qstring-double": {
"begin": "\"",
"end": "\\\"|(?:[^\\\\\\n]$)",
"name": "string.double.kbb",
"name": "string.quoted.double.kbb",
"patterns": [
{
"include": "#string-character-escape"
Expand All @@ -92,7 +95,22 @@
},
"comment-line": {
"match": "\\s*#.*$\\n?",
"name": "comment.line.dict"
"name": "comment.line.kbb"
},
"comment-block": {
"begin": "/\\*",
"beginCaptures": {
"0": {
"name": "comment.block.begin.kbb"
}
},
"end": "\\*/",
"endCaptures": {
"0": {
"name": "comment.block.end.kbb"
}
},
"name": "comment.block.kbb"
}
}
}
Loading
Loading