You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Jack Conradson (JIRA)" <ji...@apache.org> on 2015/07/24 07:07:04 UTC

[jira] [Comment Edited] (LUCENE-6417) Upgrade ANTLR to version 4.5

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

Jack Conradson edited comment on LUCENE-6417 at 7/24/15 5:06 AM:
-----------------------------------------------------------------

This patch contains the code necessary to upgrade to ANTLR 4.5.

The following changes are included:
* Updated the build.xml and ivy.xml to use ANTLR 4.5 instead of the prior version.
* Modified the grammar to use only two parser rules including a left-hand recursive rule for the majority of the language.  Simplified the lexer rules.
* Used the provided visitor pattern classes ANTLR 4.5 provides to move through the ANTLR parse tree.  The JavascriptCompiler nows inherits from a JavascriptBaseVisitor class.  While this does add some extra methods, it's also a well-known design pattern that can be easily modified by future contributors.  This allows for easy use of new rule context objects, so that some tokens may be ignored that aren't necessary.  Note that ANTLR 4.5 no longer has ASTs because it does not allow for tree rewriting.  The provided parse tree required some changes to the compiler since the root nodes now contain 3 children with something like '2' '-' '3' rather than tokens such as '-' with 2 children.
* Moved all error handling out of the grammar file making the grammar language agnostic.  Error handling is now part of separate java classes.


was (Author: jdconradson):
This patch contains the code necessary to upgrade to ANTLR 4.5.

The following changes are included:
* Updated the build.xml and ivy.xml to use ANTLR 4.5 instead of the prior version.
* Modified the grammar to use only two parser rules including a left-hand recursive rule for the majority of the language.  Simplified the lexer rules.
* Used the provided visitor pattern classes ANTLR 4.5 provides to move through the ANTLR parse tree.  The JavascriptCompiler nows inherits from a JavascriptBaseVisitor class.  While this does add some extra methods, it's also a well-known design pattern that can be easily modified by future contributors.  This allows for easy use of new rule context objects, so that some tokens may be ignored that aren't necessary.  Note that ANTLR 4.5 no longer has ASTs because it does not allow for tree rewriting.  The provided parse tree required some changes to the compiler since the root nodes now contain 3 children with something like '2' '*' '3' rather than tokens such as '*' or '-' with 2 children.
* Moved all error handling out of the grammar file making the grammar language agnostic.  Error handling is now part of separate java classes.

> Upgrade ANTLR to version 4.5
> ----------------------------
>
>                 Key: LUCENE-6417
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6417
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Jack Conradson
>         Attachments: LUCENE-6471.patch
>
>
> I would like to upgrade ANTLR from 3.5 to 4.5.  This version adds several features that will improve the existing grammars.  The main improvement would be the allowance of left-hand recursion in grammar rules which will reduce the number of rules significantly for expressions.
> This change will require some code refactoring to the existing expressions work.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org