svn commit: r981612 - /ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r981612 - /ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj

doogie-3
Author: doogie
Date: Mon Aug  2 17:41:34 2010
New Revision: 981612

URL: http://svn.apache.org/viewvc?rev=981612&view=rev
Log:
REFACTOR: Abstract out FieldAll so it can be called externally.

Modified:
    ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj

Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj?rev=981612&r1=981611&r2=981612&view=diff
==============================================================================
--- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj (original)
+++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj Mon Aug  2 17:41:34 2010
@@ -486,25 +486,32 @@ private Boolean Joiner(): {
     | <JOIN> { return Boolean.FALSE; }
 }
 
+private FieldAll FieldAll(): {
+    String n, exc;
+    Set<String> excludeList = FastSet.newInstance();
+} {
+    n=NamePart() <PERIOD> <STAR> (
+        <EXCLUDE> <OPEN_PAREN>
+        exc=NamePart() { excludeList.add(exc); }
+        ( <COMMA> exc=NamePart() { excludeList.add(exc); } )*
+        <CLOSE_PAREN>
+    )?
+    { return new FieldAll(n, excludeList); }
+}
+
 private void FieldDef(Map<String, FieldDef> fieldDefs, List<FieldAll> fieldAlls, Set<String> fieldAllAliases): {
     StaticValue v;
-    String n, fieldAlias = null, fieldName, exc;
+    String n, fieldAlias = null, fieldName;
     FieldDef def;
-    Set<String> excludeList = FastSet.newInstance();
+    FieldAll fieldAll;
 } {
     (
-          n=NamePart() (
-              <PERIOD> (
-                <STAR> (
-                    { if (fieldAllAliases.contains(n)) throw new ParseException("Duplicate aliasAll(" + n + ")"); }
-                    <EXCLUDE> <OPEN_PAREN>
-                    exc=NamePart() { excludeList.add(exc); }
-                    ( <COMMA> exc=NamePart() { excludeList.add(exc); } )*
-                    <CLOSE_PAREN>
-                )?
-                { fieldAlls.add(new FieldAll(n, excludeList)); return; }
-              | fieldName=NamePart() ( <AS> fieldAlias=NamePart() )? { def = new FieldDef(new FieldValue(n, fieldName), fieldAlias); }
-              )
+          LOOKAHEAD(3) fieldAll=FieldAll() {
+            if (fieldAllAliases.contains(fieldAll.getAlias())) throw new ParseException("Duplicate aliasAll(" + fieldAll.getAlias() + ")");
+            fieldAlls.add(fieldAll); return;
+          }
+        | n=NamePart() (
+              <PERIOD> fieldName=NamePart() ( <AS> fieldAlias=NamePart() )? { def = new FieldDef(new FieldValue(n, fieldName), fieldAlias); }
             | v=FunctionCallRest(n) ( <AS> fieldAlias=NamePart() )? { def = new FieldDef(v, fieldAlias); }
             | ( <AS> fieldAlias=NamePart() )? { def = new FieldDef(new FieldValue(null, n), fieldAlias); }
           )