1
2
3
4
5
6 using Cm.Ast;
7 using LexerFileTokens;
8
9 parser IdentifierParser
10 {
11 uselexer LexerFileLexer;
12
13 Identifier(ParsingContext* ctx) : IdentifierNode*
14 ::= ID{ return new IdentifierNode(span, ctx->ModuleId(), lexer.GetToken(pos)); }
15 ;
16
17 QualifiedId(ParsingContext* ctx, var ustring value, var Span s) : IdentifierNode*
18 ::=
19 ( ID{ s = span; Token token = lexer.GetToken(pos); value.Append(ustring(token.match.begin, token.match.end)); }
20 (DOT ID{ s.end = span.end; Token token = lexer.GetToken(pos); value.Append('.'); value.Append(ustring(token.match.begin, token.match.end)); })*
21 )
22 {
23 return new IdentifierNode(s, ctx->ModuleId(), value);
24 }
25 ;
26
27 ruleinfo
28 {
29 (Identifier, "identifier"), (QualifiedId, "identifier")
30 }
31 }