简体   繁体   中英

Left Recursion: ANTLR

I am trying to do Lexical Analysis in Java grammar, but got stack in that error. I am in expression part right now, doing it in parts (just using string_expression):

expression:
    ( expression8)
;

expression8:
    {Expression8Action}
    ((  
      ( "+" 
      | "+=" ) 
      e2=expression )e1=expression8)?
;

Solved with turning on backtrack (file .mwe2):

language = StandardLanguage {
        name = "org.xtext.example.mydsl.MyDsl"
        fileExtensions = "mydsl"

        serializer = {
            generateStub = false
        }
        validator = {
            // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
        }
        parserGenerator = {
            options = {
                backtrack = true
            }
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM