1
2
3
4
5
6 [hpp]#include <sngcm/cmparser/ParserApi.hpp>
7 [hpp]#include <sngcm/ast/Identifier.hpp>
8 [cpp]#include <sngcm/cmlexer/CmajorLexer.hpp>
9 [cpp]#include <sngcm/cmlexer/CmajorTokens.hpp>
10
11 using namespace sngcm::ast;
12 using namespace CmajorTokens;
13
14 parser api(SNGCM_PARSER_API) IdentifierParser
15 {
16 uselexer CmajorLexer;
17
18 Identifier : IdentifierNode*
19 ::= ID{ return new IdentifierNode(span, lexer.GetToken(pos)); }
20 ;
21
22 QualifiedId(var std::u32string value, var Span s) : IdentifierNode*
23 ::=
24 ( ID{ s = span; Token token = lexer.GetToken(pos); value.append(std::u32string(token.match.begin, token.match.end)); }
25 (DOT ID{ s.end = span.end; Token token = lexer.GetToken(pos); value.append(1, '.'); value.append(std::u32string(token.match.begin, token.match.end)); })*
26 )
27 {
28 return new IdentifierNode(s, value);
29 }
30 ;
31
32 ruleinfo
33 {
34 (Identifier, "identifier"), (QualifiedId, "identifier")
35 }
36 }