From 054307b6c99ab962cfa9bcb4c4d50f3aea5406ea Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Mon, 9 May 2022 23:52:56 +0900 Subject: Make the identifier format strict --- spec/lexer_test.go | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'spec/lexer_test.go') 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", -- cgit v1.2.3