Closed chharvey closed 4 years ago
Tokenize the primitive literals null, false, and true.
null
false
true
Simply add them to the reserved keywords list in the lexical grammar.
Keyword :::= | "null" | "false" | "true" ;
The TokenWorth attribute grammar adds these keywords.
TokenWorth(Keyword :::= "null" ) -> RealNumber := \x82; TokenWorth(Keyword :::= "false") -> RealNumber := \x83; TokenWorth(Keyword :::= "true" ) -> RealNumber := \x84;
In the syntactic grammar, allow these keywords as primitive literals.
PrimitiveLiteral ::= | "null" | "false" | "true" | NUMBER | STRING ;
The decoration attribute grammar:
Decorate(PrimitiveLiteral ::= "null") -> SemanticConstant := SemanticConstant {value: null} []; Decorate(PrimitiveLiteral ::= "false") -> SemanticConstant := SemanticConstant {value: false} []; Decorate(PrimitiveLiteral ::= "true") -> SemanticConstant := SemanticConstant {value: true} [];
Tokenize the primitive literals
null
,false
, andtrue
.Simply add them to the reserved keywords list in the lexical grammar.
The TokenWorth attribute grammar adds these keywords.
In the syntactic grammar, allow these keywords as primitive literals.
The decoration attribute grammar: