|
|
@ -16,7 +16,6 @@ export const circomLanguageConfig = (monaco) => ({ |
|
|
|
|
|
|
|
|
|
|
|
onEnterRules: [ |
|
|
|
onEnterRules: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
// e.g. /** | */
|
|
|
|
|
|
|
|
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/, |
|
|
|
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/, |
|
|
|
afterText: /^\s*\*\/$/, |
|
|
|
afterText: /^\s*\*\/$/, |
|
|
|
action: { |
|
|
|
action: { |
|
|
@ -25,7 +24,6 @@ export const circomLanguageConfig = (monaco) => ({ |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
// e.g. /** ...|
|
|
|
|
|
|
|
|
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/, |
|
|
|
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/, |
|
|
|
action: { |
|
|
|
action: { |
|
|
|
indentAction: monaco.languages.IndentAction.None, |
|
|
|
indentAction: monaco.languages.IndentAction.None, |
|
|
@ -33,7 +31,6 @@ export const circomLanguageConfig = (monaco) => ({ |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
// e.g. * ...|
|
|
|
|
|
|
|
|
beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/, |
|
|
|
beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/, |
|
|
|
action: { |
|
|
|
action: { |
|
|
|
indentAction: monaco.languages.IndentAction.None, |
|
|
|
indentAction: monaco.languages.IndentAction.None, |
|
|
@ -41,7 +38,6 @@ export const circomLanguageConfig = (monaco) => ({ |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
// e.g. */|
|
|
|
|
|
|
|
|
beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/, |
|
|
|
beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/, |
|
|
|
action: { |
|
|
|
action: { |
|
|
|
indentAction: monaco.languages.IndentAction.None, |
|
|
|
indentAction: monaco.languages.IndentAction.None, |
|
|
@ -126,18 +122,12 @@ export const circomTokensProvider = { |
|
|
|
"<==", |
|
|
|
"<==", |
|
|
|
], |
|
|
|
], |
|
|
|
|
|
|
|
|
|
|
|
// we include these common regular expressions
|
|
|
|
|
|
|
|
// symbols: /[=><!~?:&|+\-*\/\^%]+/,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// C# style strings
|
|
|
|
|
|
|
|
escapes: |
|
|
|
escapes: |
|
|
|
/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, |
|
|
|
/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, |
|
|
|
|
|
|
|
|
|
|
|
// The main tokenizer for our languages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tokenizer: { |
|
|
|
tokenizer: { |
|
|
|
root: [ |
|
|
|
root: [ |
|
|
|
// identifiers and keywords
|
|
|
|
|
|
|
|
[ |
|
|
|
[ |
|
|
|
/[a-z_$][\w$]*/, |
|
|
|
/[a-z_$][\w$]*/, |
|
|
|
{ |
|
|
|
{ |
|
|
@ -148,41 +138,26 @@ export const circomTokensProvider = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
[/[A-Z][\w\$]*/, "type.identifier"], // to show class names nicely
|
|
|
|
[/[A-Z][\w\$]*/, "type.identifier"], |
|
|
|
|
|
|
|
|
|
|
|
// whitespace
|
|
|
|
|
|
|
|
{ include: "@whitespace" }, |
|
|
|
{ include: "@whitespace" }, |
|
|
|
|
|
|
|
|
|
|
|
// delimiters and operators
|
|
|
|
|
|
|
|
[/[{}()\[\]]/, "@brackets"], |
|
|
|
[/[{}()\[\]]/, "@brackets"], |
|
|
|
|
|
|
|
|
|
|
|
// [/[<>](?!@symbols)/, "@brackets"],
|
|
|
|
|
|
|
|
// [
|
|
|
|
|
|
|
|
// /@symbols/,
|
|
|
|
|
|
|
|
// { cases: { "@operators": "operator", "@default": "" } },
|
|
|
|
|
|
|
|
// ],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @ annotations.
|
|
|
|
|
|
|
|
// As an example, we emit a debugging log message on these tokens.
|
|
|
|
|
|
|
|
// Note: message are supressed during the first load -- change some lines to see them.
|
|
|
|
|
|
|
|
[ |
|
|
|
[ |
|
|
|
/@\s*[a-zA-Z_\$][\w\$]*/, |
|
|
|
/@\s*[a-zA-Z_\$][\w\$]*/, |
|
|
|
{ token: "annotation", log: "annotation token: $0" }, |
|
|
|
{ token: "annotation", log: "annotation token: $0" }, |
|
|
|
], |
|
|
|
], |
|
|
|
|
|
|
|
|
|
|
|
// numbers
|
|
|
|
|
|
|
|
[/\d*\.\d+([eE][\-+]?\d+)?/, "number.float"], |
|
|
|
[/\d*\.\d+([eE][\-+]?\d+)?/, "number.float"], |
|
|
|
[/0[xX][0-9a-fA-F]+/, "number.hex"], |
|
|
|
[/0[xX][0-9a-fA-F]+/, "number.hex"], |
|
|
|
[/\d+/, "number"], |
|
|
|
[/\d+/, "number"], |
|
|
|
|
|
|
|
|
|
|
|
// delimiter: after number because of .\d floats
|
|
|
|
|
|
|
|
[/[;,.]/, "delimiter"], |
|
|
|
[/[;,.]/, "delimiter"], |
|
|
|
|
|
|
|
|
|
|
|
// strings
|
|
|
|
[/"([^"\\]|\\.)*$/, "string.invalid"], |
|
|
|
[/"([^"\\]|\\.)*$/, "string.invalid"], // non-teminated string
|
|
|
|
|
|
|
|
[/"/, { token: "string.quote", bracket: "@open", next: "@string" }], |
|
|
|
[/"/, { token: "string.quote", bracket: "@open", next: "@string" }], |
|
|
|
|
|
|
|
|
|
|
|
// characters
|
|
|
|
|
|
|
|
[/'[^\\']'/, "string"], |
|
|
|
[/'[^\\']'/, "string"], |
|
|
|
[/(')(@escapes)(')/, ["string", "string.escape", "string"]], |
|
|
|
[/(')(@escapes)(')/, ["string", "string.escape", "string"]], |
|
|
|
[/'/, "string.invalid"], |
|
|
|
[/'/, "string.invalid"], |
|
|
@ -190,7 +165,7 @@ export const circomTokensProvider = { |
|
|
|
|
|
|
|
|
|
|
|
comment: [ |
|
|
|
comment: [ |
|
|
|
[/[^\/*]+/, "comment"], |
|
|
|
[/[^\/*]+/, "comment"], |
|
|
|
[/\/\*/, "comment", "@push"], // nested comment
|
|
|
|
[/\/\*/, "comment", "@push"], |
|
|
|
["\\*/", "comment", "@pop"], |
|
|
|
["\\*/", "comment", "@pop"], |
|
|
|
[/[\/*]/, "comment"], |
|
|
|
[/[\/*]/, "comment"], |
|
|
|
], |
|
|
|
], |
|
|
|