1
2
3
4
5
6 [hpp]#include <sngcm/cmparser/ParserApi.hpp>
7 [hpp]#include <sngcm/ast/Interface.hpp>
8 [hpp]#include <sngcm/cmparser/ParsingContext.hpp>
9 [cpp]#include <sngcm/cmparser/Attribute.hpp>
10 [cpp]#include <sngcm/cmparser/Specifier.hpp>
11 [cpp]#include <sngcm/cmparser/Identifier.hpp>
12 [cpp]#include <sngcm/cmparser/TypeExpr.hpp>
13 [cpp]#include <sngcm/cmparser/Parameter.hpp>
14 [hpp]#include <sngcm/ast/Class.hpp>
15 [cpp]#include <sngcm/cmlexer/CmajorLexer.hpp>
16 [cpp]#include <sngcm/cmlexer/CmajorTokens.hpp>
17
18 using namespace sngcm::ast;
19 using namespace CmajorTokens;
20
21 parser api(SNGCM_PARSER_API) InterfaceParser
22 {
23 uselexer CmajorLexer;
24
25 using AttributeParser.Attributes;
26 using SpecifierParser.Specifiers;
27 using IdentifierParser.Identifier;
28 using TypeExprParser.TypeExpr;
29 using ParameterParser.ParameterList;
30
31 Interface(boost::uuids::uuid* moduleId, ParsingContext* ctx, var std::unique_ptr intf, var Span s, var Span specifierSpan, var Span beginBraceSpan, var Span endBraceSpan) : InterfaceNode*
32 ::=
33 ( empty{ s = span; } Attributes(moduleId):attrs? Specifiers:specifiers{ specifierSpan = span; } INTERFACE Identifier(moduleId):id!
34 {
35 s.end = span.end;
36 intf.reset(new InterfaceNode(s, *moduleId, specifiers, id, attrs));
37 intf->SetSpecifierSpan(specifierSpan);
38 }
39 LBRACE!{ beginBraceSpan = span; } InterfaceContent(moduleId, ctx, intf.get()):content RBRACE!{ endBraceSpan = span; intf->SetBeginBraceSpan(beginBraceSpan); intf->SetEndBraceSpan(endBraceSpan); }
40 )
41 {
42 return intf.release();
43 }
44 ;
45
46 InterfaceContent(boost::uuids::uuid* moduleId, ParsingContext* ctx, sngcm::ast::InterfaceNode* intf)
47 ::= (InterfaceMemFun(moduleId, ctx):intfMemFun{ intf->AddMember(intfMemFun); })*
48 ;
49
50 InterfaceMemFun(boost::uuids::uuid* moduleId, ParsingContext* ctx, var std::unique_ptr memFun, var Span s) : Node*
51 ::= empty{ s = span; } Attributes(moduleId):attrs? TypeExpr(moduleId, ctx):returnType InterfaceFunctionGroupId:groupId!
52 {
53 s.end = span.end;
54 memFun.reset(new MemberFunctionNode(s, *moduleId, Specifiers(), returnType, groupId, attrs));
55 }
56 ParameterList(moduleId, ctx, memFun.get()):paramList! SEMICOLON!
57 {
58 return memFun.release();
59 }
60 ;
61
62 InterfaceFunctionGroupId : std::u32string
63 ::= ID{ return lexer.GetMatch(span); }
64 ;
65
66 ruleinfo
67 {
68 (Interface, "interface"), (InterfaceContent, "interface content"), (InterfaceMemFun, "interface member function"), (InterfaceFunctionGroupId, "interface function group identifier")
69 }
70 }