aboutsummaryrefslogtreecommitdiff
path: root/src/build.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/build.y')
-rw-r--r--src/build.y142
1 files changed, 121 insertions, 21 deletions
diff --git a/src/build.y b/src/build.y
index 45a84f1..8345b1f 100644
--- a/src/build.y
+++ b/src/build.y
@@ -4,6 +4,8 @@
4# include "builder.h" 4# include "builder.h"
5# include "action.h" 5# include "action.h"
6# include "command.h" 6# include "command.h"
7# include "rule.h"
8# include "filetarget.h"
7# include "build.tab.h" 9# include "build.tab.h"
8void yyerror( YYLTYPE *locp, Builder &bld, char const *msg ); 10void yyerror( YYLTYPE *locp, Builder &bld, char const *msg );
9%} 11%}
@@ -28,25 +30,25 @@ void yyerror( YYLTYPE *locp, Builder &bld, char const *msg );
28%token <strval> REGEXP "regular expression" 30%token <strval> REGEXP "regular expression"
29 31
30%token TOK_ADDSET "+=" 32%token TOK_ADDSET "+="
31%token TOK_DEFAULT "keyword 'default'" 33%token TOK_DEFAULT "default"
32%token TOK_ACTION "keyword 'action'" 34%token TOK_ACTION "action"
33%token TOK_CREATE "keyword 'create'" 35%token TOK_CREATE "create"
34%token TOK_FILE "keyword 'file'" 36%token TOK_FILE "file"
35%token TOK_FROM "keyword 'from'" 37%token TOK_FROM "from"
36%token TOK_FILES "keyword 'files'" 38%token TOK_FILES "files"
37%token TOK_IN "keyword 'in'" 39%token TOK_IN "in"
38%token TOK_USING "keyword 'using'" 40%token TOK_USING "using"
39%token TOK_RULE "keyword 'rule'" 41%token TOK_RULE "rule"
40%token TOK_REQUIRES "keyword 'requires'" 42%token TOK_REQUIRES "requires"
41%token TOK_FOR "keyword 'for'" 43%token TOK_FOR "for"
42%token TOK_SET "keyword 'set'" 44%token TOK_SET "set"
43%token TOK_MATCHES "keyword 'matches'" 45%token TOK_MATCHES "matches"
44%token TOK_ALL "keyword 'all'" 46%token TOK_ALL "all"
45%token TOK_ONE "keyword 'one'" 47%token TOK_ONE "one"
46%token TOK_PERFORM "keyword 'perform'" 48%token TOK_PERFORM "perform"
47%token TOK_PRODUCES "keyword 'produces'" 49%token TOK_PRODUCES "produces"
48%token TOK_COMMAND "keyword 'command'" 50%token TOK_COMMAND "command"
49%token TOK_CHECK "keyword 'check'" 51%token TOK_CHECK "check"
50%token TOK_EOL "end of line" 52%token TOK_EOL "end of line"
51%token ',' ':' '=' 53%token ',' ':' '='
52 54
@@ -73,9 +75,40 @@ line: TOK_DEFAULT TOK_ACTION ':'
73 } 75 }
74 actionlst 76 actionlst
75 | TOK_CREATE createwhat TOK_FROM createfrom TOK_USING createusing 77 | TOK_CREATE createwhat TOK_FROM createfrom TOK_USING createusing
78 | STRING TOK_REQUIRES
79 {
80 bld.setTmp( $1 );
81 }
82 reqlst
83 | listcmds
84 | TOK_FOR STRING
85 {
86 bld.setContext( $2 );
87 }
88 listcmds
89 {
90 bld.setContext();
91 }
92 | rule
76 ; 93 ;
77 94
78createwhat: TOK_FILE STRING { printf("target: %s\n", $2 ); } 95reqlst: STRING
96 {
97 bld.requires( bld.getTmp(), $1 );
98 }
99 | reqlst ',' STRING
100 {
101 bld.requires( bld.getTmp(), $3 );
102 }
103 ;
104
105listcmds: TOK_SET setexpr
106 ;
107
108createwhat: TOK_FILE STRING
109 {
110 bld.add( new FileTarget( $2 ) );
111 }
79 ; 112 ;
80 113
81createfrom: TOK_FILES TOK_IN createfromdirlst 114createfrom: TOK_FILES TOK_IN createfromdirlst
@@ -88,7 +121,10 @@ createfromdirlst: createfromdir
88createfromdir: STRING { printf(" srcdir: %s\n", $1 ); } 121createfromdir: STRING { printf(" srcdir: %s\n", $1 ); }
89 ; 122 ;
90 123
91createusing: TOK_RULE STRING { printf(" rule: %s\n", $2 ); } 124createusing: TOK_RULE STRING
125 {
126 bld.lastTarget()->setRule( $2 );
127 }
92 ; 128 ;
93 129
94actionlst: action 130actionlst: action
@@ -101,6 +137,70 @@ action: TOK_CHECK STRING
101 } 137 }
102 ; 138 ;
103 139
140setexpr: STRING '=' STRING
141 {
142 bld.varSet( $1, $3 );
143 }
144 | STRING TOK_ADDSET STRING
145 {
146 bld.varAddSet( $1, $3 );
147 }
148 ;
149
150rule: TOK_RULE STRING
151 {
152 bld.add( new Rule( $2 ) );
153 }
154 rulesublst TOK_PERFORM rulecompletion
155 ;
156
157rulesublst: rulesub
158 | rulesublst rulesub
159 ;
160
161rulesub: TOK_MATCHES rulematches
162 | TOK_PRODUCES STRING
163 {
164 bld.lastRule()->setProduces( $2 );
165 }
166 ;
167
168rulematches: TOK_ALL REGEXP
169 {
170 try
171 {
172 bld.lastRule()->setMatches( Rule::matchAll, $2 );
173 }
174 catch( BuildException &e )
175 {
176 std::string s("RegExp compile error: ");
177 s += e.what();
178 yyerror( &yyloc, bld, s.c_str() );
179 return 1;
180 }
181 }
182 | TOK_ONE REGEXP
183 {
184 try
185 {
186 bld.lastRule()->setMatches( Rule::matchOne, $2 );
187 }
188 catch( BuildException &e )
189 {
190 std::string s("RegExp compile error: ");
191 s += e.what();
192 yyerror( &yyloc, bld, s.c_str() );
193 return 1;
194 }
195 }
196 ;
197
198rulecompletion: TOK_COMMAND STRING
199 {
200 bld.lastRule()->setPerforms( Rule::perfCommand, $2 );
201 }
202 ;
203
104%% 204%%
105 205
106void yyerror( YYLTYPE *locp, Builder &bld, char const *msg ) 206void yyerror( YYLTYPE *locp, Builder &bld, char const *msg )