[ 
https://issues.apache.org/jira/browse/GROOVY-9232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16911980#comment-16911980
 ] 

Yuli Zhan edited comment on GROOVY-9232 at 8/21/19 6:31 AM:
------------------------------------------------------------

Thanks Paul for the quick reply!

After researching for a while, I guess I am seeing this issue because I was 
using the official antlr4. The parrot parser's _build.gradle_ file suggests 
that it perfer TunnelVisonLab's optimized fork, where _baseContext_ option 
support is added 
([https://github.com/tunnelvisionlabs/antlr4/blob/master/doc/optimized-fork.md]).

Given the pervasive usage of baseContext in the 3.0 grammar, apparantly the 
official antlr4 cannot correctly parse Groovy's .g4 file at the moment. Still, 
it would be nice to see if we can make .g4 compatible with the mainstream 
antlr4, which supports a wider range of target languages(C++/Python/Go etc.). 
The optimized fork is only shipped with java target at the moment.

Changing the ticket type to `improvement`. Other suggestions are welcomed.

Thank you.

 

 

 


was (Author: zhanyl):
Thanks Paul for the quick reply!

After researching for a while, I guess I am seeing this issue because I was 
using the official antlr4. The parrot parser's _build.gradle_ file suggests 
that it perfer TunnelVisonLab's optimized fork, where _baseContext_ option 
support is added 
([https://github.com/tunnelvisionlabs/antlr4/blob/master/doc/optimized-fork.md]).

Given the pervasive usage of baseContext in the 3.0 grammar, apparantly the 
official antlr4 cannot correctly parse Groovy's .g4 file at the moment. Still, 
it would be nice to see if we can make .g4 compatible with the mainstream 
antlr4, which supports a wide range of target languages(C++/Python/Go etc.). 
The optimized fork is only shipped with java target at the moment.

Changing the ticket type to `improvement`. Other suggestions are welcomed.

Thank you.

 

 

 

> Failed to create parser from .g4 files using official ANTLR4.7.2
> ----------------------------------------------------------------
>
>                 Key: GROOVY-9232
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9232
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 3.0.0-beta-3
>            Reporter: Yuli Zhan
>            Priority: Minor
>
> I was trying to generate a parser from _GroovyLexer.g4_ and _GroovyParser.g4_ 
> using the official distribution of ANTLR4 (4.7.2). However, the following 
> error was thrown:
> {code:java}
> > antlr -Dlanguage=Go -o parser groovy/GroovyParser.g4
>  
> warning(83): groovy/GroovyParser.g4:342:10: unsupported option baseContext
> warning(83): groovy/GroovyParser.g4:374:10: unsupported option baseContext
> warning(83): groovy/GroovyParser.g4:379:10: unsupported option baseContext
> warning(83): groovy/GroovyParser.g4:479:10: unsupported option baseContext
> warning(83): groovy/GroovyParser.g4:489:10: unsupported option baseContext
> error(123): groovy/GroovyParser.g4:788:93: rule alt label castExprAlt 
> redefined in rule expression, originally in rule castOperandExpression
> error(123): groovy/GroovyParser.g4:789:93: rule alt label postfixExprAlt 
> redefined in rule expression, originally in rule castOperandExpression
> error(123): groovy/GroovyParser.g4:792:93: rule alt label unaryNotExprAlt 
> redefined in rule expression, originally in rule castOperandExpression
> error(123): groovy/GroovyParser.g4:798:93: rule alt label unaryAddExprAlt 
> redefined in rule expression, originally in rule castOperandExpression
> warning(83): groovy/GroovyParser.g4:883:10: unsupported option baseContext
> warning(83): groovy/GroovyParser.g4:1118:10: unsupported option baseContext
> warning(83): groovy/GroovyParser.g4:1133:10: unsupported option 
> baseContext{code}
>  



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to