diff options
| author | Marc Vertes <mvertes@free.fr> | 2023-09-06 11:55:09 +0200 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2023-09-06 11:55:09 +0200 |
| commit | 555e5bfc03daaf40c78eb2ad540cd73ec4ae2831 (patch) | |
| tree | 9261e96271d544d2cc9ef8c4402cf065d6c4de63 /parser | |
| parent | 6dd78f44adf6fb032d0ecd9db813651b9524fcac (diff) | |
scanner: add automatic insertion of semi-colon after newline
As specified in the Go specification, adapted to the following:
- the scanner recognise blocks as tokens
- the scanner is multi-language: define keywords in scanner spec
- as a result, we define how to skip semi-colon insertion rather
than how to add it.
Diffstat (limited to 'parser')
| -rw-r--r-- | parser/README.md | 1 | ||||
| -rw-r--r-- | parser/parse_test.go | 25 |
2 files changed, 25 insertions, 1 deletions
diff --git a/parser/README.md b/parser/README.md index 1c02d22..b8bc0d4 100644 --- a/parser/README.md +++ b/parser/README.md @@ -43,7 +43,6 @@ A successful test must be provided to check the status. - [ ] unary operator (suffix) expressions - [x] operator precedence rules - [x] parenthesis in expressions -- [ ] semi-colon automatic insertion rules - [x] call expressions - [ ] nested calls - [x] index expressions diff --git a/parser/parse_test.go b/parser/parse_test.go index ffc0f53..4559acf 100644 --- a/parser/parse_test.go +++ b/parser/parse_test.go @@ -56,6 +56,31 @@ var GoScanner = &scanner.Scanner{ "/*": scanner.CharStr, "//": scanner.CharStr | scanner.ExcludeEnd | scanner.EosValidEnd, }, + SkipSemi: map[string]bool{ + "++": true, + "--": true, + "case": true, + "chan": true, + "const": true, + "default": true, + "defer": true, + "else": true, + "for": true, + "func": true, + "go": true, + "goto": true, + "if": true, + "import": true, + "interface": true, + "map": true, + "package": true, + "range": true, + "select": true, + "struct": true, + "switch": true, + "type": true, + "var": true, + }, } var GoParser = &Parser{ |
