mdaines / grammophone

A tool for analyzing and transforming context-free grammars.
https://mdaines.github.io/grammophone
MIT License
206 stars 24 forks source link

How to insert/use Epsilon? #4

Closed evandrocoan closed 6 years ago

evandrocoan commented 6 years ago

I can just insert ε or is there another symbol for it?

S -> ε   | b I | a P | a.
P -> a P | b I | a.
I -> a I | b P | b.
mdaines commented 6 years ago

There is no explicit epsilon symbol in the master branch. So you would write this:

S -> | b I | a P | a .

The syntax branch adds a special #epsilon symbol:

https://github.com/mdaines/grammophone/blob/823d927e91a3a62d1e23f4b45c034514b76f421d/test/parsing-test.js#L76

evandrocoan commented 6 years ago

Thanks, took me some time to realize you had did S -> |

S ->     | b I | a P | a.
P -> a P | b I | a.
I -> a I | b P | b.

Can I use a colon instead of a dot to end lines:

S ->     | b I | a P | a;
P -> a P | b I | a;
I -> a I | b P | b;

Or can the line just be ended by the new line \n character?

S ->     | b I | a P | a
P -> a P | b I | a
I -> a I | b P | b
mdaines commented 6 years ago

In the syntax branch, you can do both of those things.

https://github.com/mdaines/grammophone/blob/syntax/test/parsing-test.js

mdaines commented 6 years ago

I've added this to master in da2b67bc41531597eeca1b4dad586ea28d88e81d.

evandrocoan commented 6 years ago

Thanks! I merged locally the changes and they are working great!