Lines Matching full:p
32 def make_io_redirect(p): argument
34 name, io_number, io_target = p
127 def p_multiple_commands(p): argument
131 if len(p)==2:
132 if p[1] is not None:
133 p[0] = [p[1]]
135 p[0] = []
137 p[0] = p[1] + [p[2]]
139 def p_complete_command(p): argument
142 if len(p)==3 and p[2] and p[2][1] == '&':
143 p[0] = ('async', p[1])
145 p[0] = p[1]
147 def p_list(p): argument
150 if len(p)==2:
151 p[0] = [p[1]]
153 #if p[2]!=';':
155 p[0] = p[1] + [p[3]]
157 def p_and_or(p): argument
161 if len(p)==2:
162 p[0] = p[1]
164 p[0] = ('and_or', AndOr(p[2], p[1], p[4]))
166 def p_maybe_bang_word(p): argument
168 p[0] = ('maybe_bang_word', p[1])
170 def p_pipeline(p): argument
173 if len(p)==3:
174 p[0] = ('pipeline', Pipeline(p[2][1:], True))
176 p[0] = ('pipeline', Pipeline(p[1][1:]))
178 def p_pipe_sequence(p): argument
181 if len(p)==2:
182 p[0] = ['pipe_sequence', p[1]]
184 p[0] = p[1] + [p[4]]
186 def p_command(p): argument
192 if p[1][0] in ( 'simple_command',
201 if len(p) == 2:
202 p[0] = p[1]
204 p[0] = ('redirect_list', RedirectList(p[1], p[2][1:]))
206 raise NotImplementedError('%s command is not implemented' % repr(p[1][0]))
208 def p_compound_command(p): argument
216 p[0] = p[1]
218 def p_subshell(p): argument
220 p[0] = ('subshell', SubShell(p[2][1:]))
222 def p_compound_list(p): argument
227 productions = p[1:]
235 p[0] = ['compound_list'] + term[1:]
237 def p_term(p): argument
240 if len(p)==2:
241 p[0] = ['term', p[1]]
243 if p[2] is not None and p[2][1] == '&':
244 p[0] = ['term', ('async', p[1][1:])] + [p[3]]
246 p[0] = p[1] + [p[3]]
248 def p_maybe_for_word(p): argument
251 p[0] = ('maybe_for_word', p[1])
253 def p_for_clause(p): argument
257 productions = p[1:]
269 name = p[2]
270 p[0] = ('for_clause', ForLoop(name, items, do_group[1:]))
272 def p_name(p): argument
274 p[0] = p[1]
276 def p_in(p): argument
278 p[0] = ('in', p[1])
280 def p_wordlist(p): argument
283 if len(p)==2:
284 p[0] = ['wordlist', ('TOKEN', p[1])]
286 p[0] = p[1] + [('TOKEN', p[2])]
288 def p_case_clause(p): argument
292 if len(p) < 8:
295 items = p[6][1:]
296 name = p[2]
297 p[0] = ('case_clause', Case(name, [c[1] for c in items]))
299 def p_case_list_ns(p): argument
302 p_case_list(p)
304 def p_case_list(p): argument
307 if len(p)==2:
308 p[0] = ['case_list', p[1]]
310 p[0] = p[1] + [p[2]]
312 def p_case_item_ns(p): argument
317 p_case_item(p)
319 def p_case_item(p): argument
324 if len(p) < 7:
325 name = p[1][1:]
327 name = p[2][1:]
330 cmds = get_production(p[1:], "compound_list")[1:]
334 p[0] = ('case_item', (name, cmds))
336 def p_pattern(p): argument
339 if len(p)==2:
340 p[0] = ['pattern', ('TOKEN', p[1])]
342 p[0] = p[1] + [('TOKEN', p[2])]
344 def p_maybe_if_word(p): argument
347 p[0] = ('maybe_if_word', p[1])
349 def p_maybe_then_word(p): argument
352 p[0] = ('maybe_then_word', p[1])
354 def p_if_clause(p): argument
358 if len(p)==7:
359 else_part = p[5]
360 p[0] = ('if_clause', IfCond(p[2][1:], p[4][1:], else_part))
362 def p_else_part(p): argument
366 if len(p)==3:
367 p[0] = p[2][1:]
370 if len(p)==6:
371 else_part = p[5]
372 p[0] = ('elif', IfCond(p[2][1:], p[4][1:], else_part))
374 def p_while_clause(p): argument
376 p[0] = ('while_clause', WhileLoop(p[2][1:], p[3][1:]))
378 def p_maybe_until_word(p): argument
381 p[0] = ('maybe_until_word', p[1])
383 def p_until_clause(p): argument
385 p[0] = ('until_clause', UntilLoop(p[2][1:], p[3][1:]))
387 def p_function_definition(p): argument
389 p[0] = ('function_definition', FunDef(p[1], p[5]))
391 def p_function_body(p): argument
394 if len(p)!=2:
396 p[0] = p[1]
398 def p_fname(p): argument
400 p[0] = p[1]
402 def p_brace_group(p): argument
404 p[0] = ('brace_group', BraceGroup(p[2][1:]))
406 def p_maybe_done_word(p): argument
409 p[0] = ('maybe_done_word', p[1])
411 def p_maybe_do_word(p): argument
413 p[0] = ('maybe_do_word', p[1])
415 def p_do_group(p): argument
418 p[0] = ['do_group'] + p[2][1:]
420 def p_simple_command(p): argument
427 for e in p[1:]:
442 p[0] = ('simple_command', cmd)
444 def p_cmd_name(p): argument
446 p[0] = ('cmd_name', p[1])
448 def p_cmd_word(p): argument
450 p[0] = ('cmd_word', p[1])
452 def p_maybe_assignment_word(p): argument
455 p[0] = ('maybe_assignment_word', p[1])
457 def p_cmd_prefix(p): argument
463 prefix = get_production(p[1:], 'cmd_prefix')
468 value = get_production(p[1:], 'assignment_word')[1]
471 value = get_production(p[1:], 'io_redirect')
472 p[0] = prefix + [value]
474 def p_cmd_suffix(p): argument
496 suffix = get_production(p[1:], 'cmd_suffix')
497 token = p[2]
500 token = p[1]
504 p[0] = suffix + [token]
507 p[0] = suffix + [('TOKEN', token[1])]
509 p[0] = suffix + [('TOKEN', token)]
511 def p_redirect_list(p): argument
514 if len(p) == 2:
515 p[0] = ['redirect_list', make_io_redirect(p[1])]
517 p[0] = p[1] + [make_io_redirect(p[2])]
519 def p_io_redirect(p): argument
524 if len(p)==3:
525 p[0] = ('io_redirect', p[1], p[2])
527 p[0] = ('io_redirect', None, p[1])
529 def p_io_file(p): argument
539 p[0] = ('io_file', p[1], p[2][1])
541 def p_filename(p): argument
544 p[0] = ('filename', p[1])
546 def p_io_here(p): argument
549 p[0] = ('io_here', p[1], p[2][1], p[2][2])
551 def p_here_end(p): argument
553 p[0] = ('here_document', p[1], p[2])
555 def p_newline_sequence(p): argument
559 p[0] = None
561 def p_newline_list(p): argument
564 p[0] = None
566 def p_linebreak(p): argument
569 p[0] = None
571 def p_separator_op(p): argument
575 p[0] = p[1]
577 def p_separator(p): argument
580 if len(p)==2:
582 p[0] = None
585 p[0] = ('separator', p[1])
587 def p_sequential_sep(p): argument
590 p[0] = None
595 def p_for_word(p): argument
597 p[0] = p[1]
599 def p_if_word(p): argument
601 p[0] = p[1]
603 def p_then_word(p): argument
605 p[0] = p[1]
607 def p_done_word(p): argument
609 p[0] = p[1]
611 def p_do_word(p): argument
613 p[0] = p[1]
615 def p_until_word(p): argument
617 p[0] = p[1]
619 def p_assignment_word(p): argument
621 p[0] = ('assignment_word', p[1][1])
623 def p_bang_word(p): argument
625 p[0] = ('bang_word', p[1][1])
627 def p_token(p): argument
630 p[0] = p[1]
632 def p_empty(p): argument
634 p[0] = None
637 def p_error(p): argument
640 if p:
641 w('%r\n' % p)