From 555e5bfc03daaf40c78eb2ad540cd73ec4ae2831 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 6 Sep 2023 11:55:09 +0200 Subject: 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. --- lang/golang/go.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lang/golang/go.go') diff --git a/lang/golang/go.go b/lang/golang/go.go index 5075329..47ca6db 100644 --- a/lang/golang/go.go +++ b/lang/golang/go.go @@ -53,6 +53,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.Parser{ -- cgit v1.2.3