Created
March 31, 2011 11:03
-
-
Save codedot/896182 to your computer and use it in GitHub Desktop.
Makefile to determine Shell subgrammars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RULES = \ | |
complete_command \ | |
list \ | |
and_or \ | |
pipeline \ | |
pipe_sequence \ | |
command \ | |
compound_command \ | |
compound_list \ | |
term \ | |
for_clause \ | |
do_group \ | |
case_clause \ | |
case_list_ns \ | |
case_list \ | |
case_item_ns \ | |
case_item \ | |
if_clause \ | |
else_part \ | |
function_body \ | |
simple_command \ | |
cmd_prefix \ | |
cmd_suffix \ | |
redirect_list \ | |
io_redirect \ | |
linebreak \ | |
separator \ | |
sequential_sep \ | |
io_file \ | |
io_here \ | |
newline_list \ | |
separator_op \ | |
pattern \ | |
wordlist | |
all: | |
for rule in $(RULES); do \ | |
mkdir -p $$rule && \ | |
cd $$rule && \ | |
$(MAKE) -f ../Makefile $$rule && \ | |
cd - && \ | |
printf 'Result: %s includes %s rules\n' $$rule \ | |
`ls $$rule | wc -l` || \ | |
break; \ | |
done | |
clean: | |
rm -fr $(RULES) | |
$(RULES): | |
touch $@ | |
complete_command: list separator | |
list: separator_op and_or | |
and_or: pipeline linebreak | |
pipeline: pipe_sequence | |
pipe_sequence: command linebreak | |
command: simple_command compound_command redirect_list \ | |
linebreak function_body | |
compound_command: compound_list for_clause case_clause \ | |
if_clause do_group | |
compound_list: term newline_list separator | |
term: separator and_or | |
for_clause: linebreak do_group sequential_sep wordlist | |
do_group: compound_list | |
case_clause: linebreak case_list case_list_ns | |
case_list_ns: case_list case_item_ns | |
case_list: case_item | |
case_item_ns: pattern linebreak compound_list | |
case_item: pattern linebreak compound_list | |
if_clause: compound_list else_part | |
else_part: compound_list | |
function_body: compound_command redirect_list | |
simple_command: cmd_prefix cmd_suffix | |
cmd_prefix cmd_suffix redirect_list: io_redirect | |
io_redirect: io_file io_here | |
linebreak: newline_list | |
separator: separator_op linebreak newline_list | |
sequential_sep: linebreak newline_list | |
io_file io_here newline_list separator_op pattern wordlist: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment