home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
unix
/
volume12
/
cake
/
part09
/
Script
/
yygram
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
AWK Script
|
1987-10-15
|
377 b
|
29 lines
#!/bin/awk -f
# extract the grammar from a yacc file
# usage yygram file ...
BEGIN {
num = 0;
braces = 0;
}
/^%%$/ {
braces++;
next;
}
/JUNK/ { exit; }
NF == 0 { next; }
/\t;/ { next; }
{
if (index($0, "{") > 0)
num++;
if (num == 0 && braces == 1)
print;
if (index($0, "}") > 0)
num--;
}
END {
if (num != 0)
print "Unmatched braces";
}