You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2021/06/03 11:32:10 UTC
[commons-jexl] 02/02: JEXL-348: refined grammar using semantic
infos and a syntactic kludge as fallback to allow user disambiguation of
namespace usage, tests
This is an automated email from the ASF dual-hosted git repository.
henrib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git
commit 263e221a7a71b1b14469d6778b681f5100fa4e81
Author: henrib <he...@apache.org>
AuthorDate: Thu Jun 3 13:32:00 2021 +0200
JEXL-348: refined grammar using semantic infos and a syntactic kludge as fallback to allow user disambiguation of namespace usage, tests
---
.../org/apache/commons/jexl3/parser/Parser.jjt | 24 ++++++----------------
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt
index 8280a6d..73622ea 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt
+++ b/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt
@@ -19,7 +19,7 @@
options
{
MULTI=true;
- STATIC=false;
+ //STATIC=false;
VISITOR=true;
NODE_SCOPE_HOOK=true;
NODE_CLASS="JexlNode";
@@ -507,11 +507,7 @@ void ConditionalExpression() #void : {}
{
ConditionalOrExpression()
(
- <QMARK> (LOOKAHEAD(<IDENTIFIER> <COLON> , { !isDeclaredNamespace(getToken(1), getToken(2)) })
- Identifier(true)
- |
- Expression()
- ) <COLON> Expression() #TernaryNode(3)
+ <QMARK> Expression() <COLON> Expression() #TernaryNode(3)
|
<ELVIS> Expression() #TernaryNode(2)
|
@@ -651,15 +647,7 @@ void NamespaceIdentifier() #NamespaceIdentifier :
Token id;
}
{
- ns=<IDENTIFIER> <COLON> id=<IDENTIFIER> { jjtThis.setNamespace(ns.image, id.image); }
-}
-
-void StringIdentifier() #Identifier :
-{
- Token t;
-}
-{
- t=<STRING_LITERAL> { jjtThis.setSymbol(Parser.buildString(t.image, true)); }
+ ns=<IDENTIFIER> <COLON> id=<IDENTIFIER> { jjtThis.setNamespace(ns.image, id.image); }
}
void Literal() #void :
@@ -799,7 +787,7 @@ void Arguments() #Arguments : {}
void FunctionCallLookahead() #void : {}
{
- LOOKAHEAD(2) <IDENTIFIER> <COLON> <IDENTIFIER> <LPAREN>
+ LOOKAHEAD(<IDENTIFIER> <COLON> <IDENTIFIER> <LPAREN>, { isDeclaredNamespace(getToken(1), getToken(2)) }) <IDENTIFIER> <COLON> <IDENTIFIER> <LPAREN>
|
LOOKAHEAD(2) <IDENTIFIER> <LPAREN>
|
@@ -808,9 +796,9 @@ void FunctionCallLookahead() #void : {}
void FunctionCall() #void : {}
{
- LOOKAHEAD(2) NamespaceIdentifier() Arguments() #FunctionNode(2)
+ LOOKAHEAD(<IDENTIFIER> <COLON> <IDENTIFIER> <LPAREN>, { isDeclaredNamespace(getToken(1), getToken(2)) }) NamespaceIdentifier() Arguments() #FunctionNode(2)
|
- LOOKAHEAD(2) Identifier(true) Arguments() #FunctionNode(2)
+ LOOKAHEAD(<IDENTIFIER> <LPAREN>) Identifier(true) Arguments() #FunctionNode(2)
}
void Constructor() #ConstructorNode : {}