0

I want to handle the Scala grammar in order to create a data structure and I want to create a graph to model it. The problem that I have is that I want to get rid of some syntax sugar of the EBNF grammar in order to parse it in an efficient way.

For example if I have the following rule:

Expr ::= (Bindings | id | '_') '=>' Expr | Expr1

I want the corresponding rules for it:

Expr ::= LeftExpr '=>' Expr | Expr1
LeftExpr ::= Bindings | id | '_'

What I would really appreciate would be a tool which can automatically convert those rules in order to have left-associativity rules with only OR operators in order to avoid doing it manually. I think it's possible a thing like that, maybe without some semantic sense of the new added rules, e.g. it's the same if LeftExpr is Foo or whatever other name.

I looked at web sources but the argument is so confusing that I cannot find the right answer. Any help is appreciated, also just a link (really) related to the problem. Thank you

GioAgu
  • 59
  • 6

0 Answers0