问题
How can I use these BNF grammars which are in GOLD meta-syntax (RegExp + BNF) with TinyPG? I'm new to BNF so approximately what sort of conversion will I have to do to convert BNF to EBNF?
I believe it should be pretty simple since TinyPG needs RegExp + EBNF in comparison to the GOLD grammars which are RegExp + BNF.
Also, is there any TinyPG source code for any language available, just to see what sort of conversion I would have to do?
回答1:
EBNF is not entirely backwards compatible with BNF, however the differences are actually slight, you should be familiar with the document at
http://www.cs.cmu.edu/~pattis/misc/ebnf.pdf
Primarily you have to handle the special characters <>|:= (enclosed in double quotes).
You could just use the GOLD meta-syntax engine to output your parser if it can be in one of the supported languages - instead of using TinyPG...
It begs the question - What language will your parser be in when you are implementing it?
来源:https://stackoverflow.com/questions/321245/use-existing-languages-in-bnf-with-tinypg