You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
459 B
23 lines
459 B
#
|
|
# clean_y.awk - given an awk grammar, produce a cleaned listing
|
|
# of just the grammar, without the actions.
|
|
#
|
|
# usage:
|
|
#
|
|
# gawk -f clean_y.awk grammar.y >grammar.out
|
|
#
|
|
BEGIN { in_body=0
|
|
in_brackets=0
|
|
}
|
|
/%%/ { in_body=1-in_body }
|
|
($1=="{") && (in_body==1) {
|
|
in_brackets++
|
|
}
|
|
(in_body==1) && (in_brackets==0)
|
|
($1=="};") && (in_body==1) {
|
|
in_brackets--
|
|
}
|
|
($1=="}") && (in_body==1) {
|
|
in_brackets--
|
|
}
|
|
END {}
|