1
2
3
4
5
6 using System.Lex;
7 using ProjectFileTokens;
8
9 parser ProjectFileParser
10 {
11 uselexer ProjectFileLexer;
12 main;
13
14 ProjectFile(var UniquePtr<soulcm.scmpg.ProjectFile> projectFile) : soulcm.scmpg.ProjectFile*
15 ::= PROJECT QualifiedId:projectName! SEMICOLON!{ projectFile.Reset(new soulcm.scmpg.ProjectFile(lexer.FileName(), projectName)); } ProjectFileContent(projectFile.Get()):content
16 {
17 return projectFile.Release();
18 }
19 ;
20
21 ProjectFileContent(soulcm.scmpg.ProjectFile* projectFile)
22 ::=
23 ( SourceFile(projectFile):sourceFile
24 | RuleFile(projectFile):ruleFile
25 )*
26 ;
27
28 QualifiedId(var Span s) : ustring
29 ::= (ID{ s = span; } (DOT ID{ s.end = span.end; })*){ return lexer.GetMatch(s); }
30 ;
31
32 SourceFile(soulcm.scmpg.ProjectFile* projectFile)
33 ::= SOURCE FILEPATH!{ projectFile->AddSourceFile(lexer.filePath); } SEMICOLON!
34 ;
35
36 RuleFile(soulcm.scmpg.ProjectFile* projectFile)
37 ::= RULES FILEPATH!{ projectFile->AddRuleFile(lexer.filePath); } SEMICOLON!
38 ;
39 }