Skip to content

Commit

Permalink
Remove duplicated reserved words map
Browse files Browse the repository at this point in the history
  • Loading branch information
meyermarcel committed Nov 14, 2024
1 parent b58a708 commit 0d2d472
Show file tree
Hide file tree
Showing 5 changed files with 382 additions and 454 deletions.
2 changes: 1 addition & 1 deletion bootstrap/reserved_words.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package bootstrap

var reservedWords = map[string]bool{
var ReservedWords = map[string]bool{
// Go keywords http://golang.org/ref/spec#Keywords
"break": true,
"case": true,
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (s *Scanner) Scan() (Token, bool) {
case isLetter(s.cur):
tok.id = ident
tok.lit = s.scanIdentifier()
if reservedWords[tok.lit] {
if ReservedWords[tok.lit] {
s.errorpf(tok.pos, "illegal identifier %q", tok.lit)
}
case isRuleDefStart(s.cur):
Expand Down
2 changes: 1 addition & 1 deletion grammar/pigeon.peg
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ SingleLineComment ← !("//{") "//" ( !EOL SourceChar )*

Identifier ← ident:IdentifierName {
astIdent := ast.NewIdentifier(c.astPos(), string(c.text))
if reservedWords[astIdent.Val] {
if bootstrap.ReservedWords[astIdent.Val] {
return astIdent, errors.New("identifier is a reserved word")
}
return astIdent, nil
Expand Down
Loading

0 comments on commit 0d2d472

Please sign in to comment.