Re: yacc to BNF anyone

viren@wipro.wipsys.soft.net (Virendra Kumar Mehta)
Fri, 23 Jul 1993 10:08:56 GMT

          From comp.compilers

Related articles
yacc to BNF anyone jasonl@munta.cs.mu.OZ.AU (1993-07-22)
Re: yacc to BNF anyone viren@wipro.wipsys.soft.net (1993-07-23)
| List of all articles for this month |
Newsgroups: comp.compilers
From: viren@wipro.wipsys.soft.net (Virendra Kumar Mehta)
Keywords: yacc
Organization: Compilers Central
References: 93-07-069
Date: Fri, 23 Jul 1993 10:08:56 GMT

> Does anyone know of any tool/program/hack etc that given
> a yacc file will extract the bnf grammar ???


I guess you want the '.y' file with only the rules and not the actions.
John's solution of using the '.output' file with a script will be good
enough in that case.


In case you do not have Berkeley yacc, most yacc implementations store the
rules in the '.tab.c' file as an array of strings (which they use later to
print messages if YYDEBUG is set). You could extract this array and just
replace ':' to '::=' again, or whatever form you want it in.


(If nothing else works, use the brute force approach. A vi macro that
mathces a '{' and deletes till the matching '}' worked for me once.)


viren.
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.