1
2
3
4
5
6 [hpp]#include <sngcm/cmparser/ParserApi.hpp>
7 [hpp]#include <sngcm/ast/Delegate.hpp>
8 [hpp]#include <sngcm/cmparser/ParsingContext.hpp>
9 [cpp]#include <sngcm/cmparser/Specifier.hpp>
10 [cpp]#include <sngcm/cmparser/TypeExpr.hpp>
11 [cpp]#include <sngcm/cmparser/Identifier.hpp>
12 [cpp]#include <sngcm/cmparser/Parameter.hpp>
13 [cpp]#include <sngcm/cmlexer/CmajorLexer.hpp>
14 [cpp]#include <sngcm/cmlexer/CmajorTokens.hpp>
15
16 using namespace sngcm::ast;
17 using namespace CmajorTokens;
18
19 parser api(SNGCM_PARSER_API) DelegateParser
20 {
21 uselexer CmajorLexer;
22
23 using SpecifierParser.Specifiers;
24 using TypeExprParser.TypeExpr;
25 using ParameterParser.ParameterList;
26 using IdentifierParser.Identifier;
27
28 Delegate(ParsingContext* ctx, var Span s, var std::unique_ptr dlg) : DelegateNode*
29 ::= Specifiers:specifiers{ s = span; } DELEGATE TypeExpr(ctx):type! Identifier:id!{ dlg.reset(new DelegateNode(s, specifiers, type, id)); }
30 ParameterList(ctx, dlg.get()):paramList! SEMICOLON!{ dlg->SetSpanEnd(span.end); return dlg.release(); }
31 ;
32
33 ClassDelegate(ParsingContext* ctx, var Span s, var std::unique_ptr clsDlg) : ClassDelegateNode*
34 ::= Specifiers:specifiers{ s = span; } CLASS DELEGATE TypeExpr(ctx):type! Identifier:id!{ clsDlg.reset(new ClassDelegateNode(s, specifiers, type, id)); }
35 ParameterList(ctx, clsDlg.get()):paramList! SEMICOLON!{ clsDlg->SetSpanEnd(span.end); return clsDlg.release(); }
36 ;
37
38 ruleinfo
39 {
40 (Delegate, "delegate"), (ClassDelegate, "class delegate")
41 }
42 }