aboutsummaryrefslogtreecommitdiff
path: root/spec/lexer.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2021-07-02 00:04:56 +0900
committerRyo Nihei <nihei.dev@gmail.com>2021-07-02 00:15:02 +0900
commit24d9877e822c400240a7e86cf8835971ed969ac7 (patch)
treef5bfca4fb67be35f5eadbda5249d31db79d331f9 /spec/lexer.go
parentSimplify syntax of modifiers and semantic actions (diff)
downloadcotia-24d9877e822c400240a7e86cf8835971ed969ac7.tar.gz
cotia-24d9877e822c400240a7e86cf8835971ed969ac7.tar.xz
Prohibit defining identifiers beginning with an underscore
Identifiers beginning with an underscore are used as auto-generated identifiers.
Diffstat (limited to 'spec/lexer.go')
-rw-r--r--spec/lexer.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/spec/lexer.go b/spec/lexer.go
index 2be3918..a1bd6fc 100644
--- a/spec/lexer.go
+++ b/spec/lexer.go
@@ -160,6 +160,9 @@ func (l *lexer) lexAndSkipWSs() (*token, error) {
case "kw_fragment":
return newSymbolToken(tokenKindKWFragment), nil
case "identifier":
+ if strings.HasPrefix(tok.Text(), "_") {
+ return nil, synErrAutoGenID
+ }
return newIDToken(tok.Text()), nil
case "terminal_open":
var b strings.Builder