@@ -47,6 +47,11 @@ import {ParserErrors} from "./errors";
4747type Expr = ExprNS . Expr ;
4848type Stmt = StmtNS . Stmt ;
4949
50+ const PSEUD_NAMES = [
51+ TokenType . TRUE ,
52+ TokenType . FALSE ,
53+ TokenType . NONE ,
54+ ]
5055
5156export class Parser {
5257 private readonly source : string ;
@@ -148,7 +153,8 @@ export class Parser {
148153 private stmt ( ) : Stmt {
149154 if ( this . check ( TokenType . DEF , TokenType . FOR , TokenType . IF , TokenType . WHILE ) ) {
150155 return this . compound_stmt ( ) ;
151- } else if ( this . check ( TokenType . NAME , TokenType . NUMBER , TokenType . PASS , TokenType . BREAK , TokenType . CONTINUE ,
156+ } else if ( this . check ( TokenType . NAME , ...PSEUD_NAMES , TokenType . NUMBER ,
157+ TokenType . PASS , TokenType . BREAK , TokenType . CONTINUE ,
152158 TokenType . RETURN , TokenType . FROM , TokenType . GLOBAL , TokenType . NONLOCAL ,
153159 TokenType . ASSERT , TokenType . LPAR , ...SPECIAL_IDENTIFIER_TOKENS ) ) {
154160 return this . simple_stmt ( ) ;
@@ -496,7 +502,7 @@ export class Parser {
496502 return new ExprNS . Literal ( startToken , this . previous ( ) , Number ( this . previous ( ) . lexeme ) ) ;
497503 }
498504
499- if ( this . match ( TokenType . NAME ) ) {
505+ if ( this . match ( TokenType . NAME , ... PSEUD_NAMES ) ) {
500506 return new ExprNS . Variable ( startToken , this . previous ( ) , this . previous ( ) ) ;
501507 }
502508
0 commit comments