1
2
3
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 [cpp]#include <cmajor/build/BuildLangOptionParser.hpp>
11 [hpp]#include <cmajor/build/ClientCommand.hpp>
12 [hpp]#include <memory>
13
14 using namespace BuildLangTokens;
15
16 parser api(BUILD_API) BuildLangClientParser
17 {
18 uselexer BuildLangLexer;
19 main;
20 using BuildLangOptionParser.Options;
21
22 ClientSentence(cmajor::build::BuildOptionSetter* optionSetter) : cmajor::build::ClientCommand*
23 ::= Options(optionSetter):options?
24 ClientCommandSentence:sentence!{ return sentence; }
25 ;
26
27 ClientCommandSentence : cmajor::build::ClientCommand*
28 ::=
29 ( PushProjectSentence:pushCommand{ return pushCommand; }
30 | RemoveProjectSentence:removeProjectCommand{ return removeProjectCommand; }
31 | AddServerSentence:addServerCommand{ return addServerCommand; }
32 | RemoveServerSentence:removeServerCommand{ return removeServerCommand; }
33 | BuildProjectSentence:buildCommand{ return buildCommand; }
34 | DebugProjectSentence:debugCommand{ return debugCommand; }
35 | InstallProjectSentence:installCommand{ return installCommand; }
36 | ShowConfigurationSentence:showConfigurationCommand{ return showConfigurationCommand; }
37 )
38 ;
39
40 PushProjectSentence(var std::string serverName) : cmajor::build::ClientCommand*
41 ::=
42 (
43 PUSH ProjectFilePath:project!
44 ( TO SERVER! ServerName:server!{ serverName = server; }
45 )?
46 )
47 {
48 return new cmajor::build::PushProjectClientCommand(project, serverName);
49 }
50 ;
51
52 RemoveProjectSentence(var std::string serverName) : cmajor::build::ClientCommand*
53 ::=
54 (
55 REMOVE ProjectFilePath:project
56 ( FROM SERVER! ServerName:server!{ serverName = server; }
57 )?
58 )
59 {
60 return new cmajor::build::RemoveProjectClientCommand(project, serverName);
61 }
62 ;
63
64 AddServerSentence(var std::string host, var std::string toolChain) : cmajor::build::ClientCommand*
65 ::= (ADD SERVER ServerName:server (HOST Host:h!{ host = h; })? PORT Port:port! (DEFAULT TOOLCHAIN! ToolChain:defaultToolChain!{ toolChain = defaultToolChain; })?)
66 {
67 return new cmajor::build::AddServerClientCommand(server, host, port, toolChain);
68 }
69 ;
70
71 RemoveServerSentence : cmajor::build::ClientCommand*
72 ::= REMOVE SERVER ServerName:server{ return new cmajor::build::RemoveServerClientCommand(server); }
73 ;
74
75 BuildProjectSentence(var std::string serverName) : cmajor::build::ClientCommand*
76 ::=
77 (
78 BUILD ProjectFilePath:project!
79 ( USING SERVER! ServerName:server!{ serverName = server; }
80 )?
81 )
82 {
83 return new cmajor::build::BuildProjectClientCommand(project, serverName);
84 }
85 ;
86
87 DebugProjectSentence(var std::string serverName) : cmajor::build::ClientCommand*
88 ::=
89 (
90 DEBUG ProjectFilePath:project!
91 ( USING SERVER! ServerName:server!{ serverName = server; }
92 )?
93 )
94 {
95 return new cmajor::build::DebugProjectClientCommand(project, serverName);
96 }
97 ;
98
99 InstallProjectSentence(var std::string serverName) : cmajor::build::ClientCommand*
100 ::=
101 (
102 INSTALL ProjectFilePath:project! TO! DirectoryPath:directory!
103 (
104 FROM SERVER! ServerName:server!{ serverName = server; }
105 )?
106 )
107 {
108 return new cmajor::build::InstallProjectClientCommand(project, directory, serverName);
109 }
110 ;
111
112 ShowConfigurationSentence : cmajor::build::ClientCommand*
113 ::=
114 (
115 SHOW CONFIGURATION
116 )
117 {
118 return new cmajor::build::ShowConfigurationClientCommand();
119 }
120 ;
121
122 ProjectFilePath : std::string
123 ::= FILEPATH{ return ToUtf8(lexer.GetToken(pos).match.ToString()); }
124 ;
125
126 DirectoryPath : std::string
127 ::= FILEPATH{ return ToUtf8(lexer.GetToken(pos).match.ToString()); }
128 ;
129
130 ServerName : std::string
131 ::= ID{ return ToUtf8(lexer.GetToken(pos).match.ToString()); }
132 ;
133
134 Host : std::string
135 ::= HostName:hostName{ return hostName; }
136 | IpAddress:ipAddress{ return ipAddress; }
137 ;
138
139 HostName(var std::string hostName) : std::string
140 ::=
141 (
142 ID{ hostName.append(ToUtf8(lexer.GetToken(pos).match.ToString())); } (DOT{ hostName.append(1, '.'); } ID{ hostName.append(ToUtf8(lexer.GetToken(pos).match.ToString())); })*
143 )
144 {
145 return hostName;
146 }
147 ;
148
149 IpAddress(var std::string ip) : std::string
150 ::=
151 (
152 INTEGER{ ip.append(ToUtf8(lexer.GetToken(pos).match.ToString())); }
153 DOT{ ip.append(1, '.'); } INTEGER{ ip.append(ToUtf8(lexer.GetToken(pos).match.ToString())); }
154 DOT{ ip.append(1, '.'); } INTEGER{ ip.append(ToUtf8(lexer.GetToken(pos).match.ToString())); }
155 DOT{ ip.append(1, '.'); } INTEGER{ ip.append(ToUtf8(lexer.GetToken(pos).match.ToString())); }
156 )
157 {
158 return ip;
159 }
160 ;
161
162 Port(var std::string portStr) : int
163 ::= INTEGER{ portStr = ToUtf8(lexer.GetToken(pos).match.ToString()); return std::stoi(portStr); }
164 ;
165
166 ToolChain : std::string
167 ::= CLANG{ return ToUtf8(lexer.GetToken(pos).match.ToString()); }
168 | GCC{ return ToUtf8(lexer.GetToken(pos).match.ToString()); }
169 | VS{ return ToUtf8(lexer.GetToken(pos).match.ToString()); }
170 | ID{ return ToUtf8(lexer.GetToken(pos).match.ToString()); }
171 ;
172
173 ruleinfo
174 {
175 (ClientSentence, "cmclient [options] (add | remove | show | push | build | debug | install) ..."),
176 (ClientCommandSentence, "cmclient [options] (add | remove | show | push | build | debug | install) ..."),
177 (PushProjectSentence, "push project command"),
178 (RemoveProjectSentence, "remove project command"),
179 (AddServerSentence, "add server command"),
180 (RemoveServerSentence, "remove server command"),
181 (BuildProjectSentence, "build project command"),
182 (DebugProjectSentence, "debug project command"),
183 (InstallProjectSentence, "install project command"),
184 (ShowConfigurationSentence, "show configuration command"),
185 (ProjectFilePath, "PROJECT.cmp"),
186 (DirectoryPath, "directory name"),
187 (ServerName, "server name"),
188 (Host, "host name or IP-address"),
189 (Port, "port number"),
190 (ToolChain, "tool chain (clang | gcc | vs)"),
191 (PushProjectSentence, "push project command"),
192 (RemoveProjectSentence, "remove project command"),
193 (AddServerSentence, "add server command"),
194 (RemoveServerSentence, "remove server command"),
195 (ShowConfigurationSentence, "show configuration command"),
196 (BuildProjectSentence, "build project command"),
197 (DebugProjectSentence, "debug project command"),
198 (InstallProjectSentence, "install project command")
199 }
200 }