pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From the...@apache.org
Subject svn commit: r1041245 - in /pig/trunk: build.xml src/org/apache/pig/parser/QueryParser.g test/org/apache/pig/parser/TestQueryParser.java
Date Thu, 02 Dec 2010 01:29:17 GMT
Author: thejas
Date: Thu Dec  2 01:29:16 2010
New Revision: 1041245

URL: http://svn.apache.org/viewvc?rev=1041245&view=rev
Log:
PIG-1618: Switch to new parser generator technology - NewParser-5.patch

Modified:
    pig/trunk/build.xml
    pig/trunk/src/org/apache/pig/parser/QueryParser.g
    pig/trunk/test/org/apache/pig/parser/TestQueryParser.java

Modified: pig/trunk/build.xml
URL: http://svn.apache.org/viewvc/pig/trunk/build.xml?rev=1041245&r1=1041244&r2=1041245&view=diff
==============================================================================
--- pig/trunk/build.xml (original)
+++ pig/trunk/build.xml Thu Dec  2 01:29:16 2010
@@ -123,7 +123,7 @@
     <property name="rat.reporting.classname" value="rat.Report"/>
 
     <!-- javadoc properties  -->
-    <property name="javadoc.link.java" value="http://java.sun.com/j2se/1.5.0/docs/api/"
/>
+    <property name="javadoc.link.java" value="http://download.oracle.com/javase/1.5.0/docs/api/"
/>
 
     <!-- test patch properties -->
     <property name="scratch.dir" value="${user.home}/tmp"/>
@@ -300,7 +300,7 @@
         <javacc target="${src.gen.dot.parser.dir}/DOTParser.jj" outputdirectory="${src.gen.dot.parser.dir}"
javacchome="${javacc.home}" />
     </target>
 	
-	  <target name="gen" depends="genParser"
+	  <target name="gen" depends="genTreeParser"
 	    description="generates lexer and parser code from an ANTLR grammar">
 	    <!-- Move generated Java code to the correct package directory. -->
 	    <move todir="${src.gen.dir}${grammar.package.dir}">
@@ -330,17 +330,14 @@
 	    </java>
 	  </target>
 	
-<!--
-
 	  <target name="genTreeParser" depends="genParser"
 	    unless="treeGrammarProcessed"
 	    description="generates tree parser class from an ANTLR grammar">
 	    <java classname="org.antlr.Tool"
 	      classpathref="classpath" fork="true">
-	      <arg line="${tool.options} ${grammar.name}Tree.g"/>
+	      <arg line="-o ${src.gen.dir}/${grammar.package.dir} ${src.dir}/${grammar.package.dir}/DefaultDataTypeInserter.g"/>
 	    </java>
 	  </target>
--->	
 
 	  <target name="prepare">
 	    <uptodate property="lexerGrammarProcessed" srcfile="${grammar.src.dir}/${grammar.name}Lexer.g">

Modified: pig/trunk/src/org/apache/pig/parser/QueryParser.g
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/parser/QueryParser.g?rev=1041245&r1=1041244&r2=1041245&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/parser/QueryParser.g (original)
+++ pig/trunk/src/org/apache/pig/parser/QueryParser.g Thu Dec  2 01:29:16 2010
@@ -18,6 +18,10 @@
  
 /**
  * Parser file for Pig Parser
+ *
+ * NOTE: THIS FILE IS THE BASE FOR A FEW TREE PARSER FILES, such as DefaultDataTypeInserter.g,

+ *       SO IF YOU CHANGE THIS FILE, YOU WILL PROBABLY NEED TO MAKE CORRESPONDING CHANGES
TO 
+ *       THOSE FILES AS WELL.
  */
 
 parser grammar QueryParser;
@@ -32,6 +36,7 @@ tokens {
     QUERY;
     STATEMENT;
     FUNC;
+    FUNC_EVAL;
     CAST_EXPR;
     BIN_EXPR;
     TUPLE_VAL;
@@ -44,6 +49,9 @@ tokens {
     NESTED_PROJ;
     SPLIT_BRANCH;
     NESTED_PLAN;
+    MAP_TYPE;
+    TUPLE_TYPE;
+    BAG_TYPE;
 }
 
 @header {
@@ -176,7 +184,7 @@ load_clause : LOAD^ filename ( USING! fu
 filename : QUOTEDSTRING
 ;
 
-as_clause: AS! tuple_def
+as_clause: AS^ tuple_def
 ;
 
 tuple_def : tuple_def_full | tuple_def_simple
@@ -201,13 +209,15 @@ simple_type : INT | LONG | FLOAT | DOUBL
 ;
 
 tuple_type : TUPLE? tuple_def_full
-          -> tuple_def_full
+          -> ^( TUPLE_TYPE tuple_def_full )
 ;
 
-bag_type : BAG? LEFT_CURLY! tuple_def? RIGHT_CURLY!
+bag_type : BAG? LEFT_CURLY tuple_def? RIGHT_CURLY
+        -> ^( BAG_TYPE tuple_def? )
 ;
 
-map_type : MAP! LEFT_BRACKET! RIGHT_BRACKET!
+map_type : MAP LEFT_BRACKET RIGHT_BRACKET
+        -> MAP_TYPE
 ;
 
 func_clause : func_name LEFT_PAREN func_args? RIGHT_PAREN
@@ -267,20 +277,17 @@ and_cond : unary_cond ( AND^ unary_cond 
 ;
 
 unary_cond : LEFT_PAREN! cond RIGHT_PAREN!
-           |
-             expr FILTEROP^ expr
-           |
-             func_eval
-           |
-             null_check_cond
-           |
-             not_cond
+           | expr FILTEROP^ expr
+           | func_eval
+           | null_check_cond
+           | not_cond
 ;
 
 not_cond : NOT^ unary_cond
 ;
 
-func_eval: func_name LEFT_PAREN! real_arg_list? RIGHT_PAREN!
+func_eval : func_name LEFT_PAREN real_arg_list? RIGHT_PAREN
+          -> ^( FUNC_EVAL func_name real_arg_list? )
 ;
 
 real_arg_list : real_arg ( COMMA real_arg )*

Modified: pig/trunk/test/org/apache/pig/parser/TestQueryParser.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/parser/TestQueryParser.java?rev=1041245&r1=1041244&r2=1041245&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/parser/TestQueryParser.java (original)
+++ pig/trunk/test/org/apache/pig/parser/TestQueryParser.java Thu Dec  2 01:29:16 2010
@@ -43,7 +43,7 @@ public class TestQueryParser {
         Tree ast = (Tree)result.getTree();
 
         System.out.println( ast.toStringTree() );
-        printTree( (CommonTree)ast, 0 );
+        TreePrinter.printTree( (CommonTree)ast, 0 );
         Assert.assertEquals( 0, lexer.getNumberOfSyntaxErrors() );
         Assert.assertEquals( 0, parser.getNumberOfSyntaxErrors() );
     }
@@ -102,7 +102,7 @@ public class TestQueryParser {
         Tree ast = (Tree)result.getTree();
 
         System.out.println( ast.toStringTree() );
-        printTree( (CommonTree)ast, 0 );
+        TreePrinter.printTree( (CommonTree)ast, 0 );
         Assert.assertEquals( 0, lexer.getNumberOfSyntaxErrors() );
         Assert.assertEquals( 0, parser.getNumberOfSyntaxErrors() );
    
@@ -145,23 +145,9 @@ public class TestQueryParser {
         Tree ast = (Tree)result.getTree();
 
         System.out.println( ast.toStringTree() );
-        printTree( (CommonTree)ast, 0 );
+        TreePrinter.printTree( (CommonTree)ast, 0 );
         Assert.assertEquals( 0, lexer.getNumberOfSyntaxErrors() );
         return parser.getNumberOfSyntaxErrors();
     }
 
-    public static void printTree(CommonTree tree, int indent) {
-        if( tree != null ) {
-            StringBuilder sb = new StringBuilder();
-            for ( int i = 0; i < indent; i++ )
-                sb = sb.append( "   " );
-
-            System.out.println( sb + tree.getText() );
-
-            for ( int i = 0; i < tree.getChildCount(); i++ ) {
-                printTree( (CommonTree)tree.getChild( i ), indent + 1 );
-            }
-        }
-    }
-
 }



Mime
View raw message