1 // =================================
 2 // Copyright (c) 2021 Seppo Laakko
 3 // Distributed under the MIT license
 4 // =================================
 5 
 6 [hpp]#include <cmajor/build/BuildApi.hpp>
 7 [hpp]#include <cmajor/build/BuildOption.hpp>
 8 [cpp]#include <cmajor/build/BuildLangLexer.hpp>
 9 [cpp]#include <cmajor/build/BuildLangTokens.hpp>
10 
11 using namespace BuildLangTokens;
12 
13 parser api(BUILD_API) BuildLangOptionParser
14 {
15     uselexer BuildLangLexer;
16 
17     Options(cmajor::build::BuildOptionSetter* optionSetter)
18         ::= LBRACKET OptionsWithinBrackets(optionSetter):options! RBRACKET!
19         ;
20 
21     OptionsWithinBrackets(cmajor::build::BuildOptionSetter* optionSetter)
22         ::= Option(optionSetter):option*
23         ;
24 
25     Option(cmajor::build::BuildOptionSetter* optionSetter)
26         ::= VERBOSE{ optionSetter->SetOption(cmajor::build::BuildOptions::verbose); }
27         |   MESSAGES{ optionSetter->SetOption(cmajor::build::BuildOptions::messages); }
28         |   DEBUG{ optionSetter->SetOption(cmajor::build::BuildOptions::debug); }
29         |   FORCE{ optionSetter->SetOption(cmajor::build::BuildOptions::force); }
30         |   ONLY{ optionSetter->SetOption(cmajor::build::BuildOptions::only); }
31         |   REBUILD{ optionSetter->SetOption(cmajor::build::BuildOptions::rebuild); }
32         |   ALL{ optionSetter->SetOption(cmajor::build::BuildOptions::all); }
33         |   PUSH{ optionSetter->SetOption(cmajor::build::BuildOptions::push); }
34         |   BUILD{ optionSetter->SetOption(cmajor::build::BuildOptions::build); }
35         |   CONFIG EQ! Config:config!{ optionSetter->SetConfigOption(config); }
36         |   TOOLCHAIN EQ! ToolChain:toolChain!{ optionSetter->SetToolChainOption(toolChain); }
37         ;
38 
39     Config : std::string
40         ::= DEBUG{ return "debug"; }
41         |   RELEASE{ return "release"; }
42         ;
43 
44     ToolChain : std::string
45         ::= CLANG{ return "clang"; }
46         |   GCC{ return "gcc"; }
47         |   VS{ return "vs"; }
48         |   ID{ return ToUtf8(lexer.GetToken(pos).match.ToString()); }
49         ;
50 }