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

StackOverflow https://stackoverflow.com/questions/16003248

  •  03-04-2022
  •  | 
  •  

문제

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 : ;
도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top