1
2
3
4
5
6 [hpp]#include <sngcm/cmparser/ParserApi.hpp>
7 [hpp]#include <sngcm/ast/Parameter.hpp>
8 [hpp]#include <sngcm/cmparser/ParsingContext.hpp>
9 [cpp]#include <sngcm/cmparser/TypeExpr.hpp>
10 [cpp]#include <sngcm/cmparser/Identifier.hpp>
11 [cpp]#include <sngcm/cmlexer/CmajorLexer.hpp>
12 [cpp]#include <sngcm/cmlexer/CmajorTokens.hpp>
13
14 using namespace sngcm::ast;
15 using namespace CmajorTokens;
16
17 parser api(SNGCM_PARSER_API) ParameterParser
18 {
19 uselexer CmajorLexer;
20
21 using TypeExprParser.TypeExpr;
22 using IdentifierParser.Identifier;
23
24 ParameterList(ParsingContext* ctx, sngcm::ast::Node* owner)
25 ::= LPAREN (Parameter(ctx):param{ owner->AddParameter(param); } % COMMA)? RPAREN!
26 ;
27
28 Parameter(ParsingContext* ctx, var Span s) : ParameterNode*
29 ::= (TypeExpr(ctx):type{ s = span; } (Identifier:id{ s.end = span.end; })?){ return new ParameterNode(s, type, id); }
30 ;
31
32 ruleinfo
33 {
34 (ParameterList, "parameter list"), (Parameter, "parameter")
35 }
36 }