Brent
Brent

Reputation: 4283

How would I normalize the following ANTLR grammar rules to eliminate left recursion?

I'd like to be able to treat:

int(int, int)

As a function type. How do I normalize this (stripped down) grammar?

type : classOrInterfaceType | primitiveType | functionType;
functionType : type '(' (type (',' type)*)? ')';

classOrInterfaceType : ;
primitiveType : ;

Upvotes: 0

Views: 138

Answers (1)

Brent
Brent

Reputation: 4283

There's an algorithm for eliminating left recursion. http://web.cs.wpi.edu/~kal/PLT/PLT4.1.2.html

Upvotes: 0

Related Questions