Commit 3064cafb authored by Seblu's avatar Seblu

ajoute le fichier de la grammaire du 42sh

parent 392117bf
good_input: simple_list '\n'
| '\n'
| EOF
redirection: [NUMBER] '>' WORD
| [NUMBER] '<' WORD
| [NUMBER] '>>' WORD
| [NUMBER] '<<' WORD
| [NUMBER] '<<-' WORD
| [NUMBER] '>&' WORD
| [NUMBER] '<&' WORD
| [NUMBER] '>|' WORD
| [NUMBER] '<>' WORD
element: WORD
| redirection
cmd_prefix: ASSIGMENT_WORD
| redirection
simple_command: (cmp_prefix)* (element)+
command: simple_command
| shell_command (redirection)*
| function_def
simple_list: and_or ((';'|'&') and_or)* ['&'|';']
and_or: pipeline (('&&'|'||') ('\n')* pipeline)*
pipeline: ['!'] command ('|' ('\n')* command)*
shell_command: '{' compound_list '}'
| '(' compound_list ')'
| rule_for
| rule_while
| rule_until
| rule_case
| rule_if
rule_if: 'if' compound_list 'then' compound_list [else_clause] 'fi'
else_clause: 'else' compound_list
| 'elif' compound_list 'then' compound_list [else_clause]
rule_for: 'for' WORD ('\n')* ['in' (WORD)+ (';'|'\n') ('\n')*] do_group
rule_while: 'while' compound_list do_group
rule_until: 'until' compound_list do_group
do_group: 'do' compound_list 'done'
compound_list: ('\n')* and_or ((';'|'&'|'\n') ('\n')* and_or)* [(('&'|';'|'\n') ('\n')*)]
case: 'case' WORD ('\n')* 'in' ('\n')* [case_clause] 'esac'
case_clause: pattern (';;' (\n)* pattern)* [;;]
pattern: ['('] WORD ('|' WORD)* ')' ( ('\n')* | compound_list )
function: ['function'] WORD '(' ')' ('\n')* shell_command (redirection)*
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Wed Aug 2 01:13:56 2006 Seblu
** Last update Wed Aug 2 17:58:03 2006 Seblu
** Last update Wed Aug 2 20:24:51 2006 Seblu
*/
#include <string.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment