I am looking for a Go library providing CFG parsing (preferably not in Chomsky Normal Form). Has anybody heard of anything, or should I write it ? :)
Most programming language grammars are not context-free. That means the parser has to maintain state in order to process a snippet of the language. Often when discussing context somebody will point out the parsing strings, parentheses and so on also require a kind of state in order to match their terminators.
These are rules that, when applied, can generate all possible legal phrases in the language. Parsing Expression Grammar (PEG) — describes a CFG in terms of recognition rules. These are rules that can be used to match valid phrases in the language.
A context free grammar (CFG) is a forma grammar which is used to generate all the possible patterns of strings in a given formal language.
A CFG only defines a language. It does not say how to determine whether a given string belongs to the language it defines. To do this, a parser can be used whose task is to map a string of words to its parse tree. The parse tree of course remains the same.
Do you know about goyacc?. Although it's not a library, but a code generator. Anyway it supports CFGs and it's IMO a pretty standard way to handle such tasks. (?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With