11 %token _LANGLE_EQUALS_t
14 %token _RANGLE_EQUALS_t
15 %token _QUESTION_EQUALS_t
46 * Copyright 1993, 2000 Christopher Seiwald.
48 * This file is part of Jam - see jam.c for Copyright information.
52 * Copyright 2001-2004 David Abrahams.
53 * Distributed under the Boost Software License, Version 1.0.
54 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
58 * jamgram.yy - jam grammar
60 * 04/13/94 (seiwald) - added shorthand L0 for null list pointer
61 * 06/01/94 (seiwald) - new 'actions existing' does existing sources
62 * 08/23/94 (seiwald) - Support for '+=' (append to variable)
63 * 08/31/94 (seiwald) - Allow ?= as alias for "default =".
64 * 09/15/94 (seiwald) - if conditionals take only single arguments, so
65 * that 'if foo == bar' gives syntax error (use =).
66 * 02/11/95 (seiwald) - when scanning arguments to rules, only treat
67 * punctuation keywords as keywords. All arg lists
68 * are terminated with punctuation keywords.
70 * 09/11/00 (seiwald) - Support for function calls:
72 * Rules now return lists (LIST *), rather than void.
74 * New "[ rule ]" syntax evals rule into a LIST.
76 * Lists are now generated by compile_list() and
77 * compile_append(), and any other rule that indirectly
78 * makes a list, rather than being built directly here,
79 * so that lists values can contain rule evaluations.
81 * New 'return' rule sets the return value, though
82 * other statements also may have return values.
84 * 'run' production split from 'block' production so
85 * that empty blocks can be handled separately.
90 %left _BARBAR_t _BAR_t
91 %left _AMPERAMPER_t _AMPER_t
92 %left _EQUALS_t _BANG_EQUALS_t IN_t
93 %left _LANGLE_t _LANGLE_EQUALS_t _RANGLE_t _RANGLE_EQUALS_t
106 # define YYMAXDEPTH 10000 /* for OSF and other less endowed yaccs */
108 # define F0 (LIST *(*)(PARSE *, FRAME *))0
109 # define P0 (PARSE *)0
110 # define S0 (char *)0
112 # define pappend( l,r ) parse_make( compile_append,l,r,P0,S0,S0,0 )
113 # define peval( c,l,r ) parse_make( compile_eval,l,r,P0,S0,S0,c )
114 # define pfor( s,l,r,x ) parse_make( compile_foreach,l,r,P0,s,S0,x )
115 # define pif( l,r,t ) parse_make( compile_if,l,r,t,S0,S0,0 )
116 # define pincl( l ) parse_make( compile_include,l,P0,P0,S0,S0,0 )
117 # define plist( s ) parse_make( compile_list,P0,P0,P0,s,S0,0 )
118 # define plocal( l,r,t ) parse_make( compile_local,l,r,t,S0,S0,0 )
119 # define pmodule( l,r ) parse_make( compile_module,l,r,P0,S0,S0,0 )
120 # define pclass( l,r ) parse_make( compile_class,l,r,P0,S0,S0,0 )
121 # define pnull() parse_make( compile_null,P0,P0,P0,S0,S0,0 )
122 # define pon( l,r ) parse_make( compile_on,l,r,P0,S0,S0,0 )
123 # define prule( s,p ) parse_make( compile_rule,p,P0,P0,s,S0,0 )
124 # define prules( l,r ) parse_make( compile_rules,l,r,P0,S0,S0,0 )
125 # define pset( l,r,a ) parse_make( compile_set,l,r,P0,S0,S0,a )
126 # define pset1( l,r,t,a ) parse_make( compile_settings,l,r,t,S0,S0,a )
127 # define psetc( s,p,a,l ) parse_make( compile_setcomp,p,a,P0,s,S0,l )
128 # define psete( s,l,s1,f ) parse_make( compile_setexec,l,P0,P0,s,s1,f )
129 # define pswitch( l,r ) parse_make( compile_switch,l,r,P0,S0,S0,0 )
130 # define pwhile( l,r ) parse_make( compile_while,l,r,P0,S0,S0,0 )
132 # define pnode( l,r ) parse_make( F0,l,r,P0,S0,S0,0 )
133 # define psnode( s,l ) parse_make( F0,l,P0,P0,s,S0,0 )
142 { parse_save( $1.parse ); }
146 * block - zero or more rules
147 * rules - one or more rules
148 * rule - any one of jam's rules
149 * right-recursive so rules execute in order.
153 { $$.parse = $1.parse; }
155 { $$.parse = $1.parse; }
159 { $$.parse = $1.parse; }
161 { $$.parse = prules( $1.parse, $2.parse ); }
162 | LOCAL_t list assign_list_opt _SEMIC_t block
163 { $$.parse = plocal( $2.parse, $3.parse, $5.parse ); }
167 { $$.parse = pnull(); }
170 assign_list_opt : _EQUALS_t list
171 { $$.parse = $2.parse; $$.number = ASSIGN_SET; }
173 { $$.parse = $1.parse; $$.number = ASSIGN_APPEND; }
176 arglist_opt : _LPAREN_t lol _RPAREN_t
177 { $$.parse = $2.parse; }
188 rule : _LBRACE_t block _RBRACE_t
189 { $$.parse = $2.parse; }
190 | INCLUDE_t list _SEMIC_t
191 { $$.parse = pincl( $2.parse ); }
193 { $$.parse = prule( $1.string, $2.parse ); }
194 | arg assign list _SEMIC_t
195 { $$.parse = pset( $1.parse, $3.parse, $2.number ); }
196 | arg ON_t list assign list _SEMIC_t
197 { $$.parse = pset1( $1.parse, $3.parse, $5.parse, $4.number ); }
198 | RETURN_t list _SEMIC_t
199 { $$.parse = $2.parse; }
200 | FOR_t local_opt ARG IN_t list _LBRACE_t block _RBRACE_t
201 { $$.parse = pfor( $3.string, $5.parse, $7.parse, $2.number ); }
202 | SWITCH_t list _LBRACE_t cases _RBRACE_t
203 { $$.parse = pswitch( $2.parse, $4.parse ); }
204 | IF_t expr _LBRACE_t block _RBRACE_t
205 { $$.parse = pif( $2.parse, $4.parse, pnull() ); }
206 | MODULE_t list _LBRACE_t block _RBRACE_t
207 { $$.parse = pmodule( $2.parse, $4.parse ); }
208 | CLASS_t lol _LBRACE_t block _RBRACE_t
209 { $$.parse = pclass( $2.parse, $4.parse ); }
210 | WHILE_t expr _LBRACE_t block _RBRACE_t
211 { $$.parse = pwhile( $2.parse, $4.parse ); }
212 | IF_t expr _LBRACE_t block _RBRACE_t ELSE_t rule
213 { $$.parse = pif( $2.parse, $4.parse, $7.parse ); }
214 | local_opt RULE_t ARG arglist_opt rule
215 { $$.parse = psetc( $3.string, $5.parse, $4.parse, $1.number ); }
217 { $$.parse = pon( $2.parse, $3.parse ); }
218 | ACTIONS_t eflags ARG bindlist _LBRACE_t
219 { yymode( SCAN_STRING ); }
221 { yymode( SCAN_NORMAL ); }
223 { $$.parse = psete( $3.string,$4.parse,$7.string,$2.number ); }
231 { $$.number = ASSIGN_SET; }
233 { $$.number = ASSIGN_APPEND; }
235 { $$.number = ASSIGN_DEFAULT; }
236 | DEFAULT_t _EQUALS_t
237 { $$.number = ASSIGN_DEFAULT; }
241 * expr - an expression for if
244 { $$.parse = peval( EXPR_EXISTS, $1.parse, pnull() ); }
245 | expr _EQUALS_t expr
246 { $$.parse = peval( EXPR_EQUALS, $1.parse, $3.parse ); }
247 | expr _BANG_EQUALS_t expr
248 { $$.parse = peval( EXPR_NOTEQ, $1.parse, $3.parse ); }
249 | expr _LANGLE_t expr
250 { $$.parse = peval( EXPR_LESS, $1.parse, $3.parse ); }
251 | expr _LANGLE_EQUALS_t expr
252 { $$.parse = peval( EXPR_LESSEQ, $1.parse, $3.parse ); }
253 | expr _RANGLE_t expr
254 { $$.parse = peval( EXPR_MORE, $1.parse, $3.parse ); }
255 | expr _RANGLE_EQUALS_t expr
256 { $$.parse = peval( EXPR_MOREEQ, $1.parse, $3.parse ); }
258 { $$.parse = peval( EXPR_AND, $1.parse, $3.parse ); }
259 | expr _AMPERAMPER_t expr
260 { $$.parse = peval( EXPR_AND, $1.parse, $3.parse ); }
262 { $$.parse = peval( EXPR_OR, $1.parse, $3.parse ); }
263 | expr _BARBAR_t expr
264 { $$.parse = peval( EXPR_OR, $1.parse, $3.parse ); }
266 { $$.parse = peval( EXPR_IN, $1.parse, $3.parse ); }
268 { $$.parse = peval( EXPR_NOT, $2.parse, pnull() ); }
269 | _LPAREN_t expr _RPAREN_t
270 { $$.parse = $2.parse; }
275 * cases - action elements inside a 'switch'
276 * case - a single action element inside a 'switch'
277 * right-recursive rule so cases can be examined in order.
283 { $$.parse = pnode( $1.parse, $2.parse ); }
286 case : CASE_t ARG _COLON_t block
287 { $$.parse = psnode( $2.string, $4.parse ); }
291 * lol - list of lists
292 * right-recursive rule so that lists can be added in order.
296 { $$.parse = pnode( P0, $1.parse ); }
298 { $$.parse = pnode( $3.parse, $1.parse ); }
302 * list - zero or more args in a LIST
303 * listp - list (in puncutation only mode)
304 * arg - one ARG or function call
308 { $$.parse = $1.parse; yymode( SCAN_NORMAL ); }
312 { $$.parse = pnull(); yymode( SCAN_PUNCT ); }
314 { $$.parse = pappend( $1.parse, $2.parse ); }
318 { $$.parse = plist( $1.string ); }
319 | _LBRACKET_t { yymode( SCAN_NORMAL ); } func _RBRACKET_t
320 { $$.parse = $3.parse; }
324 * func - a function call (inside [])
325 * This needs to be split cleanly out of 'rule'
329 { $$.parse = prule( $1.string, $2.parse ); }
331 { $$.parse = pon( $2.parse, prule( $3.string, $4.parse ) ); }
332 | ON_t arg RETURN_t list
333 { $$.parse = pon( $2.parse, $4.parse ); }
338 * eflags - zero or more modifiers to 'executes'
339 * eflag - a single modifier to 'executes'
345 { $$.number = $1.number | $2.number; }
349 { $$.number = EXEC_UPDATED; }
351 { $$.number = EXEC_TOGETHER; }
353 { $$.number = EXEC_IGNORE; }
355 { $$.number = EXEC_QUIETLY; }
357 { $$.number = EXEC_PIECEMEAL; }
359 { $$.number = EXEC_EXISTING; }
364 * bindlist - list of variable to bind for an action
367 bindlist : /* empty */
368 { $$.parse = pnull(); }
370 { $$.parse = $2.parse; }