aboutsummaryrefslogtreecommitdiff
path: root/spec/lexer_test.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2022-05-09 23:52:56 +0900
committerRyo Nihei <nihei.dev@gmail.com>2022-05-10 23:14:52 +0900
commit054307b6c99ab962cfa9bcb4c4d50f3aea5406ea (patch)
tree73aea74559c64f3bcb55f3a39b2399714b616174 /spec/lexer_test.go
parentChange the default suffix of a grammar file from .vr to .vartan (diff)
downloadcotia-054307b6c99ab962cfa9bcb4c4d50f3aea5406ea.tar.gz
cotia-054307b6c99ab962cfa9bcb4c4d50f3aea5406ea.tar.xz
Make the identifier format strict
Diffstat (limited to 'spec/lexer_test.go')
-rw-r--r--spec/lexer_test.go34
1 files changed, 32 insertions, 2 deletions
diff --git a/spec/lexer_test.go b/spec/lexer_test.go
index 0e7cc89..5f555ec 100644
--- a/spec/lexer_test.go
+++ b/spec/lexer_test.go
@@ -120,9 +120,39 @@ bar // This is the fourth comment.
},
},
{
- caption: "identifiers beginning with an underscore are not allowed because they are used only auto-generated identifiers",
+ caption: "an identifier cannot contain the capital-case letters",
+ src: `Abc`,
+ err: synErrIDInvalidChar,
+ },
+ {
+ caption: "an identifier cannot contain the capital-case letters",
+ src: `Zyx`,
+ err: synErrIDInvalidChar,
+ },
+ {
+ caption: "the underscore cannot be placed at the beginning of an identifier",
src: `_abc`,
- err: synErrAutoGenID,
+ err: synErrIDInvalidUnderscorePos,
+ },
+ {
+ caption: "the underscore cannot be placed at the end of an identifier",
+ src: `abc_`,
+ err: synErrIDInvalidUnderscorePos,
+ },
+ {
+ caption: "the underscore cannot be placed consecutively",
+ src: `a__b`,
+ err: synErrIDConsecutiveUnderscores,
+ },
+ {
+ caption: "the digits cannot be placed at the biginning of an identifier",
+ src: `0abc`,
+ err: synErrIDInvalidDigitsPos,
+ },
+ {
+ caption: "the digits cannot be placed at the biginning of an identifier",
+ src: `9abc`,
+ err: synErrIDInvalidDigitsPos,
},
{
caption: "an unclosed terminal is not a valid token",