From: <ibr...@us...> - 2010-05-19 21:30:51
|
Revision: 3527 http://tora.svn.sourceforge.net/tora/?rev=3527&view=rev Author: ibre5041 Date: 2010-05-19 21:30:44 +0000 (Wed, 19 May 2010) Log Message: ----------- This sandbox directory is just a playground for SQL grammar parser tests. This code is not ready to be used with tora sources. Added Paths: ----------- branches/tora-trotl/sandbox/ branches/tora-trotl/sandbox/Makefile branches/tora-trotl/sandbox/SELECT_SIMPLE.g branches/tora-trotl/sandbox/SELECT_SIMPLE.tokens branches/tora-trotl/sandbox/input branches/tora-trotl/sandbox/input.model.1.test branches/tora-trotl/sandbox/main.c Added: branches/tora-trotl/sandbox/Makefile =================================================================== --- branches/tora-trotl/sandbox/Makefile (rev 0) +++ branches/tora-trotl/sandbox/Makefile 2010-05-19 21:30:44 UTC (rev 3527) @@ -0,0 +1,28 @@ +.PRECIOUS=.o + +ANTLRGRAMMARS ?= $(wildcard *.g) + +all: a.out + +a.out: main.c SELECT_SIMPLE.tokens + gcc -ggdb -O0 -fno-inline -I/home/ibrezina/devel/libantlr3c-3.2/include/ -I/home/ibrezina/devel/libantlr3c-3.2/ *.c /home/ibrezina/devel/libantlr3c-3.2/.libs/libantlr3c.a + +clean: + rm *.o a.out + +%.u: %.g + @echo "Bulding dependencies for "$< + java -jar /home/ibrezina/workspace/SQL_Grammar/antlr-3.2.jar -depend $< > $@ + @grep ":" $@ |awk 'BEGIN {printf "ANTLRGENLIST := " }{printf " " $$1}END {print ""}' >> $@.tmp + @cat $@.tmp >> $@ + $(RM) $@.tmp + + +%.tokens %.c %Lexer.c %Parser.c %Lexer.h %Parser.h %.h: %.g + java -jar /home/ibrezina/workspace/SQL_Grammar/antlr-3.2.jar $(GRAMMAROPTIONS) $< + +#ifneq ($(MAKECMDGOALS),clean) +ifneq ($(strip $(ANTLRGRAMMARS)),) +-include $(ANTLRGRAMMARS:.g=.u) +endif +#endif Added: branches/tora-trotl/sandbox/SELECT_SIMPLE.g =================================================================== --- branches/tora-trotl/sandbox/SELECT_SIMPLE.g (rev 0) +++ branches/tora-trotl/sandbox/SELECT_SIMPLE.g 2010-05-19 21:30:44 UTC (rev 3527) @@ -0,0 +1,1148 @@ +/******************************************************************************* + +DESCRIPTION: + Grammar for Oracle's SELECT statement for ANTLR v3, target any language +AUTHOR: + ibr...@ib... + +DATE: + MAY 2010 +BASED ON: + PLSQL3.g Andrey Kharitonkin (th...@gm...) + PLSQLGrammar.g for ANTLR v2 + Qazi Firdous Ahmed (qaz...@in...) + Krupa Benhur (kru...@in...) + Manojaba Banerjee (man...@in...) + Infosys Technologies Ltd., Bangalore, India + Sept 18, 2002 + This grammar is for PL/SQL. +COMMENT: + This grammar file is based on freely downloadable + file PLSQL3.g. I extracted only those rules that + are mandatory for SELECT statement. Column list was + partialy rewritten, support for analytic queries add, + list of reserved words and keywords added. +ORIGINAL COMMENT: + The grammar has been mostly re-written for ANTLR v3, + using Oracle 10g Release 2 documentation and ANTLR book. + New SQL and PL/SQL expression rules, SQL statments + SELECT, INSERT, UPDATE, DELETE are fully supported. + Generated parser can parse most of valid PL/SQL and + it was tested with over 10 Mb of test source code. + Let me know if something cannot be parsed by this grammar. +KNOWN ISSUES: + "FOR UPDATE" clause is not yet supported and support for + some exceptional constructs like "PIVOT XML" is still + missing. + +*******************************************************************************/ + +grammar SELECT_SIMPLE; + +options { +// language=Java; + language=C; +// k=4; + backtrack=true; + memoize=true; + output=AST; +// ASTLabelType=CommonTree; +} + +tokens { + T_RESERVED = 'reserved'; + T_WITH = 'with'; + T_SELECT = 't_select'; + T_COLUMN_LIST = 'column_list'; + T_SELECT_COLUMN = 'select_column'; + T_FROM = 'from'; + T_SELECTED_TABLE = 'selected_table'; + T_WHERE = 'where'; + T_HIERARCHICAL = 'hierarchical'; + T_GROUP_BY = 'group_by'; + T_HAVING = 'having'; + T_MODEL = 't_model'; + T_SET_OP = 'set_op'; + T_ORDER_BY_CLAUSE='t_order_by'; +} + +// @members { +// private boolean is_sql = false; +// } + +// @header { +// package org.tora; +// } + +// @lexer::header { +// package org.tora; +// } + +//@parser::includes { +// #include "expr.h" +//} + +@members { +// ExprFactory *exprFactory; + unsigned _class; +} + +start_rule + : select_expression + ; + +select_expression + : + subquery_factoring_clause? + /*'SELECT'*/k_select /*( hint )?*/ ( /*'DISTINCT'*/k_distinct | /*'UNIQUE'*/k_union | /*'ALL'*/k_all )? select_list + /*'FROM'*/k_from + ( table_reference_list | join_clause | LPAREN join_clause RPAREN ) + ( where_clause )? + ( hierarchical_query_clause )? + ( group_by_clause )? + ( /*'HAVING'*/k_having sql_condition )? + ( model_clause )? + ( ( /*'UNION'*/k_union ( /*'ALL'*/k_all )? + | /*'INTERSECT'*/k_intersect + | /*'MINUS'*/k_minus + ) + ( select_expression | subquery ) + )? + ( order_by_clause )? + -> ^('t_select' /*'SELECT'*/k_select + subquery_factoring_clause? + select_list + ^('from' k_from table_reference_list? join_clause?) + where_clause? + hierarchical_query_clause? //TODO TEST ME + model_clause? + order_by_clause? + ) + ; + +subquery_factoring_clause + : /*'WITH'*/k_with sql_identifier /*'AS'*/k_as subquery (COMMA sql_identifier /*'AS'*/k_as subquery)* + //->^('with' 'WITH' (sql_identifier 'AS' subquery)+ ) + //TODO comma is missing here + ; + +/* ================================================================================ + Query column list specs (ie. everything between 'SELECT' ... 'FROM' + ================================================================================ */ +select_list + : displayed_column ( COMMA displayed_column )* + -> ^('column_list' displayed_column*) + ; + +displayed_column + : ( + asterisk1=ASTERISK + | schema=sql_identifier DOT asterisk2=ASTERISK + | sql_expression + ) + (alias|alias_name=sql_identifier)? + -> ^('select_column' $asterisk1? $schema? DOT? $asterisk2? sql_expression? alias? $alias_name? ) + ; +sql_expression + : expr_add + ; +expr_add + : expr_mul ( ( PLUS | MINUS | DOUBLEVERTBAR ) expr_mul )* + ; +expr_mul + : expr_sign ( ( ASTERISK | DIVIDE ) expr_sign )* + ; +expr_sign + : ( PLUS | MINUS )? expr_pow + ; +expr_pow + : expr_expr ( EXPONENT expr_expr )* + ; +expr_expr + : ( expr_paren ) => expr_paren + | ( function_expression ) => function_expression +// | ( compound_expression ) => compound_expression + | ( case_expression ) => case_expression +// | ( cursor_expression ) => cursor_expression + | ( simple_expression ) => simple_expression +// | ( select_expression ) => select_expression replaced with subquery +// | ( special_expression ) => special_expression +// | datetime_expression +// | interval_expression +// | object_access_expression +// | scalar_subquery_expression +// | model_expression +// | type_constructor_expression +// | variable_expression +// : 'NULL' | NUMBER | QUOTED_STRING | IDENTIFIER + | ( subquery ) => subquery + ; +expr_paren + : LPAREN nested_expression RPAREN + ; +nested_expression + : sql_expression + ; +function_expression + : (function_name|analytic_function_name) LPAREN call_parameters RPAREN + ; +call_parameters + : ASTERISK + | call_parameter ( COMMA call_parameter )* + ; +call_parameter + : ( parameter_name ARROW )? nested_expression + ; +parameter_name + : identifier + ; +case_expression + : /*'CASE'*/k_case ( simple_case_expression | searched_case_expression ) ( else_case_expression )? /*'END'*/k_end + ; +simple_case_expression + : nested_expression ( /*'WHEN'*/k_when nested_expression /*'THEN'*/k_then nested_expression )+ + ; +searched_case_expression + : ( /*'WHEN'*/k_when sql_condition /*'THEN'*/k_then nested_expression )+ + ; +else_case_expression + : /*'ELSE'*/k_else nested_expression + ; + +simple_expression + : boolean_literal + | /*'SQL'*/k_sql ( FOUND_ATTR | NOTFOUND_ATTR | ISOPEN_ATTR | ROWCOUNT_ATTR | BULK_ROWCOUNT_ATTR ) + | ( cell_assignment ) => cell_assignment // this is used only in model_clause s[PROD='A'] = S['B'] + 1 + | ( column_spec ) => column_spec + | QUOTED_STRING + | NUMBER +// | sequence_name DOT ( 'CURRVAL' | 'NEXTVAL' ) +// | 'ROWID' +// | 'ROWNUM' + | /*'NULL'*/k_null + ; + +subquery + : LPAREN select_expression RPAREN + ; + +boolean_literal + : /*'TRUE'*/k_true | /*'FALSE'*/k_false + ; +alias + : ( /*'AS'*/k_as ) sql_identifier? + ; + +column_spec + : sql_identifier DOT sql_identifier DOT sql_identifier + | sql_identifier DOT sql_identifier + | sql_identifier + ; + +function_name + : sql_identifier DOT sql_identifier DOT sql_identifier + | sql_identifier DOT sql_identifier + | sql_identifier + ; + +identifier + : ID + | DOUBLEQUOTED_STRING + ; + +sql_identifier + : identifier + | keyword + | 'ROWID' + | 'ROWNUM' + ; + +/* ================================================================================ + Query tables specs (ie. everything between 'FROM' ... 'WHERE' + ================================================================================ */ +table_reference_list + : selected_table ( COMMA selected_table )* + ; +join_clause + : table_name ( inner_cross_join_clause | outer_join_clause )+ + ; +inner_cross_join_clause + : ( 'INNER' )? 'JOIN' table_name ( 'ON' sql_condition | 'USING' LPAREN column_specs RPAREN ) + | ( 'CROSS' | 'NATURAL' ( 'INNER' ) ) 'JOIN' table_name + ; +outer_join_clause + : ( query_partition_clause )? + ( outer_join_type 'JOIN' + | 'NATURAL' ( outer_join_type )? 'JOIN' + ) + table_name ( query_partition_clause )? + ( 'ON' sql_condition | 'USING' LPAREN column_specs RPAREN )? + ; +column_specs + : column_spec ( COMMA column_spec )* + ; +query_partition_clause + : 'PARTITION' 'BY' expression_list + ; +outer_join_type + : ( 'FULL' | 'LEFT' | 'RIGHT' ) ( 'OUTER' )? + ; +outer_join_sign + : LPAREN PLUS RPAREN + ; +selected_table + : ( table_spec | ( 'TABLE' | 'THE' )? subquery ) ( alias )? + ; + +table_spec + : ( schema_name DOT )? table_name ( AT_SIGN link_name )? + -> ^('selected_table' schema_name? DOT? table_name AT_SIGN? link_name?) + ; + +schema_name + : sql_identifier + ; +table_name + : sql_identifier + ; +table_alias + : ( schema_name DOT )? table_name ( AT_SIGN link_name )? ( alias )? + ; +link_name + : sql_identifier + ; + +/* ================================================================================ + where clause + ================================================================================ */ +where_clause + : /*'WHERE'*/k_where sql_condition + -> ^( 'where' k_where sql_condition) + ; +/* ================================================================================ + hierarchical query clause + ================================================================================ */ +hierarchical_query_clause + : ( 'START' 'WITH' start=sql_condition )? 'CONNECT' 'BY' ( 'NOCYCLE' )? connect=sql_condition + -> ^('hierarchical' 'START'? 'WITH'? $start? 'CONNECT' 'BY' 'NOCYCLE'? $connect) + ; + +/* ================================================================================ + group by clause + ================================================================================ */ +group_by_clause + : 'GROUP' 'BY' group_by_exprs + -> ^('group_by' 'GROUP' 'BY' group_by_exprs) + ; +group_by_exprs + : group_by_expr ( COMMA group_by_expr )* + ; +group_by_expr + : rollup_cube_clause + | grouping_sets_clause + | grouping_expression_list + ; +rollup_cube_clause + : ( 'ROLLUP' | 'CUBE' ) LPAREN grouping_expression_list RPAREN + ; +grouping_sets_clause + : 'GROUPING' 'SETS' LPAREN grouping_expression_list RPAREN + ; +grouping_sets_exprs + : grouping_sets_expr ( COMMA grouping_sets_expr )* + ; +grouping_sets_expr + : rollup_cube_clause | grouping_expression_list + ; +sql_condition + : condition_or + ; +condition_or + : condition_and ( 'OR' condition_and )* + ; +condition_and + : condition_not ( 'AND' condition_not )* + ; +condition_not + : 'NOT' condition_expr + | condition_expr + ; +condition_expr + : condition_exists + | condition_is + | condition_comparison + | condition_group_comparison + | condition_in + | condition_is_a_set + | condition_is_any + | condition_is_empty + | condition_is_of_type + | condition_is_present + | condition_like + | condition_memeber + | condition_between + | condition_regexp_like + | condition_submultiset + | condition_equals_path + | condition_under_path + | condition_paren + ; + +condition_exists + : 'EXISTS' subquery + ; +condition_is + : sql_expression 'IS' ( 'NOT' )? ( 'NAN' | 'INFINITE' | 'NULL' ) + ; +condition_comparison + : LPAREN sql_expressions RPAREN ( outer_join_sign )? ( EQ | NOT_EQ ) subquery ( outer_join_sign )? + | ( 'PRIOR' )? sql_expression ( outer_join_sign )? ( EQ | NOT_EQ | GTH | GEQ | LTH | LEQ ) ( 'PRIOR' )? ( sql_expression | LPAREN select_expression RPAREN ) ( outer_join_sign )? + ; +condition_group_comparison + : LPAREN sql_expressions RPAREN ( EQ | NOT_EQ ) ( 'ANY' | 'SOME' | 'ALL' ) LPAREN ( grouping_expression_list | select_expression ) RPAREN + | sql_expression ( EQ | NOT_EQ | GTH | GEQ | LTH | LEQ ) ( 'ANY' | 'SOME' | 'ALL' ) LPAREN ( sql_expressions | select_expression ) RPAREN + ; +condition_in + : LPAREN sql_expressions RPAREN ( 'NOT' )? 'IN' LPAREN ( grouping_expression_list | select_expression ) RPAREN + | sql_expression ( 'NOT' )? 'IN' LPAREN ( expression_list | select_expression ) RPAREN + ; +condition_is_a_set + : nested_table_column_name 'IS' ( 'NOT' )? /*'A'*/k_a 'SET' + ; +condition_is_any + : ( column_name 'IS' )? 'ANY' + ; +condition_is_empty + : nested_table_column_name 'IS' ( 'NOT' )? 'EMPTY' + ; +condition_is_of_type + : sql_expression 'IS' ('NOT')? 'OF' ( 'TYPE' )? LPAREN type_name RPAREN + ; +condition_is_of_type_names + : condition_is_of_type_name ( COMMA condition_is_of_type_name )* + ; +condition_is_of_type_name + : ( 'ONLY' )? type_name + ; +condition_is_present + : cell_reference 'IS' 'PRESENT' + ; +condition_like + : sql_expression ( 'NOT' )? ( 'LIKE' | 'LIKEC' | 'LIKE2' | 'LIKE4' ) sql_expression ( 'ESCAPE' sql_expression )? + ; +condition_memeber + : sql_expression ( 'NOT' )? 'MEMBER' ( 'OF' )? nested_table_column_name + ; +condition_between + : sql_expression ( 'NOT' )? 'BETWEEN' sql_expression 'AND' sql_expression + ; +condition_regexp_like + : 'REGEXP_LIKE' LPAREN call_parameters RPAREN + ; +condition_submultiset + : nested_table_column_name ( 'NOT' )? 'SUBMULTISET' ( 'OF' )? nested_table_column_name + ; +condition_equals_path + : 'EQUALS_PATH' LPAREN column_name COMMA path_string ( COMMA correlation_integer )? RPAREN + ; +condition_under_path + : 'UNDER_PATH' LPAREN column_name ( COMMA levels )? COMMA path_string ( COMMA correlation_integer )? RPAREN + ; +levels + : integer + ; +correlation_integer + : integer + ; +path_string + : QUOTED_STRING + ; +type_name + : identifier ( DOT identifier )* + ; +integer + : NUMBER + ; +column_name + : sql_identifier + ; +nested_table + : sql_identifier + ; +nested_table_column_name + : ( schema_name DOT )? (table_name DOT)? (nested_table DOT)? column_name + ; +sql_expressions + : sql_expression ( COMMA sql_expression )* + ; +grouping_expression_list + : expression_list ( COMMA expression_list )* + ; +expression_list + : LPAREN sql_expressions RPAREN + | sql_expressions + ; +cell_reference + : sql_identifier + ; + +condition_paren + : LPAREN sql_condition RPAREN + ; + +/* ================================================================================ + MODEL clause + ================================================================================ */ +model_clause + : 'MODEL' main_model + ( cell_reference_options )? + ( return_rows_clause )? + ( reference_model )* //main_model + -> ^( 't_model' 'MODEL' main_model cell_reference_options? return_rows_clause? reference_model* ) + ; +cell_reference_options + : ( ( 'IGNORE' | 'KEEP' ) 'NAV' )? + ( 'UNIQUE' ( 'DIMENSION' | 'SINGLE' 'REFERENCE' ) )? + ; +return_rows_clause + : 'RETURN' ( 'UPDATED' | 'ALL' ) 'ROWS' + ; +reference_model + : 'REFERENCE' reference_model_name 'ON' LPAREN subquery RPAREN + model_column_clauses ( cell_reference_options ) + ; +reference_model_name + : identifier + ; +main_model + : ( 'MAIN' main_model_name )? model_column_clauses + ( cell_reference_options ) model_rules_clause + ; +main_model_name + : identifier + ; +model_column_clauses + : ( query_partition_clause ( column_spec )? )? + 'DIMENSION' 'BY' LPAREN model_columns RPAREN + 'MEASURES' LPAREN model_columns RPAREN + ; +model_columns + : model_column ( COMMA model_column )* + ; +model_column + : sql_expression ( ( /*'AS'*/k_as )? column_spec )? + ; +model_rules_clause + : ( 'RULES' ( 'UPDATE' | 'UPSERT' ( 'ALL' )? )? ( ( 'AUTOMATIC' | 'SEQUENTIAL' ) 'ORDER' )? )? + ( 'ITERATE' LPAREN NUMBER RPAREN ( 'UNTIL' LPAREN sql_condition RPAREN )? )? + LPAREN model_rules_exprs RPAREN + ; +model_rules_exprs + : model_rules_expr ( COMMA model_rules_expr )* + ; +model_rules_expr + : ( 'UPDATE' | 'UPSERT' ( 'ALL' )? )? cell_assignment ( order_by_clause )? EQ sql_expression + ; +cell_assignment + : measure_column LBRACK ( multi_column_for_loop | cell_assignment_exprs ) RBRACK + ; +cell_assignment_exprs + : cell_assignment_expr ( COMMA cell_assignment_expr )* + ; +cell_assignment_expr + : sql_condition | sql_expression | single_column_for_loop + ; +measure_column + : column_name + ; +single_column_for_loop + : 'FOR' column_name + ( 'IN' LPAREN ( literals | subquery ) RPAREN + | ( 'LIKE' pattern )? /*'FROM'*/k_from literal 'TO' literal ( 'INCREMENT' | 'DECREMENT' ) literal + ) + ; +pattern + : QUOTED_STRING + ; +literal + : ( PLUS | MINUS )? NUMBER + | QUOTED_STRING + ; +literals + : literal ( COMMA literal )* + ; +multi_column_for_loop + : 'FOR' LPAREN column_specs RPAREN 'IN' LPAREN ( bracket_literals_list | subquery ) RPAREN + ; +bracket_literals + : LPAREN literals RPAREN + ; +bracket_literals_list + : bracket_literals ( COMMA bracket_literals )* + ; +/* ================================================================================ + ORDER BY clause + ================================================================================ */ +order_by_clause + : 'ORDER' 'SIBLINGS'? 'BY' + ( sql_expression 'ASC'? 'DESC'? ('NULLS' 'FIRST')? ('NULLS' 'LAST')? ) + ( COMMA sql_expression 'ASC'? 'DESC'? ('NULLS' 'FIRST')? ('NULLS' 'LAST')? )* +// order_by_exprs + -> ^('t_order_by' 'ORDER' 'SIBLINGS'? 'BY' (sql_expression 'ASC'? 'DESC'?) *) + ; + +/* ================================================================================ + Analytic query part + ================================================================================ */ +analytic_function_name + : + | 'AVG' | 'CORR' | 'COVAR_POP' | 'COVAR_SAMP' | 'COUNT' | 'CUME_DIST' | 'DENSE_RANK' + | 'FIRST' | 'FIRST_VALUE' | 'LAG' | 'LAST' | 'LAST_VALUE' | 'LEAD' | 'MAX' | 'MIN' + | 'NTILE' | 'PERCENT_RANK' | 'PERCENTILE_CONT' | 'PERCENTILE_DISC' | 'RANK' | 'RATIO_TO_REPORT' + | 'REGR_SLOPE' | 'REGR_INTERCEPT' | 'REGR_COUNT' | 'REGR_R2' | 'REGR_AVGX' | 'REGR_AVGY' + | 'REGR_SXX' | 'REGR_SYY' | 'REGR_SXY' | 'ROW_NUMBER' | 'STDDEV' | 'STDDEV_POP' + | 'STDDEV_SAMP' | 'SUM' | 'VAR_POP' | 'VAR_SAMP' | 'VARIANCE' ; + +analytic_function_call + : analytic_function_name + LPAREN ('DISTINCT' | 'ALL')? sql_expression? (COMMA sql_expression)* RPAREN + ; + +analytic_function + : function_expression 'OVER' LPAREN analytic_clause RPAREN + ; + +analytic_clause + : query_partition_clause? (order_by_clause windowing_clause?)? + ; + +windowing_clause_part + : + ('UNBOUNDED' 'PRECEEDING')|('CURRENT' 'ROW')|(sql_expression 'RECEEDING') + ; + +windowing_clause + : ('ROWS' | 'RANGE') + ( windowing_clause_part + | + ( 'BETWEEN' windowing_clause_part 'AND' windowing_clause_part) + ) + ; + +/* ================================================================================ + FOR UPDATE CLAUSE + ================================================================================ */ +for_update + : k_for k_update + ( k_of ( (schema_name DOT)? (table_name DOT)? column_name )? + (COMMA (schema_name DOT)? (table_name DOT)? column_name )* + )? + ; + +/* ================================================================================ + Oracle reserved words + cannot by used for name database objects such as columns, tables, or indexes. + ================================================================================ */ +k_access : r='ACCESS' { $r->setType($r, T_RESERVED); } ; +k_add : r='ADD' { $r->setType($r, T_RESERVED); } ; +k_all : r='ALL' { $r->setType($r, T_RESERVED); } ; +k_alter : r='ALTER' { $r->setType($r, T_RESERVED); } ; +k_and : r='AND' { $r->setType($r, T_RESERVED); } ; +k_any : r='ANY' { $r->setType($r, T_RESERVED); } ; +k_arraylen : r='ARRAYLEN' { $r->setType($r, T_RESERVED); } ; +k_as : r='AS' { $r->setType($r, T_RESERVED); } ; +k_asc : r='ASC' { $r->setType($r, T_RESERVED); } ; +k_audit : r='AUDIT' { $r->setType($r, T_RESERVED); } ; +k_between : r='BETWEEN' { $r->setType($r, T_RESERVED); } ; +k_by : r='BY' { $r->setType($r, T_RESERVED); } ; +k_case : r='CASE' { $r->setType($r, T_RESERVED); } ; //PL/SQL +k_char : r='CHAR' { $r->setType($r, T_RESERVED); } ; +k_check : r='CHECK' { $r->setType($r, T_RESERVED); } ; +k_cluster : r='CLUSTER' { $r->setType($r, T_RESERVED); } ; +k_column : r='COLUMN' { $r->setType($r, T_RESERVED); } ; +k_comment : r='COMMENT' { $r->setType($r, T_RESERVED); } ; +k_compress : r='COMPRESS' { $r->setType($r, T_RESERVED); } ; +k_connect : r='CONNECT' { $r->setType($r, T_RESERVED); } ; +k_create : r='CREATE' { $r->setType($r, T_RESERVED); } ; +k_current : r='CURRENT' { $r->setType($r, T_RESERVED); } ; +k_date : r='DATE' { $r->setType($r, T_RESERVED); } ; +k_decimal : r='DECIMAL' { $r->setType($r, T_RESERVED); } ; +k_default : r='DEFAULT' { $r->setType($r, T_RESERVED); } ; +k_delete : r='DELETE' { $r->setType($r, T_RESERVED); } ; +k_desc : r='DESC' { $r->setType($r, T_RESERVED); } ; +k_distinct : r='DISTINCT' { $r->setType($r, T_RESERVED); } ; +k_drop : r='DROP' { $r->setType($r, T_RESERVED); } ; +k_else : r='ELSE' { $r->setType($r, T_RESERVED); } ; +k_exclusive : r='EXCLUSIVE' { $r->setType($r, T_RESERVED); } ; +k_exists : r='EXISTS' { $r->setType($r, T_RESERVED); } ; +k_false : r='FALSE' { $r->setType($r, T_RESERVED); } ; //PL/SQL +k_file : r='FILE' { $r->setType($r, T_RESERVED); } ; +k_float : r='FLOAT' { $r->setType($r, T_RESERVED); } ; +k_for : r='FOR' { $r->setType($r, T_RESERVED); } ; +k_from : r='FROM' { $r->setType($r, T_RESERVED); } ; +k_grant : r='GRANT' { $r->setType($r, T_RESERVED); } ; +k_group : r='GROUP' { $r->setType($r, T_RESERVED); } ; +k_having : r='HAVING' { $r->setType($r, T_RESERVED); } ; +k_identified : r='IDENTIFIED' { $r->setType($r, T_RESERVED); } ; +k_immediate : r='IMMEDIATE' { $r->setType($r, T_RESERVED); } ; +k_in : r='IN' { $r->setType($r, T_RESERVED); } ; +k_increment : r='INCREMENT' { $r->setType($r, T_RESERVED); } ; +k_index : r='INDEX' { $r->setType($r, T_RESERVED); } ; +k_initial : r='INITIAL' { $r->setType($r, T_RESERVED); } ; +k_insert : r='INSERT' { $r->setType($r, T_RESERVED); } ; +k_integer : r='INTEGER' { $r->setType($r, T_RESERVED); } ; +k_intersect : r='INTERSECT' { $r->setType($r, T_RESERVED); } ; +k_into : r='INTO' { $r->setType($r, T_RESERVED); } ; +k_is : r='IS' { $r->setType($r, T_RESERVED); } ; +k_level : r='LEVEL' { $r->setType($r, T_RESERVED); } ; +k_like : r='LIKE' { $r->setType($r, T_RESERVED); } ; +k_lock : r='LOCK' { $r->setType($r, T_RESERVED); } ; +k_long : r='LONG' { $r->setType($r, T_RESERVED); } ; +k_maxextents : r='MAXEXTENTS' { $r->setType($r, T_RESERVED); } ; +k_minus : r='MINUS' { $r->setType($r, T_RESERVED); } ; +k_mode : r='MODE' { $r->setType($r, T_RESERVED); } ; +k_modify : r='MODIFY' { $r->setType($r, T_RESERVED); } ; +k_noaudit : r='NOAUDIT' { $r->setType($r, T_RESERVED); } ; +k_nocompress : r='NOCOMPRESS' { $r->setType($r, T_RESERVED); } ; +k_not : r='NOT' { $r->setType($r, T_RESERVED); } ; +k_notfound : r='NOTFOUND' { $r->setType($r, T_RESERVED); } ; +k_nowait : r='NOWAIT' { $r->setType($r, T_RESERVED); } ; +k_null : r='NULL' { $r->setType($r, T_RESERVED); } ; +k_number : r='NUMBER' { $r->setType($r, T_RESERVED); } ; +k_of : r='OF' { $r->setType($r, T_RESERVED); } ; +k_offline : r='OFFLINE' { $r->setType($r, T_RESERVED); } ; +k_on : r='ON' { $r->setType($r, T_RESERVED); } ; +k_online : r='ONLINE' { $r->setType($r, T_RESERVED); } ; +k_option : r='OPTION' { $r->setType($r, T_RESERVED); } ; +k_or : r='OR' { $r->setType($r, T_RESERVED); } ; +k_order : r='ORDER' { $r->setType($r, T_RESERVED); } ; +k_pctfree : r='PCTFREE' { $r->setType($r, T_RESERVED); } ; +k_prior : r='PRIOR' { $r->setType($r, T_RESERVED); } ; +k_privileges : r='PRIVILEGES' { $r->setType($r, T_RESERVED); } ; +k_public : r='PUBLIC' { $r->setType($r, T_RESERVED); } ; +k_raw : r='RAW' { $r->setType($r, T_RESERVED); } ; +k_rename : r='RENAME' { $r->setType($r, T_RESERVED); } ; +k_resource : r='RESOURCE' { $r->setType($r, T_RESERVED); } ; +k_revoke : r='REVOKE' { $r->setType($r, T_RESERVED); } ; +k_row : r='ROW' { $r->setType($r, T_RESERVED); } ; +k_rowid : r='ROWID' { $r->setType($r, T_RESERVED); } ; +k_rowlabel : r='ROWLABEL' { $r->setType($r, T_RESERVED); } ; +k_rownum : r='ROWNUM' { $r->setType($r, T_RESERVED); } ; +k_rows : r='ROWS' { $r->setType($r, T_RESERVED); } ; +k_select : r='SELECT' { $r->setType($r, T_RESERVED); } ; +k_session : r='SESSION' { $r->setType($r, T_RESERVED); } ; +k_set : r='SET' { $r->setType($r, T_RESERVED); } ; +k_share : r='SHARE' { $r->setType($r, T_RESERVED); } ; +k_size : r='SIZE' { $r->setType($r, T_RESERVED); } ; +k_smallint : r='SMALLINT' { $r->setType($r, T_RESERVED); } ; +k_sqlbuf : r='SQLBUF' { $r->setType($r, T_RESERVED); } ; +k_start : r='START' { $r->setType($r, T_RESERVED); } ; +k_successful : r='SUCCESSFUL' { $r->setType($r, T_RESERVED); } ; +k_synonym : r='SYNONYM' { $r->setType($r, T_RESERVED); } ; +k_sysdate : r='SYSDATE' { $r->setType($r, T_RESERVED); } ; +k_table : r='TABLE' { $r->setType($r, T_RESERVED); } ; +k_then : r='THEN' { $r->setType($r, T_RESERVED); } ; +k_to : r='TO' { $r->setType($r, T_RESERVED); } ; +k_trigger : r='TRIGGER' { $r->setType($r, T_RESERVED); } ; +k_true : r='TRUE' { $r->setType($r, T_RESERVED); } ; // PL/SQL +k_uid : r='UID' { $r->setType($r, T_RESERVED); } ; +k_union : r='UNION' { $r->setType($r, T_RESERVED); } ; +k_unique : r='UNIQUE' { $r->setType($r, T_RESERVED); } ; +k_update : r='UPDATE' { $r->setType($r, T_RESERVED); } ; +k_user : r='USER' { $r->setType($r, T_RESERVED); } ; +k_validate : r='VALIDATE' { $r->setType($r, T_RESERVED); } ; +k_values : r='VALUES' { $r->setType($r, T_RESERVED); } ; +k_varchar : r='VARCHAR' { $r->setType($r, T_RESERVED); } ; +k_varchar2 : r='VARCHAR2' { $r->setType($r, T_RESERVED); } ; +k_view : r='VIEW' { $r->setType($r, T_RESERVED); } ; +k_whenever : r='WHENEVER' { $r->setType($r, T_RESERVED); } ; +k_where : r='WHERE' { $r->setType($r, T_RESERVED); } ; +k_with : r='WITH' { $r->setType($r, T_RESERVED); } ; + +reserved_word options { backtrack=false; } + : r=( 'ACCESS' | 'ADD' | 'ALL' | 'ALTER' | 'AND' | 'ANY' | 'ARRAYLEN' | 'AS' | 'ASC' | 'AUDIT' + | 'BETWEEN' | 'BY' + | 'CHAR' | 'CHECK' | 'CLUSTER' | 'COLUMN' | 'COMMENT' | 'COMPRESS' | 'CONNECT' | 'CREATE' | 'CURRENT' + | 'DATE' | 'DECIMAL' | 'DEFAULT' | 'DELETE' | 'DESC' | 'DISTINCT' | 'DROP' + | 'ELSE' | 'EXCLUSIVE' | 'EXISTS' + | 'FILE' | 'FLOAT' | 'FOR' | 'FROM' + | 'GRANT' | 'GROUP' + | 'HAVING' + | 'IDENTIFIED' | 'IMMEDIATE' | 'IN' | 'INCREMENT' | 'INDEX' | 'INITIAL' | 'INSERT' | 'INTEGER' + | 'INTERSECT' | 'INTO' | 'IS' + | 'LEVEL' | 'LIKE' | 'LOCK' | 'LONG' + | 'MAXEXTENTS' | 'MINUS' | 'MODE' | 'MODIFY' + | 'NOAUDIT' | 'NOCOMPRESS' | 'NOT' | 'NOTFOUND' | 'NOWAIT' | 'NULL' | 'NUMBER' + | 'OF' | 'OFFLINE' | 'ON' | 'ONLINE' | 'OPTION' | 'OR' | 'ORDER' + | 'PCTFREE' | 'PRIOR' | 'PRIVILEGES' | 'PUBLIC' + | 'RAW' | 'RENAME' | 'RESOURCE' | 'REVOKE' | 'ROW' | 'ROWID' | 'ROWLABEL' | 'ROWNUM' | 'ROWS' + | 'SELECT' | 'SESSION' | 'SET' | 'SHARE' | 'SIZE' | 'SMALLINT' | 'SQLBUF' + | 'START' | 'SUCCESSFUL' | 'SYNONYM' | 'SYSDATE' + | 'TABLE' | 'THEN' | 'TO' | 'TRIGGER' + | 'UID' | 'UNION' | 'UNIQUE' | 'UPDATE' | 'USER' + | 'VALIDATE' | 'VALUES' | 'VARCHAR' | 'VARCHAR2' | 'VIEW' + | 'WHENEVER' | 'WHERE' | 'WITH' + ) //{ $r->setType($r, T_RESERVED); } + //{ $type = T_RESERVED; } + // -> ^(T_RESERVED[$r]) + ; + +/* ================================================================================ + Oracle keywords + can by used for name database objects such as columns, tables, or indexes. + ================================================================================ */ +k_a : r='A' { $r->setType($r, T_RESERVED); } ; +k_admin : r='ADMIN' { $r->setType($r, T_RESERVED); } ; +k_after : r='AFTER' { $r->setType($r, T_RESERVED); } ; +k_allocate : r='ALLOCATE' { $r->setType($r, T_RESERVED); } ; +k_analyze : r='ANALYZE' { $r->setType($r, T_RESERVED); } ; +k_archive : r='ARCHIVE' { $r->setType($r, T_RESERVED); } ; +k_archivelog : r='ARCHIVELOG' { $r->setType($r, T_RESERVED); } ; +k_authorization : r='AUTHORIZATION' { $r->setType($r, T_RESERVED); } ; +k_avg : r='AVG' { $r->setType($r, T_RESERVED); } ; +k_backup : r='BACKUP' { $r->setType($r, T_RESERVED); } ; +k_become : r='BECOME' { $r->setType($r, T_RESERVED); } ; +k_before : r='BEFORE' { $r->setType($r, T_RESERVED); } ; +k_begin : r='BEGIN' { $r->setType($r, T_RESERVED); } ; +k_block : r='BLOCK' { $r->setType($r, T_RESERVED); } ; +k_body : r='BODY' { $r->setType($r, T_RESERVED); } ; +k_cache : r='CACHE' { $r->setType($r, T_RESERVED); } ; +k_cancel : r='CANCEL' { $r->setType($r, T_RESERVED); } ; +k_cascade : r='CASCADE' { $r->setType($r, T_RESERVED); } ; +k_change : r='CHANGE' { $r->setType($r, T_RESERVED); } ; +k_character : r='CHARACTER' { $r->setType($r, T_RESERVED); } ; +k_checkpoint : r='CHECKPOINT' { $r->setType($r, T_RESERVED); } ; +k_close : r='CLOSE' { $r->setType($r, T_RESERVED); } ; +k_cobol : r='COBOL' { $r->setType($r, T_RESERVED); } ; +k_commit : r='COMMIT' { $r->setType($r, T_RESERVED); } ; +k_compile : r='COMPILE' { $r->setType($r, T_RESERVED); } ; +k_constraint : r='CONSTRAINT' { $r->setType($r, T_RESERVED); } ; +k_constraints : r='CONSTRAINTS' { $r->setType($r, T_RESERVED); } ; +k_contents : r='CONTENTS' { $r->setType($r, T_RESERVED); } ; +k_continue : r='CONTINUE' { $r->setType($r, T_RESERVED); } ; +k_controlfile : r='CONTROLFILE' { $r->setType($r, T_RESERVED); } ; +k_count : r='COUNT' { $r->setType($r, T_RESERVED); } ; +k_cursor : r='CURSOR' { $r->setType($r, T_RESERVED); } ; +k_cycle : r='CYCLE' { $r->setType($r, T_RESERVED); } ; +k_database : r='DATABASE' { $r->setType($r, T_RESERVED); } ; +k_datafile : r='DATAFILE' { $r->setType($r, T_RESERVED); } ; +k_dba : r='DBA' { $r->setType($r, T_RESERVED); } ; +k_dec : r='DEC' { $r->setType($r, T_RESERVED); } ; +k_declare : r='DECLARE' { $r->setType($r, T_RESERVED); } ; +k_disable : r='DISABLE' { $r->setType($r, T_RESERVED); } ; +k_dismount : r='DISMOUNT' { $r->setType($r, T_RESERVED); } ; +k_double : r='DOUBLE' { $r->setType($r, T_RESERVED); } ; +k_dump : r='DUMP' { $r->setType($r, T_RESERVED); } ; +k_each : r='EACH' { $r->setType($r, T_RESERVED); } ; +k_enable : r='ENABLE' { $r->setType($r, T_RESERVED); } ; +k_end : r='END' { $r->setType($r, T_RESERVED); } ; +k_escape : r='ESCAPE' { $r->setType($r, T_RESERVED); } ; +k_events : r='EVENTS' { $r->setType($r, T_RESERVED); } ; +k_except : r='EXCEPT' { $r->setType($r, T_RESERVED); } ; +k_exceptions : r='EXCEPTIONS' { $r->setType($r, T_RESERVED); } ; +k_exec : r='EXEC' { $r->setType($r, T_RESERVED); } ; +k_execute : r='EXECUTE' { $r->setType($r, T_RESERVED); } ; +k_explain : r='EXPLAIN' { $r->setType($r, T_RESERVED); } ; +k_extent : r='EXTENT' { $r->setType($r, T_RESERVED); } ; +k_externally : r='EXTERNALLY' { $r->setType($r, T_RESERVED); } ; +k_fetch : r='FETCH' { $r->setType($r, T_RESERVED); } ; +k_flush : r='FLUSH' { $r->setType($r, T_RESERVED); } ; +k_force : r='FORCE' { $r->setType($r, T_RESERVED); } ; +k_foreign : r='FOREIGN' { $r->setType($r, T_RESERVED); } ; +k_fortran : r='FORTRAN' { $r->setType($r, T_RESERVED); } ; +k_found : r='FOUND' { $r->setType($r, T_RESERVED); } ; +k_freelist : r='FREELIST' { $r->setType($r, T_RESERVED); } ; +k_freelists : r='FREELISTS' { $r->setType($r, T_RESERVED); } ; +k_function : r='FUNCTION' { $r->setType($r, T_RESERVED); } ; +k_go : r='GO' { $r->setType($r, T_RESERVED); } ; +k_goto : r='GOTO' { $r->setType($r, T_RESERVED); } ; +k_groups : r='GROUPS' { $r->setType($r, T_RESERVED); } ; +k_including : r='INCLUDING' { $r->setType($r, T_RESERVED); } ; +k_indicator : r='INDICATOR' { $r->setType($r, T_RESERVED); } ; +k_initrans : r='INITRANS' { $r->setType($r, T_RESERVED); } ; +k_instance : r='INSTANCE' { $r->setType($r, T_RESERVED); } ; +k_int : r='INT' { $r->setType($r, T_RESERVED); } ; +k_key : r='KEY' { $r->setType($r, T_RESERVED); } ; +k_language : r='LANGUAGE' { $r->setType($r, T_RESERVED); } ; +k_layer : r='LAYER' { $r->setType($r, T_RESERVED); } ; +k_link : r='LINK' { $r->setType($r, T_RESERVED); } ; +k_lists : r='LISTS' { $r->setType($r, T_RESERVED); } ; +k_logfile : r='LOGFILE' { $r->setType($r, T_RESERVED); } ; +k_manage : r='MANAGE' { $r->setType($r, T_RESERVED); } ; +k_manual : r='MANUAL' { $r->setType($r, T_RESERVED); } ; +k_max : r='MAX' { $r->setType($r, T_RESERVED); } ; +k_maxdatafiles : r='MAXDATAFILES' { $r->setType($r, T_RESERVED); } ; +k_maxinstances : r='MAXINSTANCES' { $r->setType($r, T_RESERVED); } ; +k_maxlogfiles : r='MAXLOGFILES' { $r->setType($r, T_RESERVED); } ; +k_maxloghistory : r='MAXLOGHISTORY' { $r->setType($r, T_RESERVED); } ; +k_maxlogmembers : r='MAXLOGMEMBERS' { $r->setType($r, T_RESERVED); } ; +k_maxtrans : r='MAXTRANS' { $r->setType($r, T_RESERVED); } ; +k_maxvalue : r='MAXVALUE' { $r->setType($r, T_RESERVED); } ; +k_min : r='MIN' { $r->setType($r, T_RESERVED); } ; +k_minextents : r='MINEXTENTS' { $r->setType($r, T_RESERVED); } ; +k_minvalue : r='MINVALUE' { $r->setType($r, T_RESERVED); } ; +k_module : r='MODULE' { $r->setType($r, T_RESERVED); } ; +k_mount : r='MOUNT' { $r->setType($r, T_RESERVED); } ; +k_new : r='NEW' { $r->setType($r, T_RESERVED); } ; +k_next : r='NEXT' { $r->setType($r, T_RESERVED); } ; +k_noarchivelog : r='NOARCHIVELOG' { $r->setType($r, T_RESERVED); } ; +k_nocache : r='NOCACHE' { $r->setType($r, T_RESERVED); } ; +k_nocycle : r='NOCYCLE' { $r->setType($r, T_RESERVED); } ; +k_nomaxvalue : r='NOMAXVALUE' { $r->setType($r, T_RESERVED); } ; +k_nominvalue : r='NOMINVALUE' { $r->setType($r, T_RESERVED); } ; +k_none : r='NONE' { $r->setType($r, T_RESERVED); } ; +k_noorder : r='NOORDER' { $r->setType($r, T_RESERVED); } ; +k_noresetlogs : r='NORESETLOGS' { $r->setType($r, T_RESERVED); } ; +k_normal : r='NORMAL' { $r->setType($r, T_RESERVED); } ; +k_nosort : r='NOSORT' { $r->setType($r, T_RESERVED); } ; +k_numeric : r='NUMERIC' { $r->setType($r, T_RESERVED); } ; +k_off : r='OFF' { $r->setType($r, T_RESERVED); } ; +k_old : r='OLD' { $r->setType($r, T_RESERVED); } ; +k_only : r='ONLY' { $r->setType($r, T_RESERVED); } ; +k_open : r='OPEN' { $r->setType($r, T_RESERVED); } ; +k_optimal : r='OPTIMAL' { $r->setType($r, T_RESERVED); } ; +k_own : r='OWN' { $r->setType($r, T_RESERVED); } ; +k_package : r='PACKAGE' { $r->setType($r, T_RESERVED); } ; +k_parallel : r='PARALLEL' { $r->setType($r, T_RESERVED); } ; +k_pctincrease : r='PCTINCREASE' { $r->setType($r, T_RESERVED); } ; +k_pctused : r='PCTUSED' { $r->setType($r, T_RESERVED); } ; +k_plan : r='PLAN' { $r->setType($r, T_RESERVED); } ; +k_pli : r='PLI' { $r->setType($r, T_RESERVED); } ; +k_precision : r='PRECISION' { $r->setType($r, T_RESERVED); } ; +k_primary : r='PRIMARY' { $r->setType($r, T_RESERVED); } ; +k_private : r='PRIVATE' { $r->setType($r, T_RESERVED); } ; +k_procedure : r='PROCEDURE' { $r->setType($r, T_RESERVED); } ; +k_profile : r='PROFILE' { $r->setType($r, T_RESERVED); } ; +k_quota : r='QUOTA' { $r->setType($r, T_RESERVED); } ; +k_read : r='READ' { $r->setType($r, T_RESERVED); } ; +k_real : r='REAL' { $r->setType($r, T_RESERVED); } ; +k_recover : r='RECOVER' { $r->setType($r, T_RESERVED); } ; +k_references : r='REFERENCES' { $r->setType($r, T_RESERVED); } ; +k_referencing : r='REFERENCING' { $r->setType($r, T_RESERVED); } ; +k_resetlogs : r='RESETLOGS' { $r->setType($r, T_RESERVED); } ; +k_restricted : r='RESTRICTED' { $r->setType($r, T_RESERVED); } ; +k_reuse : r='REUSE' { $r->setType($r, T_RESERVED); } ; +k_role : r='ROLE' { $r->setType($r, T_RESERVED); } ; +k_roles : r='ROLES' { $r->setType($r, T_RESERVED); } ; +k_rollback : r='ROLLBACK' { $r->setType($r, T_RESERVED); } ; +k_savepoint : r='SAVEPOINT' { $r->setType($r, T_RESERVED); } ; +k_schema : r='SCHEMA' { $r->setType($r, T_RESERVED); } ; +k_scn : r='SCN' { $r->setType($r, T_RESERVED); } ; +k_section : r='SECTION' { $r->setType($r, T_RESERVED); } ; +k_segment : r='SEGMENT' { $r->setType($r, T_RESERVED); } ; +k_sequence : r='SEQUENCE' { $r->setType($r, T_RESERVED); } ; +k_shared : r='SHARED' { $r->setType($r, T_RESERVED); } ; +k_snapshot : r='SNAPSHOT' { $r->setType($r, T_RESERVED); } ; +k_some : r='SOME' { $r->setType($r, T_RESERVED); } ; +k_sort : r='SORT' { $r->setType($r, T_RESERVED); } ; +k_sql : r='SQL' { $r->setType($r, T_RESERVED); } ; +k_sqlcode : r='SQLCODE' { $r->setType($r, T_RESERVED); } ; +k_sqlerror : r='SQLERROR' { $r->setType($r, T_RESERVED); } ; +k_sqlstate : r='SQLSTATE' { $r->setType($r, T_RESERVED); } ; +k_statement_ID : r='STATEMENT' { $r->setType($r, T_RESERVED); } ; +k_statistics : r='STATISTICS' { $r->setType($r, T_RESERVED); } ; +k_stop : r='STOP' { $r->setType($r, T_RESERVED); } ; +k_storage : r='STORAGE' { $r->setType($r, T_RESERVED); } ; +k_sum : r='SUM' { $r->setType($r, T_RESERVED); } ; +k_switch : r='SWITCH' { $r->setType($r, T_RESERVED); } ; +k_system : r='SYSTEM' { $r->setType($r, T_RESERVED); } ; +k_tables : r='TABLES' { $r->setType($r, T_RESERVED); } ; +k_tablespace : r='TABLESPACE' { $r->setType($r, T_RESERVED); } ; +k_temporary : r='TEMPORARY' { $r->setType($r, T_RESERVED); } ; +k_thread : r='THREAD' { $r->setType($r, T_RESERVED); } ; +k_time : r='TIME' { $r->setType($r, T_RESERVED); } ; +k_tracing : r='TRACING' { $r->setType($r, T_RESERVED); } ; +k_transaction : r='TRANSACTION' { $r->setType($r, T_RESERVED); } ; +k_triggers : r='TRIGGERS' { $r->setType($r, T_RESERVED); } ; +k_truncate : r='TRUNCATE' { $r->setType($r, T_RESERVED); } ; +k_under : r='UNDER' { $r->setType($r, T_RESERVED); } ; +k_unlimited : r='UNLIMITED' { $r->setType($r, T_RESERVED); } ; +k_until : r='UNTIL' { $r->setType($r, T_RESERVED); } ; +k_use : r='USE' { $r->setType($r, T_RESERVED); } ; +k_using : r='USING' { $r->setType($r, T_RESERVED); } ; +k_when : r='WHEN' { $r->setType($r, T_RESERVED); } ; +k_work : r='WORK' { $r->setType($r, T_RESERVED); } ; +k_write : r='WRITE' { $r->setType($r, T_RESERVED); } ; + +keyword + : 'A' // note: this one is not listed in the docs but is a part of "IS A SET" condition clause + | 'ADMIN' | 'AFTER' | 'ALLOCATE' | 'ANALYZE' | 'ARCHIVE' | 'ARCHIVELOG' | 'AUTHORIZATION' | 'AVG' + | 'BACKUP' | 'BECOME' | 'BEFORE' | 'BEGIN' | 'BLOCK' | 'BODY' + | 'CACHE' | 'CANCEL' | 'CASCADE' | 'CHANGE' | 'CHARACTER' | 'CHECKPOINT' | 'CLOSE' + | 'COBOL' | 'COMMIT' | 'COMPILE' | 'CONSTRAINT' | 'CONSTRAINTS' | 'CONTENTS' | 'CONTINUE' + | 'CONTROLFILE' | 'COUNT' | 'CURSOR' | 'CYCLE' + | 'DATABASE' | 'DATAFILE' | 'DBA' | 'DEC' | 'DECLARE' | 'DISABLE' | 'DISMOUNT' | 'DOUBLE' | 'DUMP' + | 'EACH' | 'ENABLE' | 'END' | 'ESCAPE' | 'EVENTS' | 'EXCEPT' | 'EXCEPTIONS' | 'EXEC' | 'EXECUTE' + | 'EXPLAIN' | 'EXTENT' | 'EXTERNALLY' + | 'FETCH' | 'FLUSH' | 'FORCE' | 'FOREIGN' | 'FORTRAN' | 'FOUND' | 'FREELIST' + | 'FREELISTS' | 'FUNCTION' + | 'GO' | 'GOTO' | 'GROUPS' + | 'INCLUDING' | 'INDICATOR' | 'INITRANS' | 'INSTANCE' | 'INT' + | 'KEY' + | 'LANGUAGE' | 'LAYER' | 'LINK' | 'LISTS' | 'LOGFILE' + | 'MANAGE' | 'MANUAL' | 'MAX' | 'MAXDATAFILES' | 'MAXINSTANCES' | 'MAXLOGFILES' | 'MAXLOGHISTORY' + | 'MAXLOGMEMBERS' | 'MAXTRANS' | 'MAXVALUE' | 'MIN' | 'MINEXTENTS' | 'MINVALUE' | 'MODULE' | 'MOUNT' + | 'NEW' | 'NEXT' | 'NOARCHIVELOG' | 'NOCACHE' | 'NOCYCLE' | 'NOMAXVALUE' | 'NOMINVALUE' | 'NONE' + | 'NOORDER' | 'NORESETLOGS' | 'NORMAL' | 'NOSORT' | 'NUMERIC' + | 'OFF' | 'OLD' | 'ONLY' | 'OPEN' | 'OPTIMAL' | 'OWN' + | 'PACKAGE' | 'PARALLEL' | 'PCTINCREASE' | 'PCTUSED' | 'PLAN' | 'PLI' | 'PRECISION' | 'PRIMARY' + | 'PRIVATE' | 'PROCEDURE' | 'PROFILE' + | 'QUOTA' + | 'READ' | 'REAL' | 'RECOVER' | 'REFERENCES' | 'REFERENCING' | 'RESETLOGS' | 'RESTRICTED' | 'REUSE' + | 'ROLE' | 'ROLES' | 'ROLLBACK' + | 'SAVEPOINT' | 'SCHEMA' | 'SCN' | 'SECTION' | 'SEGMENT' | 'SEQUENCE' | 'SHARED' | 'SNAPSHOT' + | 'SOME' | 'SORT' | 'SQL' | 'SQLCODE' | 'SQLERROR' | 'SQLSTATE' | 'STATEMENT_ID' + | 'STATISTICS' | 'STOP' | 'STORAGE' | 'SUM' | 'SWITCH' | 'SYSTEM' + | 'TABLES' | 'TABLESPACE' | 'TEMPORARY' | 'THREAD' | 'TIME' | 'TRACING' | 'TRANSACTION' | 'TRIGGERS' + | 'TRUNCATE' + | 'UNDER' | 'UNLIMITED' | 'UNTIL' | 'USE' | 'USING' + | 'WHEN' | 'WORK' | 'WRITE' + ; + +QUOTED_STRING + : ( 'n' )? '\'' ( '\'\'' | ~('\'') )* '\'' + ; +ID /*options { testLiterals=true; }*/ + : 'A' .. 'Z' ( 'A' .. 'Z' | '0' .. '9' | '_' | '$' | '#' )* + | DOUBLEQUOTED_STRING + ; +SEMI + : ';' + ; +COLON + : ':' + ; +DOUBLEDOT + : POINT POINT + ; +DOT + : POINT + ; +fragment +POINT + : '.' + ; +COMMA + : ',' + ; +EXPONENT + : '**' + ; +ASTERISK + : '*' + ; +AT_SIGN + : '@' + ; +RPAREN + : ')' + ; +LPAREN + : '(' + ; +RBRACK + : ']' + ; +LBRACK + : '[' + ; +PLUS + : '+' + ; +MINUS + : '-' + ; +DIVIDE + : '/' + ; +EQ + : '=' + ; +PERCENTAGE + : '%' + ; +LLABEL + : '<<' + ; +RLABEL + : '>>' + ; +ASSIGN + : ':=' + ; +ARROW + : '=>' + ; +VERTBAR + : '|' + ; +DOUBLEVERTBAR + : '||' + ; +NOT_EQ + : '<>' | '!=' | '^=' + ; +LTH + : '<' + ; +LEQ + : '<=' + ; +GTH + : '>' + ; +GEQ + : '>=' + ; +NUMBER + : //( PLUS | MINUS )? + ( ( N POINT N ) => N POINT N + | POINT N + | N + ) + ( 'E' ( PLUS | MINUS )? N )? + ; +fragment +N + : '0' .. '9' ( '0' .. '9' )* + ; +QUOTE + : '\'' + ; +fragment +DOUBLEQUOTED_STRING + : '"' ( ~('"') )* '"' + ; +WS : (' '|'\r'|'\t'|'\n') {$channel=HIDDEN;} + ; +SL_COMMENT + : '--' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;} + ; +ML_COMMENT + : '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;} + ; +TYPE_ATTR + : '%TYPE' + ; +ROWTYPE_ATTR + : '%ROWTYPE' + ; +NOTFOUND_ATTR + : '%NOTFOUND' + ; +FOUND_ATTR + : '%FOUND' + ; +ISOPEN_ATTR + : '%ISOPEN' + ; +ROWCOUNT_ATTR + : '%ROWCOUNT' + ; +BULK_ROWCOUNT_ATTR + : '%BULK_ROWCOUNT' + ; +CHARSET_ATTR + : '%CHARSET' + ; + Added: branches/tora-trotl/sandbox/SELECT_SIMPLE.tokens =================================================================== --- branches/tora-trotl/sandbox/SELECT_SIMPLE.tokens (rev 0) +++ branches/tora-trotl/sandbox/SELECT_SIMPLE.tokens 2010-05-19 21:30:44 UTC (rev 3527) @@ -0,0 +1,818 @@ +BULK_ROWCOUNT_ATTR=33 +T_FROM=9 +T__93=93 +T__94=94 +RPAREN=19 +T__91=91 +T__92=92 +T_SELECT_COLUMN=8 +T__90=90 +GEQ=42 +EQ=39 +T__99=99 +T__98=98 +DIVIDE=26 +T__97=97 +T__96=96 +T__95=95 +RBRACK=46 +T__80=80 +T__81=81 +T__82=82 +T__83=83 +N=56 +T__85=85 +T__84=84 +T__87=87 +T__86=86 +PERCENTAGE=51 +T__89=89 +T__88=88 +T__71=71 +T__72=72 +T__70=70 +T_WHERE=11 +SL_COMMENT=59 +T_SELECT=6 +T__76=76 +T__75=75 +T__74=74 +T__73=73 +T__79=79 +T__78=78 +T__77=77 +LBRACK=45 +POINT=49 +TYPE_ATTR=61 +PLUS=23 +NOTFOUND_ATTR=30 +MINUS=24 +SEMI=47 +NOT_EQ=40 +VERTBAR=55 +COLON=48 +ARROW=28 +T__377=377 +T__376=376 +T__375=375 +T__374=374 +T__373=373 +T__372=372 +T__371=371 +T__370=370 +T_SELECTED_TABLE=10 +T__369=369 +DOUBLEDOT=50 +T__367=367 +T__368=368 +QUOTE=57 +T__380=380 +T__386=386 +T__385=385 +T__388=388 +T__387=387 +T__382=382 +T__381=381 +T__384=384 +T__383=383 +T__378=378 +T__379=379 +T__391=391 +T__390=390 +T__395=395 +T__394=394 +T__393=393 +T__392=392 +T__399=399 +T__398=398 +T__397=397 +T__396=396 +T__389=389 +DOUBLEVERTBAR=25 +T_SET_OP=16 +T__200=200 +T__201=201 +T__68=68 +T__332=332 +T__69=69 +T__333=333 +T__66=66 +T__330=330 +T__67=67 +T__331=331 +T__64=64 +T__65=65 +ID=36 +T__329=329 +T__328=328 +T__327=327 +T__326=326 +T__325=325 +T__324=324 +T__323=323 +T__341=341 +T__342=342 +T__343=343 +T__344=344 +T__340=340 +COMMA=20 +QUOTED_STRING=34 +T__339=339 +T__338=338 +ISOPEN_ATTR=31 +T__335=335 +T__334=334 +T__337=337 +T__336=336 +T__350=350 +T__351=351 +T__354=354 +T__355=355 +T__352=352 +T__353=353 +T__348=348 +T__347=347 +T__346=346 +T__345=345 +T__349=349 +T__360=360 +T__361=361 +T__362=362 +T__363=363 +T__364=364 +T__365=365 +T__366=366 +ASSIGN=54 +T__357=357 +T__356=356 +T__359=359 +T__358=358 +CHARSET_ATTR=63 +LEQ=44 +T_RESERVED=4 +T__159=159 +T__158=158 +T__259=259 +T__258=258 +T__257=257 +T__435=435 +T__433=433 +T__434=434 +T__262=262 +T__160=160 +T__263=263 +T__260=260 +T__261=261 +T__266=266 +T__267=267 +T__264=264 +T__265=265 +T__167=167 +T__168=168 +T__165=165 +T__166=166 +T__163=163 +T__300=300 +T__164=164 +T__161=161 +T__162=162 +T_WITH=5 +T__148=148 +T__147=147 +T__149=149 +T__247=247 +T__426=426 +T__246=246 +T__427=427 +T__249=249 +T__428=428 +T__248=248 +T__429=429 +T__422=422 +T__423=423 +T__424=424 +T__425=425 +T__430=430 +T__250=250 +T__251=251 +T__432=432 +T__252=252 +T__431=431 +T__253=253 +T__254=254 +T__255=255 +T__256=256 +T__154=154 +T__155=155 +T__156=156 +T__157=157 +T__150=150 +T__151=151 +T__152=152 +T__153=153 +T__139=139 +T__318=318 +T__138=138 +T__319=319 +T__137=137 +T__316=316 +T__419=419 +T__136=136 +T__317=317 +T__314=314 +T_COLUMN_LIST=7 +T__315=315 +T__312=312 +T__313=313 +T__413=413 +T__414=414 +T__411=411 +T__412=412 +T__417=417 +T__418=418 +T__415=415 +NUMBER=35 +T__279=279 +T__416=416 +T__288=288 +T__289=289 +AT_SIGN=38 +T__286=286 +T__287=287 +T__284=284 +T__421=421 +T__285=285 +T__420=420 +T__282=282 +T__283=283 +T__141=141 +T__280=280 +T__322=322 +T__142=142 +T__281=281 +T__321=321 +T__320=320 +T__140=140 +T__145=145 +T__146=146 +T__143=143 +T__144=144 +T__126=126 +T__305=305 +T__408=408 +T__125=125 +T__306=306 +T__409=409 +T__128=128 +T__307=307 +T__127=127 +T__308=308 +WS=58 +T__301=301 +T__129=129 +T__302=302 +T__303=303 +T__304=304 +T__400=400 +T__401=401 +T__402=402 +T__403=403 +T__269=269 +T__309=309 +T__404=404 +T__268=268 +T__405=405 +T__406=406 +T__407=407 +T__275=275 +T__276=276 +T__277=277 +T__278=278 +T__271=271 +T__272=272 +T__273=273 +T__410=410 +T__274=274 +T__130=130 +T__311=311 +T__131=131 +T__270=270 +T__310=310 +T__132=132 +T__133=133 +ROWTYPE_ATTR=62 +T__134=134 +T__135=135 +T__215=215 +T__216=216 +T__213=213 +T__214=214 +T__219=219 +T__217=217 +T__218=218 +T__118=118 +T__119=119 +T__116=116 +T__117=117 +T__114=114 +T__115=115 +T__124=124 +LLABEL=52 +T__123=123 +T__122=122 +T__121=121 +T__120=120 +T__223=223 +ASTERISK=21 +LPAREN=18 +T__222=222 +T__221=221 +RLABEL=53 +T__220=220 +T__202=202 +T__203=203 +T__204=204 +T__205=205 +T__206=206 +T__207=207 +T__208=208 +T__209=209 +T__107=107 +T__108=108 +T__109=109 +T__103=103 +T__104=104 +T__105=105 +T__106=106 +T__111=111 +T__110=110 +T__113=113 +T__112=112 +T__210=210 +T_GROUP_BY=13 +T__212=212 +T__211=211 +T__239=239 +T__237=237 +T__238=238 +T__235=235 +T__236=236 +T__102=102 +T__101=101 +T__100=100 +T__245=245 +T__244=244 +T__243=243 +T__242=242 +T__241=241 +T__240=240 +T__228=228 +T__229=229 +T__224=224 +T__225=225 +T__226=226 +T__227=227 +T__232=232 +T__231=231 +T__234=234 +T__233=233 +T__230=230 +EXPONENT=27 +FOUND_ATTR=29 +ROWCOUNT_ATTR=32 +T_ORDER_BY_CLAUSE=17 +T_MODEL=15 +T_HIERARCHICAL=12 +T_HAVING=14 +GTH=41 +ML_COMMENT=60 +T__199=199 +T__198=198 +T__197=197 +T__292=292 +T__196=196 +T__291=291 +T__195=195 +T__290=290 +T__194=194 +T__193=193 +T__296=296 +T__192=192 +T__295=295 +T__191=191 +T__294=294 +T__190=190 +T__293=293 +T__299=299 +T__298=298 +T__297=297 +DOT=22 +T__184=184 +T__183=183 +T__186=186 +T__185=185 +T__188=188 +T__187=187 +T__189=189 +DOUBLEQUOTED_STRING=37 +T__180=180 +T__182=182 +T__181=181 +LTH=43 +T__175=175 +T__174=174 +T__173=173 +T__172=172 +T__179=179 +T__178=178 +T__177=177 +T__176=176 +T__171=171 +T__170=170 +T__169=169 +'PUBLIC'=246 +'STATEMENT'=414 +'UNDER'=429 +'CURSOR'=303 +'FETCH'=325 +'with'=5 +'SQLBUF'=257 +'FORTRAN'=329 +'group_by'=13 +'OFFLINE'=241 +'VARIANCE'=185 +'EXTENT'=323 +'AVG'=150 +'PERCENTILE_CONT'=165 +'FULL'=74 +'ADMIN'=275 +'CLOSE'=294 +'NUMERIC'=372 +'ASC'=145 +'TYPE'=105 +'SELECT'=252 +'INT'=341 +'MANAGE'=348 +'LIKE'=108 +'THREAD'=423 +'FLOAT'=217 +'COMMIT'=296 +'ROW'=191 +'ACCESS'=194 +'MAXVALUE'=356 +'STDDEV_POP'=180 +'ROLE'=398 +'INCLUDING'=337 +'PRIMARY'=385 +'THE'=79 +'NULLS'=147 +'INSTANCE'=340 +'NOMINVALUE'=366 +'START'=80 +'RIGHT'=76 +'EQUALS_PATH'=117 +'EXCEPTIONS'=319 +'CONTENTS'=300 +'LIKEC'=109 +'REGR_SXX'=175 +'NOCYCLE'=83 +'ARCHIVELOG'=280 +'CREATE'=207 +'NEW'=361 +'PRIVILEGES'=245 +'SETS'=88 +'LEFT'=75 +'GROUPS'=336 +'ANALYZE'=278 +'VARCHAR'=269 +'VARCHAR2'=270 +'MANUAL'=349 +'TO'=141 +'PARTITION'=72 +'UPSERT'=134 +'RESETLOGS'=395 +'having'=14 +'LAG'=158 +'UNTIL'=139 +'ARRAYLEN'=197 +'CONTROLFILE'=302 +'RESTRICTED'=396 +'REFERENCES'=393 +'hierarchical'=12 +'NORMAL'=370 +'ADD'=195 +'PRESENT'=107 +'CHAR'=201 +'PERCENTILE_DISC'=166 +'CHARACTER'=292 +'FREELIST'=331 +'UNLIMITED'=430 +'MAX'=161 +'DEC'=308 +'CASE'=200 +'VAR_SAMP'=184 +'NOORDER'=368 +'TRUE'=263 +'ROLES'=399 +'ROWLABEL'=251 +'CONTINUE'=301 +'FORCE'=327 +'reserved'=4 +'END'=316 +'COMPRESS'=206 +'RECEEDING'=192 +'PLAN'=382 +'ARCHIVE'=279 +'column_list'=7 +'SQLERROR'=412 +'SUBMULTISET'=116 +'DISABLE'=310 +'FUNCTION'=333 +'ONLY'=106 +'UPDATE'=133 +'REGR_INTERCEPT'=170 +'EMPTY'=103 +'INTO'=228 +'BODY'=287 +'SESSION'=253 +'VALUES'=268 +'HAVING'=220 +'REGEXP_LIKE'=115 +'REFERENCING'=394 +'TEMPORARY'=422 +'select_column'=8 +'NOT'=91 +'REGR_AVGY'=174 +'RETURN'=127 +'SAVEPOINT'=401 +'LAYER'=344 +'ROW_NUMBER'=178 +'REGR_SLOPE'=169 +'NOWAIT'=239 +'ITERATE'=138 +'set_op'=16 +'DECREMENT'=143 +'RANGE'=193 +'REGR_COUNT'=171 +'EXEC'=320 +'STATEMENT_ID'=435 +'REGR_AVGX'=173 +'BLOCK'=286 +'CONSTRAINTS'=299 +'RAW'=247 +'SYNONYM'=259 +'MAXINSTANCES'=351 +'WORK'=433 +'REGR_SXY'=177 +'WHERE'=273 +'SWITCH'=418 +'GROUP'=84 +'MAXDATAFILES'=350 +'IDENTIFIED'=221 +'WITH'=81 +'REAL'=391 +'WHEN'=432 +'PLI'=383 +'NUMBER'=240 +'ALTER'=196 +'NTILE'=163 +'MEMBER'=113 +'ROWNUM'=65 +'IMMEDIATE'=222 +'PARALLEL'=379 +'DECLARE'=309 +'TRACING'=425 +'LINK'=345 +'MINVALUE'=358 +'ALLOCATE'=277 +'OPTIMAL'=376 +'THEN'=261 +'INTERSECT'=227 +'LISTS'=346 +'COUNT'=154 +'BECOME'=283 +'MODE'=234 +'NAN'=94 +'INITRANS'=339 +'ROWID'=64 +'BACKUP'=282 +'IGNORE'=120 +'DESC'=146 +'TABLE'=78 +'OPEN'=375 +'AUTOMATIC'=135 +'OWN'=377 +'SUCCESSFUL'=258 +'SYSTEM'=419 +'RENAME'=248 +'NOTFOUND'=238 +'ENABLE'=315 +'STATISTICS'=415 +'COMMENT'=205 +'EXTERNALLY'=324 +'WHENEVER'=272 +'SEQUENTIAL'=136 +'ALL'=100 +'OF'=104 +'t_order_by'=17 +'EVENTS'=317 +'DATABASE'=305 +'AFTER'=276 +'MIN'=162 +'KEY'=342 +'CLUSTER'=203 +'LEVEL'=229 +'CONNECT'=82 +'SECTION'=404 +'LAST'=149 +'OFF'=373 +'CHANGE'=291 +'WRITE'=434 +'INDICATOR'=338 +'MAXEXTENTS'=232 +'MAXLOGFILES'=352 +'EXCLUSIVE'=214 +'PRIVATE'=386 +'INCREMENT'=142 +'USER'=266 +'MAXTRANS'=355 +'RANK'=167 +'GRANT'=219 +'PACKAGE'=378 +'SEGMENT'=405 +'MAXLOGMEMBERS'=354 +'SOME'=99 +'EACH'=314 +'SHARED'=407 +'EXISTS'=92 +'SNAPSHOT'=408 +'AUDIT'=199 +'NAV'=122 +'DENSE_RANK'=156 +'UNDER_PATH'=118 +'FOUND'=330 +'NEXT'=362 +'PCTFREE'=244 +'OLD'=374 +'CANCEL'=289 +'SUM'=182 +'LONG'=231 +'ORDER'=137 +'PERCENT_RANK'=164 +'SIBLINGS'=144 +'ROLLBACK'=400 +'TRUNCATE'=428 +'MINUS'=233 +'COVAR_SAMP'=153 +'BEFORE'=284 +'CYCLE'=304 +'FLUSH'=326 +'LEAD'=160 +'BEGIN'=285 +'where'=11 +'PROFILE'=388 +'DOUBLE'=312 +'ON'=68 +'ROWS'=129 +'OPTION'=243 +'REGR_SYY'=176 +'SMALLINT'=256 +'MODIFY'=235 +'REGR_R2'=172 +'COVAR_POP'=152 +'NULL'=96 +'PROCEDURE'=387 +'NATURAL'=71 +'FALSE'=215 +'JOIN'=67 +'UNBOUNDED'=188 +'DATE'=208 +'MINEXTENTS'=357 +'RECOVER'=392 +'FOREIGN'=328 +'TIME'=424 +'READ'=390 +'t_model'=15 +'BY'=73 +'DIMENSION'=124 +'COBOL'=295 +'FROM'=218 +'DROP'=212 +'TABLESPACE'=421 +'PCTUSED'=381 +'OUTER'=77 +'DISMOUNT'=311 +'GOTO'=335 +'MOUNT'=360 +'SORT'=409 +'SQLCODE'=411 +'SHARE'=254 +'CASCADE'=290 +'NOAUDIT'=236 +'LIKE4'=111 +'INNER'=66 +'CURRENT'=190 +'CORR'=151 +'CACHE'=288 +'BETWEEN'=114 +'RATIO_TO_REPORT'=168 +'FREELISTS'=332 +'GO'=334 +'STDDEV'=179 +'A'=274 +'DBA'=307 +'t_select'=6 +'COMPILE'=297 +'DISTINCT'=186 +'INDEX'=223 +'UNION'=265 +'LIKE2'=110 +'VAR_POP'=183 +'UNIQUE'=123 +'UPDATED'=128 +'LANGUAGE'=343 +'SYSDATE'=260 +'MODULE'=359 +'REVOKE'=250 +'TRANSACTION'=426 +'EXPLAIN'=322 +'SINGLE'=125 +'VALIDATE'=267 +'FILE'=216 +'SIZE'=255 +'OR'=89 +'LAST_VALUE'=159 +'GROUPING'=87 +'INITIAL'=224 +'TABLES'=420 +'VIEW'=271 +'NORESETLOGS'=369 +'CUBE'=86 +'INTEGER'=226 +'ESCAPE'=112 +'TRIGGER'=262 +'QUOTA'=389 +'ANY'=98 +'PRECISION'=384 +'IS'=93 +'REUSE'=397 +'NOCACHE'=364 +'INFINITE'=95 +'NOSORT'=371 +'DECIMAL'=209 +'SET'=102 +'selected_table'=10 +'STOP'=416 +'EXECUTE'=321 +'ELSE'=213 +'AS'=198 +'MODEL'=119 +'PRECEEDING'=189 +'CONSTRAINT'=298 +'AUTHORIZATION'=281 +'NONE'=367 +'PCTINCREASE'=380 +'TRIGGERS'=427 +'ONLINE'=242 +'SQL'=410 +'SEQUENCE'=406 +'OVER'=187 +'SCN'=403 +'COLUMN'=204 +'SCHEMA'=402 +'USING'=69 +'CHECKPOINT'=293 +'DUMP'=313 +'FOR'=140 +'DEFAULT'=210 +'FIRST'=148 +'RESOURCE'=249 +'EXCEPT'=318 +'DATAFILE'=306 +'FIRST_VALUE'=157 +'CROSS'=70 +'MAIN'=130 +'MAXLOGHISTORY'=353 +'ROLLUP'=85 +'PRIOR'=97 +'CHECK'=202 +'INSERT'=225 +'NOARCHIVELOG'=363 +'USE'=431 +'STORAGE'=417 +'REFERENCE'=126 +'AND'=90 +'LOCK'=230 +'RULES'=132 +'UID'=264 +'KEEP'=121 +'IN'=101 +'MEASURES'=131 +'STDDEV_SAMP'=181 +'LOGFILE'=347 +'SQLSTATE'=413 +'DELETE'=211 +'NOCOMPRESS'=237 +'CUME_DIST'=155 +'NOMAXVALUE'=365 +'from'=9 Added: branches/tora-trotl/sandbox/input =================================================================== --- branches/tora-trotl/sandbox/input (rev 0) +++ branches/tora-trotl/sandbox/input 2010-05-19 21:30:44 UTC (rev 3527) @@ -0,0 +1,28 @@ +WITH +X1 AS (SELECT MAX(Y1) FROM KLM1), +X2 AS (SELECT MAX(Y2) FROM KLM2), +X3 AS (SELECT MAX(Y3) FROM KLM3), +X4 AS (SELECT MAX(Y4) FROM KLM4) +SELECT + DISTINCT + -1, + +1, + A + B * (A * D) AS, + T1.REGION_NAME, + T2.DIVISION_NAME, + T1.REGION_NAME AS A, + T2.DIVISION_NAME AS, + *, + A.*, + SUM(T3.AMOUNT), + SUM(COUNT(1)) + COUNT(*) + , SUM(1) + (SELECT COUNT(1) FROM DDD) A +FROM DUAL, FFF +WHERE A IS NULL +OR B IS NOT NULL +AND ( A LIKE 'D') +AND 1 = 0 +AND A.B.C IS A SET +UNION +SELECT A FROM DUAL + Added: branches/tora-trotl/sandbox/input.model.1.test =================================================================== --- branches/tora-trotl/sandbox/input.model.1.test (rev 0) +++ branches/tora-trotl/sandbox/input.model.1.test 2010-05-19 21:30:44 UTC (rev 3527) @@ -0,0 +1,16 @@ +SELECT COUNTRY,PROD,YEAR,S +FROM SALES_VIEW_REF +MODEL +PARTITION BY (COUNTRY) +DIMENSION BY (PROD, YEAR) +MEASURES (SALE S) +IGNORE NAV +-- cell_reference_options +UNIQUE DIMENSION +-- here starts model_rules_clause +RULES UPSERT SEQUENTIAL ORDER +( +S[PROD='Mouse Pad', YEAR=2001] = S['Mouse Pad', 1999] + S['Mouse Pad', 2000], +S['Standard Mouse', 2002] = S['Standard Mouse', 2001] +) +ORDER BY COUNTRY, PROD, YEAR Added: branches/tora-trotl/sandbox/main.c =================================================================== --- branches/tora-trotl/sandbox/main.c (rev 0) +++ branches/tora-trotl/sandbox/main.c 2010-05-19 21:30:44 UTC (rev 3527) @@ -0,0 +1,308 @@ +// Example of a grammar for a trivial tree parser. +// Adapted from Java equivalent example, by Terence Parr +// Author: Jim Idle - April 2007 +// Permission is granted to use this example code in any way you want, so long as +// all the original authors are cited. +// + +// set ts=4,sw=4 +// Tab size is 4 chars, indent is 4 chars + +// Notes: Although all the examples provided are configured to be built +// by Visual Studio 2005, based on the custom build rules +// provided in $(ANTLRSRC)/code/antlr/main/runtime/C/vs2005/rulefiles/antlr3.rules +// there is no reason that this MUST be the case. Provided that you know how +// to run the antlr tool, then just compile the resulting .c files and this +// file together, using say gcc or whatever: gcc *.c -I. -o XXX +// The C code is generic and will compile and run on all platforms (please +// report any warnings or errors to the antlr-interest newsgroup (see www.antlr.org) +// so that they may be corrected for any platform that I have not specifically tested. +// +// The project settings such as additional library paths and include paths have been set +// relative to the place where this source code sits on the ANTLR perforce system. You +// may well need to change the settings to locate the includes and the lib files. UNIX +// people need -L path/to/antlr/libs -lantlr3c (release mode) or -lantlr3cd (debug) +// +// Jim Idle (jimi cut-this at idle ws) +// + +// You may adopt your own practices by all means, but in general it is best +// to create a single include for your project, that will include the ANTLR3 C +// runtime header files, the generated header files (all of which are safe to include +// multiple times) and your own project related header files. Use <> to include and +// -I on the compile line (which vs2005 now handles, where vs2003 did not). +// +#include "SELECT_SIMPLELexer.h" +#include "SELECT_SIMPLEParser.h" + +// Main entry point for this example +// +int ANTLR3_CDECL +main (int argc, char *argv[]) +{ + // Now we declare the ANTLR related local variables we need. + // Note that unless you are convinced you will never need thread safe + // versions for your project, then you should always create such things + // as instance variables for each invocation. + // ------------------- + + // Name of the input file. Note that we always use the abstract type pANTLR3_UINT8 + // for ASCII/8 bit strings - the runtime library guarantees that this will be + // good on all platforms. This is a general rule - always use the ANTLR3 supplied + // typedefs for pointers/types/etc. + // + pANTLR3_UINT8 fName; + + // The ANTLR3 character input stream, which abstracts the input source such that + // it is easy to provide input from different sources such as files, or + // memory strings. + // + // For an ASCII/latin-1 memory string use: + // input = antlr3NewAsciiStringInPlaceStream (stringtouse, (ANTLR3_UINT64) length, NULL); + // + // For a UCS2 (16 bit) memory string use: + // input = antlr3NewUCS2StringInPlaceStream (stringtouse, (ANTLR3_UINT64) length, NULL); + // + // For input from a file, see code below + // + // Note that this is essentially a pointer to a structure containing pointers to functions. + // You can create your own input stream type (copy one of the existing ones) and override any + // individual function by installing your own pointer after you have created the standard + // version. + // + pANTLR3_INPUT_STREAM input; + + // The lexer is of course generated by ANTLR, and so the lexer type is not upper case. + // The lexer is supplied with a pANTLR3_INPUT_STREAM from whence it consumes its + // input and generates a token stream as output. + // + pSELECT_SIMPLELexer lxr; + + // The token stream is produced by the ANTLR3 generated lexer. Again it is a structure based + // API/Object, which you can customise and override methods of as you wish. a Token stream is + // supplied to the generated parser, and you can write your own token stream and pass this in + // if you wish. + // + pANTLR3_COMMON_TOKEN_STREAM tstream; + + // The Lang parser is also generated by ANTLR and accepts a token stream as explained + // above. The token stream can be any source in fact, so long as it implements the + // ANTLR3_TOKEN_SOURCE interface. In this case the parser does not return anything + // but it can of course specify any kind of return type from the rule you invoke + // when calling it. + // + pSELECT_SIMPLEParser psr; + + // The parser produces an AST, which is returned as... [truncated message content] |