2 %token _LANGLE_EQUALS_t
5 %token _RANGLE_EQUALS_t
12 %token _QUESTION_EQUALS_t
47 * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
49 * This file is part of Jam - see jam.c for Copyright information.
53 * jamgram.yy - jam grammar
55 * 04/13/94 (seiwald) - added shorthand L0 for null list pointer
56 * 06/01/94 (seiwald) - new 'actions existing' does existing sources
57 * 08/23/94 (seiwald) - Support for '+=' (append to variable)
58 * 08/31/94 (seiwald) - Allow ?= as alias for "default =".
59 * 09/15/94 (seiwald) - if conditionals take only single arguments, so
60 * that 'if foo == bar' gives syntax error (use =).
61 * 02/11/95 (seiwald) - when scanning arguments to rules, only treat
62 * punctuation keywords as keywords. All arg lists
63 * are terminated with punctuation keywords.
64 * 09/11/00 (seiwald) - Support for function calls; rules return LIST *.
65 * 01/22/01 (seiwald) - replace evaluate_if() with compile_eval()
66 * 01/24/01 (seiwald) - 'while' statement
67 * 03/23/01 (seiwald) - "[ on target rule ]" support
68 * 02/27/02 (seiwald) - un-break "expr : arg in list" syntax
69 * 03/02/02 (seiwald) - rules can be invoked via variable names
70 * 03/12/02 (seiwald) - set YYMAXDEPTH for big, right-recursive rules
71 * 02/28/02 (seiwald) - merge EXEC_xxx flags in with RULE_xxx
72 * 06/21/02 (seiwald) - support for named parameters
73 * 10/22/02 (seiwald) - working return/break/continue statements
78 %left _BARBAR_t _BAR_t
79 %left _AMPERAMPER_t _AMPER_t
80 %left _EQUALS_t _BANG_EQUALS_t IN_t
81 %left _LANGLE_t _LANGLE_EQUALS_t _RANGLE_t _RANGLE_EQUALS_t
95 # define YYMAXDEPTH 10000 /* for OSF and other less endowed yaccs */
97 # define F0 (LIST *(*)(PARSE *, LOL *, int *))0
98 # define P0 (PARSE *)0
101 # define pappend( l,r ) parse_make( compile_append,l,r,P0,S0,S0,0 )
102 # define pbreak( l,f ) parse_make( compile_break,l,P0,P0,S0,S0,f )
103 # define peval( c,l,r ) parse_make( compile_eval,l,r,P0,S0,S0,c )
104 # define pfor( s,l,r ) parse_make( compile_foreach,l,r,P0,s,S0,0 )
105 # define pif( l,r,t ) parse_make( compile_if,l,r,t,S0,S0,0 )
106 # define pincl( l ) parse_make( compile_include,l,P0,P0,S0,S0,0 )
107 # define plist( s ) parse_make( compile_list,P0,P0,P0,s,S0,0 )
108 # define plocal( l,r,t ) parse_make( compile_local,l,r,t,S0,S0,0 )
109 # define pnull() parse_make( compile_null,P0,P0,P0,S0,S0,0 )
110 # define pon( l,r ) parse_make( compile_on,l,r,P0,S0,S0,0 )
111 # define prule( a,p ) parse_make( compile_rule,a,p,P0,S0,S0,0 )
112 # define prules( l,r ) parse_make( compile_rules,l,r,P0,S0,S0,0 )
113 # define pset( l,r,a ) parse_make( compile_set,l,r,P0,S0,S0,a )
114 # define pset1( l,r,t,a ) parse_make( compile_settings,l,r,t,S0,S0,a )
115 # define psetc( s,l,r ) parse_make( compile_setcomp,l,r,P0,s,S0,0 )
116 # define psete( s,l,s1,f ) parse_make( compile_setexec,l,P0,P0,s,s1,f )
117 # define pswitch( l,r ) parse_make( compile_switch,l,r,P0,S0,S0,0 )
118 # define pwhile( l,r ) parse_make( compile_while,l,r,P0,S0,S0,0 )
120 # define pnode( l,r ) parse_make( F0,l,r,P0,S0,S0,0 )
121 # define psnode( s,l ) parse_make( F0,l,P0,P0,s,S0,0 )
130 { parse_save
( $1.parse
); }
134 * block - zero or more rules
135 * rules - one or more rules
136 * rule - any one of jam's rules
137 * right-recursive so rules execute in order.
141 { $$.parse
= pnull
(); }
143 { $$.parse
= $1.parse
; }
147 { $$.parse
= $1.parse
; }
149 { $$.parse
= prules
( $1.parse
, $2.parse
); }
150 | LOCAL_t list _SEMIC_t block
151 { $$.parse
= plocal
( $2.parse
, pnull
(), $4.parse
); }
152 | LOCAL_t list _EQUALS_t list _SEMIC_t block
153 { $$.parse
= plocal
( $2.parse
, $4.parse
, $6.parse
); }
156 rule
: _LBRACE_t block _RBRACE_t
157 { $$.parse
= $2.parse
; }
158 | INCLUDE_t list _SEMIC_t
159 { $$.parse
= pincl
( $2.parse
); }
161 { $$.parse
= prule
( $1.parse
, $2.parse
); }
162 | arg assign list _SEMIC_t
163 { $$.parse
= pset
( $1.parse
, $3.parse
, $2.number
); }
164 | arg ON_t list assign list _SEMIC_t
165 { $$.parse
= pset1
( $1.parse
, $3.parse
, $5.parse
, $4.number
); }
166 | BREAK_t list _SEMIC_t
167 { $$.parse
= pbreak
( $2.parse
, JMP_BREAK
); }
168 | CONTINUE_t list _SEMIC_t
169 { $$.parse
= pbreak
( $2.parse
, JMP_CONTINUE
); }
170 | RETURN_t list _SEMIC_t
171 { $$.parse
= pbreak
( $2.parse
, JMP_RETURN
); }
172 | FOR_t ARG IN_t list _LBRACE_t block _RBRACE_t
173 { $$.parse
= pfor
( $2.
string, $4.parse
, $6.parse
); }
174 | SWITCH_t list _LBRACE_t cases _RBRACE_t
175 { $$.parse
= pswitch
( $2.parse
, $4.parse
); }
176 | IF_t expr _LBRACE_t block _RBRACE_t
177 { $$.parse
= pif
( $2.parse
, $4.parse
, pnull
() ); }
178 | IF_t expr _LBRACE_t block _RBRACE_t ELSE_t rule
179 { $$.parse
= pif
( $2.parse
, $4.parse
, $7.parse
); }
180 | WHILE_t expr _LBRACE_t block _RBRACE_t
181 { $$.parse
= pwhile
( $2.parse
, $4.parse
); }
182 | RULE_t ARG params _LBRACE_t block _RBRACE_t
183 { $$.parse
= psetc
( $2.
string, $3.parse
, $5.parse
); }
185 { $$.parse
= pon
( $2.parse
, $3.parse
); }
186 | ACTIONS_t eflags ARG bindlist _LBRACE_t
187 { yymode
( SCAN_STRING
); }
189 { yymode
( SCAN_NORMAL
); }
191 { $$.parse
= psete
( $3.
string,$4.parse
,$7.
string,$2.number
); }
199 { $$.number
= VAR_SET
; }
201 { $$.number
= VAR_APPEND
; }
203 { $$.number
= VAR_DEFAULT
; }
204 | DEFAULT_t _EQUALS_t
205 { $$.number
= VAR_DEFAULT
; }
209 * expr - an expression for if
213 { $$.parse
= peval
( EXPR_EXISTS
, $1.parse
, pnull
() ); }
214 | expr _EQUALS_t expr
215 { $$.parse
= peval
( EXPR_EQUALS
, $1.parse
, $3.parse
); }
216 | expr _BANG_EQUALS_t expr
217 { $$.parse
= peval
( EXPR_NOTEQ
, $1.parse
, $3.parse
); }
218 | expr _LANGLE_t expr
219 { $$.parse
= peval
( EXPR_LESS
, $1.parse
, $3.parse
); }
220 | expr _LANGLE_EQUALS_t expr
221 { $$.parse
= peval
( EXPR_LESSEQ
, $1.parse
, $3.parse
); }
222 | expr _RANGLE_t expr
223 { $$.parse
= peval
( EXPR_MORE
, $1.parse
, $3.parse
); }
224 | expr _RANGLE_EQUALS_t expr
225 { $$.parse
= peval
( EXPR_MOREEQ
, $1.parse
, $3.parse
); }
227 { $$.parse
= peval
( EXPR_AND
, $1.parse
, $3.parse
); }
228 | expr _AMPERAMPER_t expr
229 { $$.parse
= peval
( EXPR_AND
, $1.parse
, $3.parse
); }
231 { $$.parse
= peval
( EXPR_OR
, $1.parse
, $3.parse
); }
232 | expr _BARBAR_t expr
233 { $$.parse
= peval
( EXPR_OR
, $1.parse
, $3.parse
); }
235 { $$.parse
= peval
( EXPR_IN
, $1.parse
, $3.parse
); }
237 { $$.parse
= peval
( EXPR_NOT
, $2.parse
, pnull
() ); }
238 | _LPAREN_t expr _RPAREN_t
239 { $$.parse
= $2.parse
; }
243 * cases - action elements inside a 'switch'
244 * case - a single action element inside a 'switch'
245 * right-recursive rule so cases can be examined in order.
251 { $$.parse
= pnode
( $1.parse
, $2.parse
); }
254 case
: CASE_t ARG _COLON_t block
255 { $$.parse
= psnode
( $2.
string, $4.parse
); }
259 * params - optional parameter names to rule definition
260 * right-recursive rule so that params can be added in order.
265 | ARG _COLON_t params
266 { $$.parse
= psnode
( $1.
string, $3.parse
); }
268 { $$.parse
= psnode
( $1.
string, P0
); }
272 * lol - list of lists
273 * right-recursive rule so that lists can be added in order.
277 { $$.parse
= pnode
( P0
, $1.parse
); }
279 { $$.parse
= pnode
( $3.parse
, $1.parse
); }
283 * list - zero or more args in a LIST
284 * listp - list (in puncutation only mode)
285 * arg - one ARG or function call
289 { $$.parse
= $1.parse
; yymode
( SCAN_NORMAL
); }
293 { $$.parse
= pnull
(); yymode
( SCAN_PUNCT
); }
295 { $$.parse
= pappend
( $1.parse
, $2.parse
); }
299 { $$.parse
= plist
( $1.
string ); }
300 | _LBRACKET_t
{ yymode
( SCAN_NORMAL
); } func _RBRACKET_t
301 { $$.parse
= $3.parse
; }
305 * func - a function call (inside [])
306 * This needs to be split cleanly out of 'rule'
310 { $$.parse
= prule
( $1.parse
, $2.parse
); }
312 { $$.parse
= pon
( $2.parse
, prule
( $3.parse
, $4.parse
) ); }
313 | ON_t arg RETURN_t list
314 { $$.parse
= pon
( $2.parse
, $4.parse
); }
318 * eflags - zero or more modifiers to 'executes'
319 * eflag - a single modifier to 'executes'
325 { $$.number
= $1.number |
$2.number
; }
329 { $$.number
= RULE_UPDATED
; }
331 { $$.number
= RULE_TOGETHER
; }
333 { $$.number
= RULE_IGNORE
; }
335 { $$.number
= RULE_QUIETLY
; }
337 { $$.number
= RULE_PIECEMEAL
; }
339 { $$.number
= RULE_EXISTING
; }
341 { $$.number
= atoi
( $2.
string ) * RULE_MAXLINE
; }
346 * bindlist - list of variable to bind for an action
349 bindlist
: /* empty */
350 { $$.parse
= pnull
(); }
352 { $$.parse
= $2.parse
; }