1
2
3
4
5
6 [hpp]#include <sngcm/cmparser/ParserApi.hpp>
7 [hpp]#include <sngcm/ast/Solution.hpp>
8 [cpp]#include <sngcm/cmlexer/ContainerFileLexer.hpp>
9 [cpp]#include <sngcm/cmlexer/ContainerFileTokens.hpp>
10
11 using namespace sngcm::ast;
12 using namespace ContainerFileTokens;
13
14 parser api(SNGCM_PARSER_API) SolutionFileParser
15 {
16 uselexer ContainerFileLexer;
17 main;
18
19 SolutionFile(var std::unique_ptr solution) : sngcm::ast::Solution*
20 ::=
21 (
22 SOLUTION QualifiedId:name! SEMICOLON!{ solution.reset(new sngcm::ast::Solution(name, lexer.FileName())); }
23 (Declaration:declaration{ solution->AddDeclaration(declaration); })*
24 )
25 {
26 return solution.release();
27 }
28 ;
29
30 QualifiedId(var Span s) : std::u32string
31 ::=
32 (
33 ID{ s = span; } (DOT ID{ s.end = span.end; })*
34 )
35 {
36 return lexer.GetMatch(s);
37 }
38 ;
39
40 Declaration : sngcm::ast::SolutionDeclaration*
41 ::= SolutionProjectDeclaration:solutionProjectDeclaration{ return solutionProjectDeclaration; }
42 | ActiveProjectDeclaration:activeProjectDeclaration{ return activeProjectDeclaration; }
43 ;
44
45 SolutionProjectDeclaration(var std::string filePath) : sngcm::ast::SolutionDeclaration*
46 ::= (PROJECT FILEPATH{ filePath = lexer.filePath; } SEMICOLON){ return new sngcm::ast::SolutionProjectDeclaration(filePath); }
47 ;
48
49 ActiveProjectDeclaration : sngcm::ast::SolutionDeclaration*
50 ::= (ACTIVEPROJECT QualifiedId:activeProjectName SEMICOLON){ return new sngcm::ast::SolutionActiveProjectDeclaration(activeProjectName); }
51 ;
52 }