[OLINGO-63] Improve-Lexer-Modes

This commit is contained in:
Sven Kobler 2013-12-02 10:54:53 +01:00 committed by Stephan Klevenz
parent 5e10653b1f
commit 2e622040d1
10 changed files with 564 additions and 642 deletions

View File

@ -57,6 +57,5 @@ public interface EdmEntityContainer extends EdmNamed {
* @return {@link EdmFunctionImport}
*/
EdmFunctionImport getFunctionImport(String name);
EdmNamed getElement(String odataIdentifier);
}

View File

@ -126,9 +126,4 @@ public class EdmEntityContainerImpl extends EdmNamedImpl implements EdmEntityCon
return functionImport;
}
@Override
public EdmNamed getElement(final String odataIdentifier) {
return null;
}
}

View File

@ -18,26 +18,32 @@
******************************************************************************/
lexer grammar UriLexer;
//;==============================================================================
// Mode "DEFAULT_MODE": Processes everything bevor the first '?' char
// On '?' the next mode "MODE_QUERY" is used
// The percent encoding rules a defined in RFC3986 ABNF rule "path-rootless" apply
//;==============================================================================
QM : '?' -> pushMode(MODE_QUERY);
QM : '?' -> pushMode(MODE_QUERY); //first query parameter
AMP : '&' -> pushMode(MODE_QUERY); //more query parameters
STRING : '\'' -> more, pushMode(MODE_ODATA_STRING);
GEOGRAPHY : G E O G R A P H Y SQUOTE -> pushMode(MODE_ODATA_GEO); //TODO make case insensitive
GEOMETRY : G E O M E T R Y SQUOTE -> pushMode(MODE_ODATA_GEO);
//Letters for case insensitivity
fragment A : 'A'|'a';
fragment B : 'B'|'b';
fragment D : 'D'|'d';
fragment E : 'E'|'e';
fragment F : 'F'|'f';
fragment G : 'G'|'g';
fragment H : 'H'|'h';
fragment I : 'I'|'i';
fragment L : 'L'|'l';
fragment M : 'M'|'m';
fragment N : 'N'|'n';
fragment O : 'O'|'o';
fragment P : 'P'|'p';
fragment R : 'R'|'r';
fragment S : 'S'|'s';
fragment T : 'T'|'t';
@ -45,6 +51,24 @@ fragment U : 'U'|'u';
fragment Y : 'Y'|'y';
fragment Z : 'Z'|'z';
//special chars
OPEN : '(' | '%28';
CLOSE : ')' | '%29';
COMMA : ',' | '%2C';
SLASH : '/';
POINT : '.';
AT : '@';
EQ : '=' ;
STAR : '*';
SEMI : ';';
FRAGMENT : '#';
EQ_sq : '=' -> type(EQ);
AMP_sq : '&' -> type(AMP), popMode;
fragment WS : ( ' ' | '%09' | '%20' | '%09' );
WSP : WS+;
//alpha stuff
fragment ALPHA : 'a'..'z' | 'A'..'Z';
fragment ALPHA_A_TO_F : 'a'..'f' | 'A'..'F';
fragment DIGIT : '0'..'9';
@ -53,7 +77,18 @@ fragment HEXDIG : DIGIT | ALPHA_A_TO_F;
fragment ODI_LEADINGCHARACTER : ALPHA | '_'; //TODO; add Unicode characters from the categories L or Nl
fragment ODI_CHARACTER : ALPHA | '_' | DIGIT; //TODO; add Unicode characters from the categories L, Nl, Nd, Mn, Mc, Pc, or Cf
//helper for date/time values
fragment ONE_TO_NINE : '1'..'9';
fragment ZERO_TO_FIFTYNINE : ('0'..'5') DIGIT;
fragment FRACTIONALSECONDS : DIGIT+;
fragment SECOND : ZERO_TO_FIFTYNINE;
fragment MINUTE : ZERO_TO_FIFTYNINE;
fragment HOUR : ('0' | '1') DIGIT | '2' ( '0'..'3');
fragment DAY : '0' '1'..'9' | ('1'|'2') DIGIT | '3' ('0'|'1');
fragment MONTH : '0' ONE_TO_NINE | '1' ( '0' | '1' | '2' );
fragment YEAR : ('-')? ( '0' DIGIT DIGIT DIGIT | ONE_TO_NINE DIGIT DIGIT DIGIT );
//tag start with $
BATCH : '$batch';
ENTITY : '$entity';
METADATA : '$metadata';
@ -65,37 +100,29 @@ VALUE : '$value';
REF : '$ref';
COUNT : '$count';
//inlined query parameters ( e.g. $skip)
SKIP_INLINE : '$skip';
FILTER_INLINE : '$filter';
ORDERBY_INLINE: '$orderby';
SEARCH_INLINE : '$search'-> pushMode(MODE_SYSTEM_QUERY_SEARCH);
//rest
NULLVALUE : 'null';
OPEN : '(' | '%28';
CLOSE : ')' | '%29';
COMMA : ',' | '%2 SLASH_sqpC';
SLASH : '/';
POINT : '.';
AT : '@';
EQ : '=' ;
TRUE : 'true';
FALSE : 'false';
BOOLEAN : T R U E | F A L S E;
SIGN : '+' | '%2B' |'-';
PLUS : '+';
SIGN : PLUS | '%2B' |'-';
INT : SIGN? DIGITS;
DECIMAL : INT '.' DIGITS ('e' SIGN? DIGITS)?;
//primary types
BINARY : ('X'| B I N A R Y) SQUOTE (HEXDIG HEXDIG)* SQUOTE; //TODO remove 'x' here and in unit tests
fragment ONE_TO_NINE : '1'..'9';
fragment ZERO_TO_FIFTYNINE : ('0'..'5') DIGIT;
fragment FRACTIONALSECONDS : DIGIT+;
fragment SECOND : ZERO_TO_FIFTYNINE;
fragment MINUTE : ZERO_TO_FIFTYNINE;
fragment HOUR : ('0' | '1') DIGIT | '2' ( '0'..'3');
fragment DAY : '0' '1'..'9' | ('1'|'2') DIGIT | '3' ('0'|'1');
fragment MONTH : '0' ONE_TO_NINE | '1' ( '0' | '1' | '2' );
fragment YEAR : ('-')? ( '0' DIGIT DIGIT DIGIT | ONE_TO_NINE DIGIT DIGIT DIGIT );
BINARY : B I N A R Y SQUOTE (HEXDIG HEXDIG)* SQUOTE;
DATE : D A T E SQUOTE YEAR '-' MONTH '-' DAY SQUOTE;
DATETIMEOFFSET : D A T E T I M E O F F S E T SQUOTE YEAR '-' MONTH '-' DAY T HOUR ':' MINUTE ( ':' SECOND ( '.' FRACTIONALSECONDS )? )? ( Z | SIGN HOUR ':' MINUTE ) SQUOTE;
fragment DUSECONDFRAG : DIGITS ('.' DIGITS)? 'S';
fragment DUTIMEFRAG : 'T' (
( DIGITS 'H' (DIGITS 'M')? DUSECONDFRAG?)
@ -105,7 +132,6 @@ fragment DUTIMEFRAG : 'T' (
fragment DUDAYTIMEFRAG : DIGITS 'D' DUTIMEFRAG? | DUTIMEFRAG;
DURATION : D U R A T I O N SQUOTE '-'? 'P' DUDAYTIMEFRAG SQUOTE;
TIMEOFDAY : T I M E O F D A Y SQUOTE HOUR ':' MINUTE ( ':' SECOND ( '.' FRACTIONALSECONDS )? )? SQUOTE;
fragment GUIDVALUE : HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG'-'
HEXDIG HEXDIG HEXDIG HEXDIG '-'
HEXDIG HEXDIG HEXDIG HEXDIG '-'
@ -113,8 +139,85 @@ fragment GUIDVALUE : HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG H
HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG;
GUID : G U I D SQUOTE GUIDVALUE SQUOTE;
ODATAIDENTIFIER : ODI_LEADINGCHARACTER (ODI_CHARACTER)*;
//expression tokens
ASC : 'asc';
DESC : 'desc';
MUL : 'mul';
DIV : 'div';
MOD : 'mod';
ADD : 'add';
SUB : 'sub';
GT : 'gt';
GE : 'ge';
LT : 'lt';
LE : 'le';
EQ_ALPHA : 'eq';
NE : 'ne';
AND : 'and';
OR : 'or';
ISOF : 'isof';
NOT : 'not';
MINUS :'-';
ROOT : '$root/';
NANINFINITY : 'NaN' | '-INF' | 'INF';
IMPLICIT_VARIABLE_EXPR : '$it';
LEVELS : '$levels';
CONTAINS_WORD : 'contains(';
STARTSWITH_WORD : 'startswith(';
ENDSWITH_WORD : 'endswith(';
LENGTH_WORD : 'length(';
INDEXOF_WORD : 'indexof(';
SUBSTRING_WORD : 'substring(';
TOLOWER_WORD : 'tolower(';
TOUPPER_WORD : 'toupper(';
TRIM_WORD : 'trim(';
CONCAT_WORD : 'concat(';
YEAR_WORD : 'year(';
MONTH_WORD : 'month(';
DAY_WORD : 'day(';
HOUR_WORD : 'hour(';
MINUTE_WORD : 'minute(';
SECOND_WORD : 'second(';
FRACTIONALSECONDS_WORD : 'fractionalseconds(';
TOTALSECONDS_WORD : 'totalseconds(';
DATE_WORD : 'date(';
TIME_WORD : 'time(';
TOTALOFFSETMINUTES_WORD : 'totaloffsetminutes(';
MINDATETIME_WORD : 'mindatetime(';
MAXDATETIME_WORD : 'maxdatetime(';
NOW_WORD : 'now(';
ROUND_WORD : 'round(';
FLOOR_WORD : 'floor(';
CEILING_WORD : 'ceiling(';
GEO_DISTANCE_WORD : 'geo.distance(';
GEO_LENGTH_WORD : 'geo.length(';
GEO_INTERSECTS_WORD : 'geo.intersects(';
ISOF_WORD : 'isof(';
CAST_WORD : 'cast(';
COLLECTION_REF : 'Collection($ref)';
COLLECTION_ENTITY_TYPE : 'Collection(Edm.EntityType)';
COLLECTION_COMPLEX_TYPE : 'Collection(Edm.ComplexType)';
COLLECTION : 'Collection(' -> type(COLLECTION);
//used in fragment only
DELETED_ENTITY : '$deletedEntity';
LINK : '$link';
DELETED_LINK : '$deletedLink';
DELTA : '$delta';
//ENTITY_IN_FRAGMENT : '/$entity';
LEVELSMAX : '$levels=max';
//ODI
ODATAIDENTIFIER : ODI_LEADINGCHARACTER (ODI_CHARACTER)*;
//;==============================================================================
// Mode "QUERY": Processes everything between the first '?' and the '#' char
@ -123,56 +226,31 @@ ODATAIDENTIFIER : ODI_LEADINGCHARACTER (ODI_CHARACTER)*;
mode MODE_QUERY;
//;==============================================================================
FRAGMENT : '#' -> pushMode(MODE_FRAGMENT);
FILTER : '$filter' -> pushMode(MODE_SYSTEM_QUERY);
ORDERBY : '$orderby' -> pushMode(MODE_SYSTEM_QUERY);
EXPAND : '$expand' -> pushMode(MODE_SYSTEM_QUERY);
SELECT : '$select' -> pushMode(MODE_SYSTEM_QUERY);
SKIP : '$skip' -> pushMode(MODE_SYSTEM_QUERY);
TOP : '$top' -> pushMode(MODE_SYSTEM_QUERY);
LEVELS : '$levels' -> pushMode(MODE_SYSTEM_QUERY);
FRAGMENT_q : '#' -> type(FRAGMENT);
FILTER : '$filter' -> pushMode(DEFAULT_MODE);
ORDERBY : '$orderby' -> pushMode(DEFAULT_MODE);
EXPAND : '$expand' -> pushMode(DEFAULT_MODE);
SELECT : '$select' -> pushMode(DEFAULT_MODE);
SKIP : '$skip' -> pushMode(DEFAULT_MODE);
SKIPTOKEN : '$skiptoken' -> pushMode(MODE_SYSTEM_QUERY_REST_QCHAR_NO_AMP);
TOP : '$top' -> pushMode(DEFAULT_MODE);
LEVELS_q : '$levels' -> type(LEVELS), pushMode(DEFAULT_MODE);
FORMAT : '$format' -> pushMode(MODE_SYSTEM_QUERY_PCHAR);
COUNT_q : '$count' -> type(COUNT), pushMode(MODE_SYSTEM_QUERY);
COUNT_q : '$count' -> type(COUNT), pushMode(DEFAULT_MODE);
REF_q : '$ref' -> type(REF);
VALUE_q : '$value' -> type(VALUE);
ID : '$id'-> pushMode(MODE_SYSTEM_QUERY_REST_QCHAR_NO_AMP);
SKIPTOKEN : '$skiptoken' -> pushMode(MODE_SYSTEM_QUERY_REST_QCHAR_NO_AMP);
SEARCH : '$search'-> pushMode(MODE_SYSTEM_QUERY_SEARCH);
GEOGRAPHY : G_q E_q O_q G_q R_q A_q P_q H_q Y_q -> pushMode(MODE_ODATA_GEO);//TODO make case insensitive
GEOMETRY : G_q E_q O_q M_q E_q T_q R_q Y_q -> pushMode(MODE_ODATA_GEO);
fragment A_q : 'A'|'a';
fragment E_q : 'E'|'e';
fragment G_q : 'G'|'g';
fragment H_q : 'H'|'h';
fragment M_q : 'M'|'m';
fragment O_q : 'O'|'o';
fragment P_q : 'P'|'p';
fragment R_q : 'R'|'r';
fragment S_q : 'S'|'s';
fragment T_q : 'T'|'t';
fragment Y_q : 'Y'|'y';
fragment ALPHA_q : 'a'..'z'|'A'..'Z';
fragment A_TO_F_q : 'a'..'f'|'A'..'F';
fragment DIGIT_q : '0'..'9';
fragment HEXDIG_q : DIGIT_q | A_TO_F_q;
fragment PCT_ENCODED_q : '%' HEXDIG_q HEXDIG_q;
fragment UNRESERVED_q : ALPHA_q | DIGIT_q | '-' |'.' | '_' | '~';
fragment OTHER_DELIMS_q : '!' | '(' | ')' | '*' | '+' | ',' | ';';
fragment QCHAR_NO_AMP_q : UNRESERVED_q | PCT_ENCODED_q | OTHER_DELIMS_q | ':' | '@' | '/' | '?' | '$' | '\'' | '=';
fragment QCHAR_NO_AMP_EQ_q : UNRESERVED_q | PCT_ENCODED_q | OTHER_DELIMS_q | ':' | '@' | '/' | '?' | '$' | '\'';
fragment QCHAR_NO_AMP_EQ_AT_DOLLAR_q : UNRESERVED_q | PCT_ENCODED_q | OTHER_DELIMS_q | ':' | '/' | '?' | '\'';
EQ_q : '=' -> type(EQ);
AMP : '&';
AMP_q : '&' -> type(AMP);
CUSTOMNAME : QCHAR_NO_AMP_EQ_AT_DOLLAR_q QCHAR_NO_AMP_EQ_q*;
CUSTOMVALUE : QCHAR_NO_AMP_EQ_q+;
CUSTOMNAME : ~[&=@$] ~[&=]*;
CUSTOMVALUE : ~[&=]+;
//;==============================================================================
mode MODE_SYSTEM_QUERY_PCHAR;
@ -206,6 +284,9 @@ EQ_sqp : '=' -> type(EQ);
mode MODE_SYSTEM_QUERY_REST_QCHAR_NO_AMP;
//;==============================================================================
AMP_sqr : '&' -> type(AMP), popMode;
FRAGMENT_sqr : '#' -> popMode;
/*
fragment ALPHA_sqr : 'a'..'z'|'A'..'Z';
fragment A_TO_F_sqr : 'a'..'f'|'A'..'F';
fragment DIGIT_sqr : '0'..'9';
@ -215,13 +296,11 @@ fragment UNRESERVED_sqr : ALPHA_sqr | DIGIT_sqr | '-' |'.' | '_' | '~';
fragment OTHER_DELIMS_sqr : '!' | '(' | ')' | '*' | '+' | ',' | ';';
fragment QCHAR_NO_AMP_sqr : UNRESERVED_sqr | PCT_ENCODED_sqr | OTHER_DELIMS_sqr | ':' | '@' | '/' | '?' | '$' | '\'' | '=';
fragment QCHAR_NO_AMP_EQ_sqr : UNRESERVED_sqr | PCT_ENCODED_sqr | OTHER_DELIMS_sqr | ':' | '@' | '/' | '?' | '$' | '\'' ;
*/
//REST : ~[&#]*;
AMP_sqr : '&' -> type(AMP), popMode;
EQ_sqr : '=' -> type(EQ);
FRAGMENT_sqr : '#' -> popMode;
REST : QCHAR_NO_AMP_EQ_sqr QCHAR_NO_AMP_sqr*;
REST : ~[&#=] ~[&#]*;
//;==============================================================================
@ -248,207 +327,15 @@ SEARCHPHRASE : QUOTATION_MARK /*QCHAR_NO_AMP_DQUOTE+*/ ~[&"]* QUOTATION_M
//;==============================================================================
mode MODE_SYSTEM_QUERY;
mode MODE_ODATA_STRING;
//;==============================================================================
fragment SQUOTE_sq : '\'' -> type(SQUOTE);
STRING_sq : SQUOTE_sq -> more, pushMode(MODE_ODATA_STRING);
GEOGRAPHY_sq : G_sq E_sq O_sq G_sq R_sq A_sq P_sq H_sq Y SQUOTE_sq -> type(GEOGRAPHY), pushMode(MODE_ODATA_GEO); //TODO make case insensitive
GEOMETRY_sq : G_sq E_sq O_sq M_sq E_sq T_sq R_sq Y_sq SQUOTE_sq -> type(GEOMETRY),pushMode(MODE_ODATA_GEO);
fragment A_sq : 'A'|'a';
fragment B_sq : 'B'|'b';
fragment D_sq : 'D'|'d';
fragment E_sq : 'E'|'e';
fragment F_sq : 'F'|'f';
fragment G_sq : 'G'|'g';
fragment H_sq : 'H'|'h';
fragment I_sq : 'I'|'i';
fragment L_sq : 'L'|'l';
fragment M_sq : 'M'|'m';
fragment N_sq : 'N'|'n';
fragment O_sq : 'O'|'o';
fragment P_sq : 'P'|'p';
fragment R_sq : 'R'|'r';
fragment S_sq : 'S'|'s';
fragment T_sq : 'T'|'t';
fragment U_sq : 'U'|'u';
fragment Y_sq : 'Y'|'y';
fragment Z_sq : 'Z'|'z';
fragment ALPHA_sq : 'a'..'z'|'A'..'Z';
fragment ALPHA_A_TO_F_sq : 'a'..'f'|'A'..'F';
fragment DIGIT_sq : '0'..'9';
fragment DIGITS_sq : DIGIT_sq+;
fragment HEXDIG_sq : DIGIT_sq | ALPHA_A_TO_F_sq;
fragment ODI_LEADINGCHARACTER_sq : ALPHA_sq | '_'; //TODO; plus Unicode characters from the categories L or Nl
fragment ODI_CHARACTER_sq : ALPHA_sq | '_' | DIGIT_sq; //TODO; plus Unicode characters from the categories L, Nl, Nd, Mn, Mc, Pc, or Cf
fragment WS_sqr : ( SP_g | HTAB_g | '%20' | '%09' );
OPEN_sq : ('(' | '%28') -> type(OPEN);
CLOSE_sq : (')' | '%29') -> type(CLOSE);
COMMA_sq : (',' | '%2C') -> type(COMMA);
SLASH_sq : '/' -> type(SLASH);
POINT_sq : '.' -> type(POINT);
AT_sq : '@' -> type(AT);
STAR : '*';
SEMI_sq : ';' -> type(SEMI);
EQ_sq : '=' -> type(EQ);
AMP_sq : '&' -> type(AMP), popMode;
WSP_sqr : WS_sqr+ -> type(WSP);
NULLVALUE_sq : 'null' -> type(NULLVALUE);
TRUE : 'true';
FALSE : 'false';
BOOLEAN_sq : (T_sq R_sq U_sq E_sq | F_sq A_sq L_sq S_sq E_sq) -> type(BOOLEAN);
SIGN_sq : ('+' | '%2B' |'-') -> type(SIGN);
INT_sq : SIGN_sq? DIGITS_sq -> type(INT);
DECIMAL_sq : INT_sq '.' DIGITS_sq ('e' SIGN_sq? DIGITS_sq)? -> type(DECIMAL);
BINARY_sq : ('X'| B_sq I_sq N_sq A_sq R_sq Y_sq) SQUOTE_sq (HEXDIG_sq HEXDIG_sq)* SQUOTE_sq -> type(BINARY);
ASC : 'asc';
DESC : 'desc';
MUL : 'mul';
DIV : 'div';
MOD : 'mod';
ADD : 'add';
SUB : 'sub';
GT : 'gt';
GE : 'ge';
LT : 'lt';
LE : 'le';
EQ_ALPHA : 'eq';
NE : 'ne';
AND : 'and';
OR : 'or';
ISOF : 'isof';
NOT : 'not';
MINUS :'-';
ROOT : '$root/';
NANINFINITY : 'NaN' | '-INF' | 'INF';
fragment ONE_TO_NINE_sq : '1'..'9';
fragment ZERO_TO_FIFTYNINE_sq : ('0'..'5') DIGIT_sq;
fragment FRACTIONALSECONDS_sq : DIGIT_sq+;
fragment SECOND_sq : ZERO_TO_FIFTYNINE_sq;
fragment MINUTE_sq : ZERO_TO_FIFTYNINE_sq;
fragment HOUR_sq : ('0' | '1') DIGIT_sq | '2' ( '0'..'3');
fragment DAY_sq : '0' '1'..'9' | ('1'|'2') DIGIT_sq | '3' ('0'|'1');
fragment MONTH_sq : '0' ONE_TO_NINE_sq | '1' ( '0' | '1' | '2' );
fragment YEAR_sq : ('-')? ( '0' DIGIT_sq DIGIT_sq DIGIT_sq | ONE_TO_NINE DIGIT_sq DIGIT_sq DIGIT_sq );
DATE_sq : D_sq A_sq T_sq E_sq SQUOTE_sq YEAR_sq '-' MONTH_sq '-' DAY_sq SQUOTE_sq -> type(DATE);
DATETIMEOFFSET_sq : D_sq A_sq T_sq E_sq T_sq I_sq M_sq E_sq O_sq F_sq F_sq S_sq E_sq T_sq SQUOTE_sq YEAR_sq '-' MONTH_sq '-' DAY_sq T_sq HOUR_sq ':' MINUTE_sq ( ':' SECOND_sq ( '.' FRACTIONALSECONDS_sq )? )? ( Z_sq | SIGN_sq HOUR_sq ':' MINUTE_sq ) SQUOTE_sq -> type(DATETIMEOFFSET);
fragment DUSECONDFRAG_sq : DIGITS_sq ('.' DIGITS_sq)? 'S';
fragment DUTIMEFRAG_sq : 'T' (
( DIGITS_sq 'H' (DIGITS_sq 'M')? DUSECONDFRAG_sq?)
| (DIGITS_sq 'M' DUSECONDFRAG_sq?)
| DUSECONDFRAG_sq
);
fragment DUDAYTIMEFRAG_sq : DIGITS 'D' DUTIMEFRAG? | DUTIMEFRAG;
DURATION_sq : D_sq U_sq R_sq A_sq T_sq I_sq O_sq N_sq SQUOTE_sq '-'? 'P' DUDAYTIMEFRAG_sq SQUOTE_sq -> type(DURATION);
TIMEOFDAY_sq : T_sq I_sq M_sq E_sq O_sq F_sq D_sq A_sq Y_sq SQUOTE_sq HOUR_sq ':' MINUTE_sq ( ':' SECOND_sq ( '.' FRACTIONALSECONDS_sq )? )? SQUOTE_sq -> type(TIMEOFDAY);
GUID_sq : G_sq U_sq I_sq D_sq SQUOTE_sq GUIDVALUE_sq SQUOTE_sq -> type(GUID);
fragment GUIDVALUE_sq : HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq'-'
HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq '-'
HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq '-'
HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq '-'
HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq HEXDIG_sq;
fragment PCT_ENCODED_sq : '%' HEXDIG_sq HEXDIG_sq;
fragment UNRESERVED_sq : ALPHA_sq | DIGIT_sq | '-' |'.' | '_' | '~';
fragment OTHER_DELIMS_sq : '!' | '(' | ')' | '*' | '+' | ',' | ';';
fragment QCHAR_NO_AMP_sq : UNRESERVED_sq | PCT_ENCODED_sq | OTHER_DELIMS_sq | ':' | '@' | '/' | '?' | '$' | '\'' | '=';
IMPLICIT_VARIABLE_EXPR : '$it';
REF_sq : '$ref' -> type(REF);
LEVELS_sq : '$levels' -> type(LEVELS);
CONTAINS_WORD : 'contains(';
STARTSWITH_WORD : 'startswith(';
ENDSWITH_WORD : 'endswith(';
LENGTH_WORD : 'length(';
INDEXOF_WORD : 'indexof(';
SUBSTRING_WORD : 'substring(';
TOLOWER_WORD : 'tolower(';
TOUPPER_WORD : 'toupper(';
TRIM_WORD : 'trim(';
CONCAT_WORD : 'concat(';
YEAR_WORD : 'year(';
MONTH_WORD : 'month(';
DAY_WORD : 'day(';
HOUR_WORD : 'hour(';
MINUTE_WORD : 'minute(';
SECOND_WORD : 'second(';
FRACTIONALSECONDS_WORD : 'fractionalseconds(';
TOTALSECONDS_WORD : 'totalseconds(';
DATE_WORD : 'date(';
TIME_WORD : 'time(';
TOTALOFFSETMINUTES_WORD : 'totaloffsetminutes(';
MINDATETIME_WORD : 'mindatetime(';
MAXDATETIME_WORD : 'maxdatetime(';
NOW_WORD : 'now(';
ROUND_WORD : 'round(';
FLOOR_WORD : 'floor(';
CEILING_WORD : 'ceiling(';
GEO_DISTANCE_WORD : 'geo.distance(';
GEO_LENGTH_WORD : 'geo.length(';
GEO_INTERSECTS_WORD : 'geo.intersects(';
ISOF_WORD : 'isof(';
CAST_WORD : 'cast(';
LEVELSMAX : '$levels=max';
SKIP_sq : '$skip' -> type(SKIP);
COUNT_sq : '$count' -> type(COUNT);
FILTER_sq : '$filter' -> type(FILTER);
SEARCH_sq : '$search' -> type(SEARCH), pushMode(MODE_SYSTEM_QUERY_SEARCH);
//IRI_IN_QUERY : /*EQ*/ QCHAR_NO_AMP_sq*;
ODATAIDENTIFIER_sq : ODI_LEADINGCHARACTER_sq (ODI_CHARACTER_sq)* ->type(ODATAIDENTIFIER);
//;==============================================================================
// Mode "QUERY": Processes everything after the '#' char
// The percent encoding rules a defined in RFC3986 ABNF rule "fragment" apply
//;==============================================================================
mode MODE_FRAGMENT;
TMP_FRAGMENT : 'TMP_FRAGMENT';
//;==============================================================================
//;==============================================================================
mode MODE_ODATA_STRING;//2
fragment COMMA_s : ',' | '%2C';
fragment ALPHA_s : 'a'..'z'|'A'..'Z';
fragment ALPHA_A_TO_F_s : 'a'..'f'|'A'..'F';
fragment DIGIT_s : '0'..'9';
fragment HEXDIG_s : DIGIT_s | ALPHA_A_TO_F_s;
fragment UNRESERVED_s : ALPHA_s | DIGIT_s | '-' |'.' | '_' | '~';
fragment OTHER_DELIMS_s : '!' | '(' | ')' | '*' | '+' | COMMA_s | ';';
fragment PCTENCODEDnoSQUOTE_s : '%' ( '0'|'1'|'3'..'9' | ALPHA_A_TO_F_s ) HEXDIG_s | '%' '2' ( '0'..'6'|'8'|'9' | ALPHA_A_TO_F_s );
fragment PCHARnoSQUOTE_s : UNRESERVED_s| PCTENCODEDnoSQUOTE_s | OTHER_DELIMS_s | '$' | '&' | '=' | ':' | '@';
fragment SQUOTE_s : '\'';
STRING_s : ('\'\'' | PCHARnoSQUOTE_s )* SQUOTE_s -> type(STRING), popMode;
STRING_s : ('\'\'' | ~[\u0027] )* SQUOTE_s -> type(STRING), popMode;
//;==============================================================================
//;==============================================================================
mode MODE_ODATA_GEO;
//;==============================================================================
fragment C_g : 'c'|'C';
fragment D_g : 'd'|'D';
@ -469,15 +356,15 @@ fragment Y_g : 'y'|'Y';
fragment SP_g : ' ';//'\u0020'; // a simple space
fragment HTAB_g : '%09';
fragment WS_g : ( SP_g | HTAB_g | '%20' | '%09' );
fragment WS_g : ( ' ' | HTAB_g | '%20' | '%09' );
OPEN_g : ('(' | '%28') -> type(OPEN);
CLOSE_g : (')' | '%29') -> type(CLOSE);
COMMA_g : (',' | '%2C') -> type(COMMA);
WSP : WS_g+;
WSP_g : WS_g+ -> type(WSP);
POINT_g : '.' -> type(POINT);
AT_g : '@' -> type(AT);
SEMI : (';' | '%3B');
SEMI_g : (';' | '%3B') -> type(SEMI);
EQ_g : '=' -> type(EQ);
fragment DIGIT_g : '0'..'9';
@ -485,7 +372,7 @@ fragment DIGITS_g : DIGIT_g+;
SIGN_g : ('+' | '%2B' |'-') -> type(SIGN);
INT_g : SIGN_g? DIGITS_g -> type(INT);
DECIMAL_g : INT_g '.' DIGITS_g ('e' SIGN_g? DIGITS_g)? -> type(DECIMAL);
COLLECTION : C_g O_g L_g L_g E_g C_g T_g I_g O_g N_g ;
COLLECTION_g : C_g O_g L_g L_g E_g C_g T_g I_g O_g N_g -> type(COLLECTION);
LINESTRING : L_g I_g N_g E_g S_g T_g R_g I_g N_g G_g ;
MULTILINESTRING : M_g U_g L_g T_g I_g L_g I_g N_g E_g S_g T_g R_g I_g N_g G_g;
MULTIPOINT : M_g U_g L_g T_g I_g P_g O_g I_g N_g T_g ;

View File

@ -163,12 +163,12 @@ expandPathExtension : SLASH ref ( OPEN expandRefOption ( SEMI expandRefOptio
| SLASH count ( OPEN expandCountOption ( SEMI expandCountOption )* CLOSE )?
| OPEN expandOption ( SEMI expandOption )* CLOSE
;
expandCountOption : filter
| search
expandCountOption : filterInline
| searchInline
;
expandRefOption : expandCountOption
| orderby
| skip
| orderbyInline
| skipInline
| top
| inlinecount
;
@ -178,18 +178,24 @@ expandOption : expandRefOption
| LEVELS;
filter : FILTER EQ commonExpr;
filterInline : FILTER_INLINE EQ commonExpr;
orderby : ORDERBY EQ orderbyItem ( COMMA orderbyItem )*;
orderbyInline : ORDERBY_INLINE EQ orderbyItem ( COMMA orderbyItem )*;
orderbyItem : commonExpr ( WSP ( ASC | DESC ) )?;
//this is completly done in lexer grammer to avoid ambiguities with odataIdentifier and STRING
skip : SKIP EQ INT;
skipInline : SKIP_INLINE EQ INT;
top : TOP EQ INT;
format : FORMAT EQ ( ATOM | JSON | XML | PCHARS ( SLASH PCHARS)?);
inlinecount : COUNT EQ booleanNonCase;
search : SEARCH searchSpecialToken;
searchInline : SEARCH_INLINE searchSpecialToken;
searchSpecialToken : EQ WSP? searchExpr;
@ -230,18 +236,14 @@ customValue : CUSTOMVALUE;
//ps+=pathSegment (SLASH ps+=pathSegment)*
//PRIMITIVETYPENAME
contextFragment : REF
| PRIMITIVETYPENAME
| 'Collection($ref)'
| 'Collection(Edm.EntityType)'
| 'Collection(Edm.ComplexType)'
| COLLECTION_FIX OPEN ( PRIMITIVETYPENAME | namespace odataIdentifier ) CLOSE
/*| PRIMITIVETYPENAME*/
| COLLECTION_REF
| COLLECTION_ENTITY_TYPE
| COLLECTION_COMPLEX_TYPE
| COLLECTION ( /*PRIMITIVETYPENAME |*/ namespace? odataIdentifier ) CLOSE
| namespace? odataIdentifier
( '/$deletedEntity'
| '/$link'
| '/$deletedLink'
| nameValueOptList? ( SLASH namespace? odataIdentifier)* ( propertyList )? ( '/$delta' )? ( entity )?
( SLASH ( DELETED_ENTITY | LINK | DELETED_LINK )
| nameValueOptList? ( SLASH namespace? odataIdentifier)* ( propertyList )? ( SLASH DELTA) ? (SLASH ENTITY) ?
)
;
@ -249,10 +251,10 @@ propertyList : OPEN propertyListItem ( COMMA propertyListItem )* CLOSE;
propertyListItem : STAR //; all structural properties
| propertyListProperty
;
propertyListProperty : namespace? odataIdentifier ( SLASH namespace? odataIdentifier)* ( '+' )? ( propertyList)?
propertyListProperty : namespace? odataIdentifier ( SLASH namespace? odataIdentifier)* ( PLUS )? ( propertyList)?
;
entity : '/$entity';
//;------------------------------------------------------------------------------
//; 4. Expressions
//;------------------------------------------------------------------------------
@ -287,8 +289,8 @@ rootExpr : ROOT pathSegments;
memberExpr : '$it' | '$it/'? pathSegments;
anyExpr : 'any' OPEN WS* /* [ lambdaVariableExpr BWS COLON BWS lambdaPredicateExpr ] WS* */ CLOSE;
allExpr : 'all' OPEN WS* /* lambdaVariableExpr BWS COLON BWS lambdaPredicateExpr WS* */ CLOSE;
anyExpr : 'any' OPEN WSP /* [ lambdaVariableExpr BWS COLON BWS lambdaPredicateExpr ] WS* */ CLOSE;
allExpr : 'all' OPEN WSP /* lambdaVariableExpr BWS COLON BWS lambdaPredicateExpr WS* */ CLOSE;
methodCallExpr : indexOfMethodCallExpr
| toLowerMethodCallExpr
@ -326,43 +328,43 @@ methodCallExpr : indexOfMethodCallExpr
;
containsMethodCallExpr : CONTAINS_WORD WS* commonExpr WS* COMMA WS* commonExpr WS* CLOSE;
startsWithMethodCallExpr : STARTSWITH_WORD WS* commonExpr WS* COMMA WS* commonExpr WS* CLOSE;
endsWithMethodCallExpr : ENDSWITH_WORD WS* commonExpr WS* COMMA WS* commonExpr WS* CLOSE;
lengthMethodCallExpr : LENGTH_WORD WS* commonExpr WS* CLOSE;
indexOfMethodCallExpr : INDEXOF_WORD WS* commonExpr WS* COMMA WS* commonExpr WS* CLOSE;
substringMethodCallExpr : SUBSTRING_WORD WS* commonExpr WS* COMMA WS* commonExpr WS* ( COMMA WS* commonExpr WS* )? CLOSE;
toLowerMethodCallExpr : TOLOWER_WORD WS* commonExpr WS* CLOSE;
toUpperMethodCallExpr : TOUPPER_WORD WS* commonExpr WS* CLOSE;
trimMethodCallExpr : TRIM_WORD WS* commonExpr WS* CLOSE;
concatMethodCallExpr : CONCAT_WORD WS* commonExpr WS* COMMA WS* commonExpr WS* CLOSE;
containsMethodCallExpr : CONTAINS_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
startsWithMethodCallExpr : STARTSWITH_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
endsWithMethodCallExpr : ENDSWITH_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
lengthMethodCallExpr : LENGTH_WORD WSP? commonExpr WSP? CLOSE;
indexOfMethodCallExpr : INDEXOF_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
substringMethodCallExpr : SUBSTRING_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? ( COMMA WSP? commonExpr WSP? )? CLOSE;
toLowerMethodCallExpr : TOLOWER_WORD WSP? commonExpr WSP? CLOSE;
toUpperMethodCallExpr : TOUPPER_WORD WSP? commonExpr WSP? CLOSE;
trimMethodCallExpr : TRIM_WORD WSP? commonExpr WSP? CLOSE;
concatMethodCallExpr : CONCAT_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
yearMethodCallExpr : YEAR_WORD WS* commonExpr WS* CLOSE;
monthMethodCallExpr : MONTH_WORD WS* commonExpr WS* CLOSE;
dayMethodCallExpr : DAY_WORD WS* commonExpr WS* CLOSE;
hourMethodCallExpr : HOUR_WORD WS* commonExpr WS* CLOSE;
minuteMethodCallExpr : MINUTE_WORD WS* commonExpr WS* CLOSE;
secondMethodCallExpr : SECOND_WORD WS* commonExpr WS* CLOSE;
fractionalsecondsMethodCallExpr : FRACTIONALSECONDS_WORD WS* commonExpr WS* CLOSE;
totalsecondsMethodCallExpr : TOTALSECONDS_WORD WS* commonExpr WS* CLOSE;
dateMethodCallExpr : DATE_WORD WS* commonExpr WS* CLOSE;
timeMethodCallExpr : TIME_WORD WS* commonExpr WS* CLOSE;
totalOffsetMinutesMethodCallExpr : TOTALOFFSETMINUTES_WORD WS* commonExpr WS* CLOSE;
yearMethodCallExpr : YEAR_WORD WSP? commonExpr WSP? CLOSE;
monthMethodCallExpr : MONTH_WORD WSP? commonExpr WSP? CLOSE;
dayMethodCallExpr : DAY_WORD WSP? commonExpr WSP? CLOSE;
hourMethodCallExpr : HOUR_WORD WSP? commonExpr WSP? CLOSE;
minuteMethodCallExpr : MINUTE_WORD WSP? commonExpr WSP? CLOSE;
secondMethodCallExpr : SECOND_WORD WSP? commonExpr WSP? CLOSE;
fractionalsecondsMethodCallExpr : FRACTIONALSECONDS_WORD WSP? commonExpr WSP? CLOSE;
totalsecondsMethodCallExpr : TOTALSECONDS_WORD WSP? commonExpr WSP? CLOSE;
dateMethodCallExpr : DATE_WORD WSP? commonExpr WSP? CLOSE;
timeMethodCallExpr : TIME_WORD WSP? commonExpr WSP? CLOSE;
totalOffsetMinutesMethodCallExpr : TOTALOFFSETMINUTES_WORD WSP? commonExpr WSP? CLOSE;
minDateTimeMethodCallExpr : MINDATETIME_WORD WS* CLOSE;
maxDateTimeMethodCallExpr : MAXDATETIME_WORD WS* CLOSE;
nowMethodCallExpr : NOW_WORD WS* CLOSE;
minDateTimeMethodCallExpr : MINDATETIME_WORD WSP? CLOSE;
maxDateTimeMethodCallExpr : MAXDATETIME_WORD WSP? CLOSE;
nowMethodCallExpr : NOW_WORD WSP? CLOSE;
roundMethodCallExpr : ROUND_WORD WS* commonExpr WS* CLOSE;
floorMethodCallExpr : FLOOR_WORD WS* commonExpr WS* CLOSE;
ceilingMethodCallExpr : CEILING_WORD WS* commonExpr WS* CLOSE;
roundMethodCallExpr : ROUND_WORD WSP? commonExpr WSP? CLOSE;
floorMethodCallExpr : FLOOR_WORD WSP? commonExpr WSP? CLOSE;
ceilingMethodCallExpr : CEILING_WORD WSP? commonExpr WSP? CLOSE;
distanceMethodCallExpr : GEO_DISTANCE_WORD OPEN WS* commonExpr WS* COMMA WS* commonExpr WS* CLOSE;
geoLengthMethodCallExpr : GEO_LENGTH_WORD OPEN WS* commonExpr WS* CLOSE;
intersectsMethodCallExpr : GEO_INTERSECTS_WORD OPEN WS* commonExpr WS* COMMA WS* commonExpr WS* CLOSE;
distanceMethodCallExpr : GEO_DISTANCE_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
geoLengthMethodCallExpr : GEO_LENGTH_WORD WSP? commonExpr WSP? CLOSE;
intersectsMethodCallExpr : GEO_INTERSECTS_WORD WSP? commonExpr WSP? COMMA WSP? commonExpr WSP? CLOSE;
isofExpr : ISOF_WORD WS* ( commonExpr WS* COMMA WS* )? qualifiedtypename WS* CLOSE;
castExpr : CAST_WORD WS* ( commonExpr WS* COMMA WS* )? qualifiedtypename WS* CLOSE;
isofExpr : ISOF_WORD WSP? ( commonExpr WSP? COMMA WSP? )? qualifiedtypename WSP? CLOSE;
castExpr : CAST_WORD WSP? ( commonExpr WSP? COMMA WSP? )? qualifiedtypename WSP? CLOSE;
//;------------------------------------------------------------------------------
//; 5. JSON format for function parameters
@ -434,9 +436,8 @@ number_in_json : INT | DECIMAL;
//; 6. Names and identifiers
//;------------------------------------------------------------------------------
qualifiedtypename : PRIMITIVETYPENAME
| namespace odataIdentifier
| 'collection' OPEN ( PRIMITIVETYPENAME | namespace odataIdentifier ) CLOSE
qualifiedtypename : namespace odataIdentifier
| 'collection' OPEN ( namespace odataIdentifier ) CLOSE
;
namespace : (odataIdentifier POINT)+;
@ -491,7 +492,7 @@ singleEnumValue : odataIdentifier / INT;
geographyCollection : GEOGRAPHY fullCollectionLiteral SQUOTE;
fullCollectionLiteral : sridLiteral collectionLiteral;
collectionLiteral : (COLLECTION | COLLECTION_FIX) OPEN geoLiteral ( COMMA geoLiteral )* CLOSE;
collectionLiteral : (COLLECTION ) OPEN geoLiteral ( COMMA geoLiteral )* CLOSE;
geoLiteral : collectionLiteral
| lineStringLiteral

View File

@ -125,7 +125,7 @@ public class UriParserImpl {
String odataIdentifier = ""; //TODO ctx.odi.getText();
// get element "odataIdentifier" from EDM
EdmNamed edmObject = entityContainer.getElement(odataIdentifier);
EdmNamed edmObject = null;// entityContainer.getElement(odataIdentifier);
if (edmObject instanceof EdmEntitySet) {

View File

@ -346,12 +346,13 @@ public class EdmMock implements Edm {
when(container1.getFunctionImport(FUNCTION_IMPORT_ALL_LOCATIONS_NAME.getName())).thenReturn(
allLocationsFunctionImport);
when(container1.getElement(EMPLOYEES_SET_NAME.getName())).thenReturn(employeesSet);
when(container1.getElement(TEAMS_SET_NAME.getName())).thenReturn(teamsSet);
when(container1.getElement(COMPANY_SINGLETON_NAME.getName())).thenReturn(company);
when(container1.getElement(ACTION_IMPORT1_NAME.getName())).thenReturn(actionImport1);
when(container1.getElement(FUNCTION_IMPORT_MAXIMAL_AGE_NAME.getName())).thenReturn(maximalAgeFunctionImport);
/*
* when(container1.getElement(EMPLOYEES_SET_NAME.getName())).thenReturn(employeesSet);
* when(container1.getElement(TEAMS_SET_NAME.getName())).thenReturn(teamsSet);
* when(container1.getElement(COMPANY_SINGLETON_NAME.getName())).thenReturn(company);
* when(container1.getElement(ACTION_IMPORT1_NAME.getName())).thenReturn(actionImport1);
* when(container1.getElement(FUNCTION_IMPORT_MAXIMAL_AGE_NAME.getName())).thenReturn(maximalAgeFunctionImport);
*/
}
private void enhanceActionImport1() {

View File

@ -35,6 +35,7 @@ import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Recognizer;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.atn.ATNConfigSet;
import org.antlr.v4.runtime.atn.PredictionMode;
import org.antlr.v4.runtime.dfa.DFA;
@ -42,71 +43,106 @@ import org.antlr.v4.runtime.misc.Interval;
import org.apache.olingo.producer.core.uri.antlr.UriLexer;
import org.apache.olingo.producer.core.uri.antlr.UriParserParser;
import org.apache.olingo.producer.core.uri.antlr.UriParserParser.OdataRelativeUriEOFContext;
import org.apache.olingo.producer.core.uri.antlr.UriParserParser.TestContext;
/**
* @author d039346
*
*/
public class ParserValidator {
public class UriLexerTrace extends UriLexer {
ParserValidator parserValidator = null;
public UriLexerTrace(ParserValidator parserValidator, ANTLRInputStream antlrInputStream) {
super(antlrInputStream);
this.parserValidator = parserValidator;
}
@Override
public Token emit() {
Token t =
_factory.create(_tokenFactorySourcePair, _type, _text, _channel, _tokenStartCharIndex, getCharIndex() - 1,
_tokenStartLine, _tokenStartCharPositionInLine);
if (parserValidator.logLevel > 1) {
String out = String.format("%1$-" + 20 + "s", t.getText());
;
int tokenType = t.getType();
if (tokenType == -1) {
out += "-1/EOF";
} else {
out += UriLexer.tokenNames[tokenType];
}
System.out.println(out);
}
emit(t);
return t;
}
@Override
public void pushMode(int m) {
String out = UriLexer.modeNames[this._mode] + "-->";
super.pushMode(m);
out += UriLexer.modeNames[this._mode];
if (parserValidator.logLevel > 1) {
System.out.print(out + " ");
}
;
}
@Override
public int popMode() {
String out = UriLexer.modeNames[this._mode] + "-->";
int m = super.popMode();
out += UriLexer.modeNames[this._mode];
if (parserValidator.logLevel > 1) {
System.out.print(out + " ");
}
return m;
}
}
private List<Exception> exceptions = new ArrayList<Exception>();
private ParserRuleContext root;
private String input = null;
//private int exceptionOnStage = -1;
// private int exceptionOnStage = -1;
private Exception curException = null;
//private Exception curWeakException = null;
// private Exception curWeakException = null;
private boolean allowFullContext;
private boolean allowContextSensitifity;
private boolean allowAmbiguity;
private int logLevel = 0;
private int lexerLog;
private int lexerLogLevel = 0;
// private int lexerLogLevel = 0;
public ParserValidator run(String uri) {
return run(uri, false);
}
public ParserValidator runTest(String uri) {
return runTest(uri, false);
}
public ParserValidator run(String uri, boolean searchMode) {
input = uri;
if (lexerLog> 0) {
(new TokenValidator()).log(lexerLog).run(input);
if (lexerLogLevel > 0) {
(new TokenValidator()).log(lexerLogLevel).run(input);
}
root = parseInput(uri, searchMode);
root = parseInput(uri);
// LOG > 0 - Write serialized tree
if (logLevel > 0) {
System.out.println(ParseTreeSerializer.getTreeAsText(root, new UriParserParser(null).getRuleNames()));
if (root != null) {
System.out.println(ParseTreeSerializer.getTreeAsText(root, new UriParserParser(null).getRuleNames()));
} else {
System.out.println("root == null");
}
}
// reset for nest test
// reset for next test
allowFullContext = false;
allowContextSensitifity = false;
allowAmbiguity = false;
logLevel = 0;
exFirst();
return this;
}
public ParserValidator runTest(String uri, boolean searchMode) {
input = uri;
root = parseInputTest(uri, searchMode);
if (logLevel > 0) {
System.out.println(ParseTreeSerializer.getTreeAsText(root, new UriParserParser(null).getRuleNames()));
}
// reset for nest test
allowFullContext = false;
allowContextSensitifity = false;
allowAmbiguity = false;
exFirst();
// exFirst();
return this;
}
@ -115,22 +151,40 @@ public class ParserValidator {
return this;
}
/**
* Used in fast LL Parsing:
* Don't stops the parsing process when the slower full context parsing (with prediction mode SLL) is
* required
* @return
*/
public ParserValidator aFC() {
allowFullContext = true;
return this;
}
/**
* Used in fast LL Parsing:
* Allows ContextSensitifity Errors which occur often when using the slower full context parsing
* and indicate that there is a context sensitivity ( which may not be an error).
* @return
*/
public ParserValidator aCS() {
allowContextSensitifity = true;
return this;
}
/**
* Used in fast LL Parsing:
* Allows ambiguities
* @return
*/
public ParserValidator aAM() {
allowAmbiguity = true;
return this;
}
public ParserValidator isText(String expected) {
// make sure that there are no exceptions
assertEquals(null, curException);
assertEquals(0, exceptions.size());
@ -144,8 +198,9 @@ public class ParserValidator {
return this;
}
private OdataRelativeUriEOFContext parseInput(final String input, boolean searchMode) {
private OdataRelativeUriEOFContext parseInput(final String input) {
UriParserParser parser = null;
UriLexer lexer = null;
OdataRelativeUriEOFContext ret = null;
// Use 2 stage approach to improve performance
@ -156,86 +211,71 @@ public class ParserValidator {
try {
curException = null;
exceptions.clear();
parser = getNewParser(input, searchMode);
// create parser
lexer = new UriLexerTrace(this, new ANTLRInputStream(input));
parser = new UriParserParser(new CommonTokenStream(lexer));
// write single tokens to System.out
if (logLevel > 1) {
// can not be used because the listener is called bevore the mode changes
parser.addParseListener(new TokenWriter());
}
// write always a error message in case of syntax errors
parser.addErrorListener(new TraceErrorHandler<Object>());
// check error message if whether they are allowed or not
parser.addErrorListener(new ErrorCollector(this));
// Bail out of parser at first syntax error. --> procceds in catch block with step 2
parser.setErrorHandler(new BailErrorStrategy());
// User the faster LL parsing
parser.getInterpreter().setPredictionMode(PredictionMode.LL);
if (logLevel > 1) {
System.out.println("Step 1 (LL)");
}
ret = parser.odataRelativeUriEOF();
} catch (Exception ex) {
curException = ex;
//exceptionOnStage = 1;
// stage= 2
try {
// clear status
curException = null;
exceptions.clear();
parser = getNewParser(input, searchMode);
// create parser
lexer = new UriLexerTrace(this, new ANTLRInputStream(input));
parser = new UriParserParser(new CommonTokenStream(lexer));
// write single tokens to System.out
if (logLevel > 1) {
parser.addParseListener(new TokenWriter());
}
// write always a error message in case of syntax errors
parser.addErrorListener(new TraceErrorHandler<Object>());
// check error message if whether they are allowed or not
parser.addErrorListener(new ErrorCollector(this));
// Used default error strategy
parser.setErrorHandler(new DefaultErrorStrategy());
// User the slower SLL parsing
parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
if (logLevel > 1) {
System.out.println("Step 2 (SLL)");
}
ret = parser.odataRelativeUriEOF();
} catch (Exception ex1) {
curException = ex1;
//exceptionOnStage = 2;
// exceptionOnStage = 2;
}
}
return ret;
}
private TestContext parseInputTest(final String input, boolean searchMode) {
UriParserParser parser = null;
TestContext ret = null;
// Use 2 stage approach to improve performance
// see https://github.com/antlr/antlr4/issues/192
// TODO verify this
// stage= 1
try {
curException = null;
exceptions.clear();
parser = getNewParser(input, searchMode);
parser.setErrorHandler(new BailErrorStrategy());
parser.getInterpreter().setPredictionMode(PredictionMode.LL);
ret = parser.test();
} catch (Exception ex) {
curException = ex;
//exceptionOnStage = 1;
// stage= 2
try {
curException = null;
exceptions.clear();
parser = getNewParser(input, searchMode);
parser.setErrorHandler(new DefaultErrorStrategy());
parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
ret = parser.test();
} catch (Exception ex1) {
curException = ex1;
//exceptionOnStage = 2;
}
}
return ret;
}
private UriParserParser getNewParser(final String input, boolean searchMode) {
ANTLRInputStream inputStream = new ANTLRInputStream(input);
// UriLexer lexer = new UriLexer(inputStream);
UriLexer lexer = new UriLexer(inputStream);
//lexer.setInSearch(searchMode);
// lexer.removeErrorListeners();
lexer.addErrorListener(new ErrorCollector(this));
CommonTokenStream tokens = new CommonTokenStream(lexer);
UriParserParser parser = new UriParserParser(tokens);
if ((lexerLog >0 ) || (logLevel > 0)) {
parser.addParseListener(new TokenWriter());
}
parser.addErrorListener(new TraceErrorHandler<Object>());
parser.addErrorListener(new ErrorCollector(this));
return parser;
}
private static class ErrorCollector implements ANTLRErrorListener {
ParserValidator tokenValidator;
@ -250,21 +290,20 @@ public class ParserValidator {
tokenValidator.exceptions.add(e);
trace(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
fail("syntaxError"); // don't fail here we want to the error message at the caller
fail("syntaxError");
}
@Override
public void reportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, boolean exact,
BitSet ambigAlts, ATNConfigSet configs) {
if (!tokenValidator.allowAmbiguity) {
System.out.println("reportAmbiguity " +
ambigAlts + ":" + configs +
", input=" + recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex)));
printStack(recognizer);
printStack(recognizer);
fail("reportAmbiguity");
} else {
} else if (tokenValidator.logLevel > 0) {
System.out.println("allowed Ambiguity " +
ambigAlts + ":" + configs +
", input=" + recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex)));
@ -280,7 +319,7 @@ public class ParserValidator {
if (!tokenValidator.allowFullContext) {
printStack(recognizer);
fail("reportAttemptingFullContext");
} else {
} else if (tokenValidator.logLevel > 0) {
System.out.println("allowed AttemptingFullContext");
}
}
@ -291,9 +330,8 @@ public class ParserValidator {
if (!tokenValidator.allowContextSensitifity) {
printStack(recognizer);
fail("reportContextSensitivity");
} else {
} else if (tokenValidator.logLevel > 0) {
System.out.println("allowed ContextSensitivity");
}
}
@ -331,32 +369,31 @@ public class ParserValidator {
public ParserValidator exFirst() {
try {
//curWeakException = exceptions.get(0);
// curWeakException = exceptions.get(0);
} catch (IndexOutOfBoundsException ex) {
//curWeakException = null;
// curWeakException = null;
}
return this;
}
public ParserValidator exLast() {
//curWeakException = exceptions.get(exceptions.size() - 1);
// curWeakException = exceptions.get(exceptions.size() - 1);
return this;
}
public ParserValidator exAt(int index) {
try {
//curWeakException = exceptions.get(index);
// curWeakException = exceptions.get(index);
} catch (IndexOutOfBoundsException ex) {
//curWeakException = null;
// curWeakException = null;
}
return this;
}
public ParserValidator lexerlog(int i) {
this.lexerLog = i;
public ParserValidator lexerLog(int i) {
lexerLogLevel = i;
return this;
}
}

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* L icensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@ -22,15 +22,19 @@ import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.ErrorNode;
import org.antlr.v4.runtime.tree.ParseTreeListener;
import org.antlr.v4.runtime.tree.TerminalNode;
import org.apache.olingo.producer.core.uri.antlr.UriLexer;
public class TokenWriter implements ParseTreeListener {
@Override
public void visitTerminal(TerminalNode node) {
String out = String.format("%1$-" + 20 + "s", node.getText()); ;
out += UriLexer.tokenNames[node.getSymbol().getType()];
System.out.println(out);
/*String out = String.format("%1$-" + 20 + "s", node.getText()); ;
int tokenType = node.getSymbol().getType();
if (tokenType == -1 ) {
out += "-1/EOF";
} else {
out += UriLexer.tokenNames[tokenType];
}
System.out.println(out); */
}
@Override

View File

@ -55,9 +55,10 @@ public class TestLexer {
test = new TokenValidator();
}
// @Test
@Test
public void test() {
test.globalMode(UriLexer.MODE_QUERY);
test.globalMode(UriLexer.DEFAULT_MODE);
test.run("ODI?$filter=geo.distance(geometry'SRID=0;Point(142.1 64.1)',geometry'SRID=0;Point(142.1 64.1)')");
// test.log(1).run("$filter='ABC'").isText("ABC").isType(UriLexer.STRING);
// test.log(1).run("ODI?$filter=1 add 2 mul 3");
// test.log(1).run("1 + 2 + 3");
@ -137,7 +138,7 @@ public class TestLexer {
// ;------------------------------------------------------------------------------
@Test
public void testQueryExpressions() {
test.globalMode(UriLexer.MODE_SYSTEM_QUERY);
test.globalMode(UriLexer.DEFAULT_MODE);
// assertEquals("expected","actual");
test.run("$it").isText("$it").isType(UriLexer.IMPLICIT_VARIABLE_EXPR);
@ -265,20 +266,15 @@ public class TestLexer {
@Test
public void testLiteralDataValues() {
test.globalMode(UriLexer.MODE_SYSTEM_QUERY);
test.globalMode(UriLexer.DEFAULT_MODE);
// null
test.run("null").isInput().isType(UriLexer.NULLVALUE);
// binary
test.run("X'ABCD'").isInput().isType(UriLexer.BINARY);
test.run("X'ABCD'").isInput().isType(UriLexer.BINARY);
test.run("binary'ABCD'").isInput().isType(UriLexer.BINARY);
test.run("BiNaRy'ABCD'").isInput().isType(UriLexer.BINARY);
// not a binary TODO add error handling
test.run("x'ABCDA'")
.at(0).isText("x").isType(UriLexer.ODATAIDENTIFIER)
.at(1).isText("'ABCDA'").isType(UriLexer.STRING);
test.run("BiNaRy'ABCDA'")
.at(0).isText("BiNaRy").isType(UriLexer.ODATAIDENTIFIER)
.at(1).isText("'ABCDA'").isType(UriLexer.STRING);

View File

@ -41,16 +41,22 @@ public class TestParser {
test = new ParserValidator();
}
//@Test
@Test
public void test() {
String text = "ODI?$expand=*";
text = "aa";
(new TokenValidator()).log(1).run(text);
// test.log(1).run(text);
//
/*
* test.log(2).run("ODI?$filter=geo.distance("+
* "geometry'SRID=0;Point(142.1 64.1)',geometry'SRID=0;Point(142.1 64.1)')")
* .isText("odataRelativeUriEOF(odataRelativeUri("
* + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions("
* + "queryOption(systemQueryOption("
* + "filter($filter = commonExpr(methodCallExpr("
* + "distanceMethodCallExpr("
* + "geo.distance( "
* + "commonExpr(primitiveLiteral(geometryPoint(geometry' fullpointLiteral(sridLiteral(SRID = 0 ;) "
* + "pointLiteral(Point pointData(( positionLiteral(142.1 64.1) )))) '))) , "
* + "commonExpr(primitiveLiteral(geometryPoint(geometry' fullpointLiteral(sridLiteral(SRID = 0 ;) "
* + "pointLiteral(Point pointData(( positionLiteral(142.1 64.1) )))) '))) ))))))))) <EOF>)");
*/
}
// ;------------------------------------------------------------------------------
@ -277,7 +283,7 @@ public class TestParser {
+ "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption("
+ "expand($expand = expandItemList("
+ "expandItem(expandPath(odataIdentifier(ODI)) "
+ "expandPathExtension(/ ref($ref) ( expandRefOption(skip($skip = 1)) ))))))))) <EOF>)");
+ "expandPathExtension(/ ref($ref) ( expandRefOption(skipInline($skip = 1)) ))))))))) <EOF>)");
test.run("ODI?$expand=ODI/$count").isText("odataRelativeUriEOF(odataRelativeUri("
+ "resourcePath(pathSegments(pathSegment("
@ -292,7 +298,7 @@ public class TestParser {
+ "expand($expand = expandItemList("
+ "expandItem(expandPath(odataIdentifier(ODI)) expandPathExtension(/ count($count) ( "
+ "expandCountOption("
+ "filter($filter = commonExpr(primitiveLiteral(1)))) ))))))))) <EOF>)");
+ "filterInline($filter = commonExpr(primitiveLiteral(1)))) ))))))))) <EOF>)");
test.run("ODI?$expand=ODI/$count($search=\"abc\")").isText("odataRelativeUriEOF(odataRelativeUri("
+ "resourcePath(pathSegments(pathSegment("
@ -300,25 +306,25 @@ public class TestParser {
+ "expand($expand = expandItemList("
+ "expandItem(expandPath(odataIdentifier(ODI)) expandPathExtension(/ count($count) ( "
+ "expandCountOption("
+ "search($search searchSpecialToken(= searchExpr(searchPhrase(\"abc\"))))) ))))))))) <EOF>)");
+ "searchInline($search searchSpecialToken(= searchExpr(searchPhrase(\"abc\"))))) ))))))))) <EOF>)");
test.run("ODI?$expand=ODI/$ref($skip=1;$filter=true)").isText("odataRelativeUriEOF(odataRelativeUri("
+ "resourcePath(pathSegments(pathSegment("
+ "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption("
+ "expand($expand = expandItemList("
+ "expandItem(expandPath(odataIdentifier(ODI)) expandPathExtension(/ ref($ref) ( "
+ "expandRefOption(skip($skip = 1)) ; "
+ "expandRefOption(skipInline($skip = 1)) ; "
+ "expandRefOption(expandCountOption("
+ "filter($filter = commonExpr(primitiveLiteral(booleanNonCase(true)))))) ))))))))) <EOF>)");
+ "filterInline($filter = commonExpr(primitiveLiteral(booleanNonCase(true)))))) ))))))))) <EOF>)");
test.run("ODI?$expand=ODI($skip=1;$filter=true)").isText("odataRelativeUriEOF(odataRelativeUri("
+ "resourcePath(pathSegments(pathSegment("
+ "odataIdentifier(ODI)))) ? queryOptions(queryOption(systemQueryOption("
+ "expand($expand = expandItemList("
+ "expandItem(expandPath(odataIdentifier(ODI)) expandPathExtension(( "
+ "expandOption(expandRefOption(skip($skip = 1))) ; "
+ "expandOption(expandRefOption(skipInline($skip = 1))) ; "
+ "expandOption(expandRefOption(expandCountOption("
+ "filter($filter = commonExpr(primitiveLiteral(booleanNonCase(true))))))) ))))))))) <EOF>)");
+ "filterInline($filter = commonExpr(primitiveLiteral(booleanNonCase(true))))))) ))))))))) <EOF>)");
// Test parser rule filter ( more filter test in method testExpressions)
test.run("ODI?$filter=true")
@ -347,11 +353,12 @@ public class TestParser {
+ "queryOption(systemQueryOption(id($id = abc))))) <EOF>)");
// Test parser rule count
/* TODO add count to new mode based lexer
test.lexerlog(1).run("ODI?$count=true").isText("odataRelativeUriEOF(odataRelativeUri("
+ "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption("
+ "systemQueryOption("
+ "inlinecount($count = booleanNonCase(true)))))) <EOF>)");
/*
* TODO add count to new mode based lexer
* test.lexerlog(1).run("ODI?$count=true").isText("odataRelativeUriEOF(odataRelativeUri("
* + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption("
* + "systemQueryOption("
* + "inlinecount($count = booleanNonCase(true)))))) <EOF>)");
*/
test.run("ODI?$count=false").isText("odataRelativeUriEOF(odataRelativeUri("
+ "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions(queryOption("
@ -562,11 +569,6 @@ public class TestParser {
+ "queryOption(systemQueryOption(filter($filter = commonExpr("
+ "primitiveLiteral(-1.2e-3))))))) <EOF>)");
test.run("ODI?$filter=X'12AB'").isText("odataRelativeUriEOF(odataRelativeUri("
+ "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions("
+ "queryOption(systemQueryOption(filter($filter = commonExpr("
+ "primitiveLiteral(X'12AB'))))))) <EOF>)");
test.run("ODI?$filter=binary'12AB'").isText("odataRelativeUriEOF(odataRelativeUri("
+ "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions("
+ "queryOption(systemQueryOption(filter($filter = commonExpr("
@ -957,23 +959,22 @@ public class TestParser {
+ "filter($filter = commonExpr(methodCallExpr("
+ "ceilingMethodCallExpr(ceiling( commonExpr(primitiveLiteral(12.34)) ))))))))) <EOF>)");
/* TODO reenable GEOMETRY
test.run("ODI?$filter=geo.distance(geometry'SRID=0;Point(142.1 64.1)',geometry'SRID=0;Point(142.1 64.1)')")
.isText("odataRelativeUriEOF(odataRelativeUri("
+ "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions("
+ "queryOption(systemQueryOption("
+ "filter($filter = commonExpr(methodCallExpr("
+ "distanceMethodCallExpr("
+ "geo.distance( "
+ "commonExpr(primitiveLiteral(geometryPoint(geometry' fullpointLiteral(sridLiteral(SRID = 0 ;) "
+ "pointLiteral(Point pointData(( positionLiteral(142.1 64.1) )))) '))) , "
+ "commonExpr(primitiveLiteral(geometryPoint(geometry' fullpointLiteral(sridLiteral(SRID = 0 ;) "
+ "pointLiteral(Point pointData(( positionLiteral(142.1 64.1) )))) '))) ))))))))) <EOF>)");
*/
// TODO check this
/*
test.run("ODI?$filter=geo.length(geometry'SRID=0;LineString(142.1 64.1,3.14 2.78)')")
.isText("odataRelativeUriEOF(odataRelativeUri("
test.run("ODI?$filter=geo.distance(geometry'SRID=0;Point(142.1 64.1)',geometry'SRID=0;Point(142.1 64.1)')")
.isText("odataRelativeUriEOF(odataRelativeUri("
+ "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions("
+ "queryOption(systemQueryOption("
+ "filter($filter = commonExpr(methodCallExpr("
+ "distanceMethodCallExpr("
+ "geo.distance( "
+ "commonExpr(primitiveLiteral(geometryPoint(geometry' fullpointLiteral(sridLiteral(SRID = 0 ;) "
+ "pointLiteral(Point pointData(( positionLiteral(142.1 64.1) )))) '))) , "
+ "commonExpr(primitiveLiteral(geometryPoint(geometry' fullpointLiteral(sridLiteral(SRID = 0 ;) "
+ "pointLiteral(Point pointData(( positionLiteral(142.1 64.1) )))) '))) ))))))))) <EOF>)");
// TODO check this
/*
* test.run("ODI?$filter=geo.length(geometry'SRID=0;LineString(142.1 64.1,3.14 2.78)')")
* .isText("odataRelativeUriEOF(odataRelativeUri("
* + "resourcePath(pathSegments(pathSegment(odataIdentifier(ODI)))) ? queryOptions("
* + "queryOption(systemQueryOption(filter($filter = commonExpr(methodCallExpr("
* + "geoLengthMethodCallExpr(geo.length ( commonExpr(primitiveLiteral("
@ -1184,132 +1185,133 @@ public class TestParser {
@Test
public void testFragment() {
/*
* test.run("$metadata#Collection($ref)").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(Collection($ref))) <EOF>)");
*
* test.run("$metadata#Collection(Edm.EntityType)").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(Collection(Edm.EntityType))) <EOF>)");
*
* test.run("$metadata#Collection(Edm.ComplexType)").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(Collection(Edm.ComplexType))) <EOF>)");
*
* test.run("$metadata#singletonEntity").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(singletonEntity))) <EOF>)");
*
* test.run("$metadata#NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI))) <EOF>)");
*
* test.run("$metadata#Edm.Boolean").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(Edm.Boolean)) <EOF>)");
*
* test.run("$metadata#ODI/$deletedEntity").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) /$deletedEntity)) <EOF>)");
*
* test.run("$metadata#ODI/$link").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) /$link)) <EOF>)");
*
* test.run("$metadata#ODI/$deletedLink").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) /$deletedLink)) <EOF>)");
*
* test.run("$metadata#ODI(1)/ODI").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
* + "/ odataIdentifier(ODI))) <EOF>)");
*
* test.run("$metadata#ODI(1)/NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
* + "/ namespace(odataIdentifier(NS) .) odataIdentifier(ODI))) <EOF>)");
*
* test.run("$metadata#ODI(1)/NS.ODI/ODI").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) "
* + "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
* + "/ namespace(odataIdentifier(NS) .) odataIdentifier(ODI) "
* + "/ odataIdentifier(ODI))) <EOF>)");
*
* test.run("$metadata#NS.ODI(*)").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI) "
* + "propertyList(( propertyListItem(*) )))) <EOF>)");
*
* test.run("$metadata#ODI(1)").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) "
* + "nameValueOptList(valueOnly(( primitiveLiteral(1) ))))) <EOF>)");
*
* test.run("$metadata#ODI(1)/ODI").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) "
* + "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
* + "/ odataIdentifier(ODI))) <EOF>)");
*
* test.run("$metadata#ODI(1)/NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) "
* + "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
* + "/ namespace(odataIdentifier(NS) .) odataIdentifier(ODI))) <EOF>)");
*
* test.run("$metadata#ODI(1)/NS.ODI/ODI").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) "
* + "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
* + "/ namespace(odataIdentifier(NS) .) odataIdentifier(ODI) / odataIdentifier(ODI))) <EOF>)");
*
* test.run("$metadata#ODI(1)(*)").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) "
* + "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) propertyList(( propertyListItem(*) )))) <EOF>)");
*
* test.run("$metadata#ODI(1)(PROP)").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) "
* + "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
* + "propertyList(( propertyListItem(propertyListProperty(odataIdentifier(PROP))) )))) <EOF>)");
* test.run("$metadata#ODI(1)(NAVPROP+)").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) "
* + "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
* + "propertyList(( propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) +)) )))) <EOF>)");
* test.run("$metadata#ODI(1)(NAVPROP+(*))").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) "
* + "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
* + "propertyList(( "
* + "propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + "
* + "propertyList(( "
* + "propertyListItem(*) )))) )))) <EOF>)");
* test.run("$metadata#ODI(1)(NAVPROP+(A,B,C))").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) "
* + "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
* + "propertyList(( "
* + "propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + "
* + "propertyList(( "
* + "propertyListItem(propertyListProperty(odataIdentifier(A))) , "
* + "propertyListItem(propertyListProperty(odataIdentifier(B))) , "
* + "propertyListItem(propertyListProperty(odataIdentifier(C))) )))) )))) <EOF>)");
*
* test.run("$metadata#ODI(1)(NAVPROP+(A,B,C))/$delta").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) "
* + "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
* + "propertyList(( "
* + "propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + "
* + "propertyList(( "
* + "propertyListItem(propertyListProperty(odataIdentifier(A))) , "
* + "propertyListItem(propertyListProperty(odataIdentifier(B))) , "
* + "propertyListItem(propertyListProperty(odataIdentifier(C))) )))) )) "
* + "/$delta)) <EOF>)");
*
* test.run("$metadata#ODI(1)(NAVPROP+(A,B,C))/$entity").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) "
* + "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
* + "propertyList(( "
* + "propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + "
* + "propertyList(( "
* + "propertyListItem(propertyListProperty(odataIdentifier(A))) , "
* + "propertyListItem(propertyListProperty(odataIdentifier(B))) , "
* + "propertyListItem(propertyListProperty(odataIdentifier(C))) )))) )) "
* + "entity(/$entity))) <EOF>)");
* test.run("$metadata#ODI(1)(NAVPROP+(A,B,C))/$delta/$entity").isText("odataRelativeUriEOF(odataRelativeUri("
* + "$metadata # contextFragment(odataIdentifier(ODI) "
* + "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
* + "propertyList(( "
* + "propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + "
* + "propertyList(( "
* + "propertyListItem(propertyListProperty(odataIdentifier(A))) , "
* + "propertyListItem(propertyListProperty(odataIdentifier(B))) , "
* + "propertyListItem(propertyListProperty(odataIdentifier(C))) )))) )) "
* + "/$delta entity(/$entity))) <EOF>)");
*/
test.run("$metadata#Collection($ref)").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(Collection($ref))) <EOF>)");
test.run("$metadata#Collection(Edm.EntityType)").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(Collection(Edm.EntityType))) <EOF>)");
test.run("$metadata#Collection(Edm.ComplexType)").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(Collection(Edm.ComplexType))) <EOF>)");
test.run("$metadata#singletonEntity").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(singletonEntity))) <EOF>)");
test.run("$metadata#NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI))) <EOF>)");
test.run("$metadata#Edm.Boolean").isText("odataRelativeUriEOF("
+ "odataRelativeUri($metadata # "
+ "contextFragment(namespace(odataIdentifier(Edm) .) odataIdentifier(Boolean))) <EOF>)");
test.run("$metadata#ODI/$deletedEntity").isText("odataRelativeUriEOF("
+ "odataRelativeUri($metadata # contextFragment(odataIdentifier(ODI) / $deletedEntity)) <EOF>)");
test.run("$metadata#ODI/$link").isText("odataRelativeUriEOF("
+ "odataRelativeUri($metadata # contextFragment(odataIdentifier(ODI) / $link)) <EOF>)");
test.run("$metadata#ODI/$deletedLink").isText("odataRelativeUriEOF("
+ "odataRelativeUri($metadata # contextFragment(odataIdentifier(ODI) / $deletedLink)) <EOF>)");
test.run("$metadata#ODI(1)/ODI").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
+ "/ odataIdentifier(ODI))) <EOF>)");
test.run("$metadata#ODI(1)/NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
+ "/ namespace(odataIdentifier(NS) .) odataIdentifier(ODI))) <EOF>)");
test.run("$metadata#ODI(1)/NS.ODI/ODI").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) "
+ "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
+ "/ namespace(odataIdentifier(NS) .) odataIdentifier(ODI) "
+ "/ odataIdentifier(ODI))) <EOF>)");
test.run("$metadata#NS.ODI(*)").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(namespace(odataIdentifier(NS) .) odataIdentifier(ODI) "
+ "propertyList(( propertyListItem(*) )))) <EOF>)");
test.run("$metadata#ODI(1)").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) "
+ "nameValueOptList(valueOnly(( primitiveLiteral(1) ))))) <EOF>)");
test.run("$metadata#ODI(1)/ODI").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) "
+ "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
+ "/ odataIdentifier(ODI))) <EOF>)");
test.run("$metadata#ODI(1)/NS.ODI").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) "
+ "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
+ "/ namespace(odataIdentifier(NS) .) odataIdentifier(ODI))) <EOF>)");
test.run("$metadata#ODI(1)/NS.ODI/ODI").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) "
+ "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
+ "/ namespace(odataIdentifier(NS) .) odataIdentifier(ODI) / odataIdentifier(ODI))) <EOF>)");
test.run("$metadata#ODI(1)(*)").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) "
+ "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) propertyList(( propertyListItem(*) )))) <EOF>)");
test.run("$metadata#ODI(1)(PROP)").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) "
+ "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
+ "propertyList(( propertyListItem(propertyListProperty(odataIdentifier(PROP))) )))) <EOF>)");
test.run("$metadata#ODI(1)(NAVPROP+)").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) "
+ "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
+ "propertyList(( propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) +)) )))) <EOF>)");
test.run("$metadata#ODI(1)(NAVPROP+(*))").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) "
+ "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
+ "propertyList(( "
+ "propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + "
+ "propertyList(( "
+ "propertyListItem(*) )))) )))) <EOF>)");
test.run("$metadata#ODI(1)(NAVPROP+(A,B,C))").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) "
+ "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
+ "propertyList(( "
+ "propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + "
+ "propertyList(( "
+ "propertyListItem(propertyListProperty(odataIdentifier(A))) , "
+ "propertyListItem(propertyListProperty(odataIdentifier(B))) , "
+ "propertyListItem(propertyListProperty(odataIdentifier(C))) )))) )))) <EOF>)");
test.run("$metadata#ODI(1)(NAVPROP+(A,B,C))/$delta").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) "
+ "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
+ "propertyList(( "
+ "propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + "
+ "propertyList(( "
+ "propertyListItem(propertyListProperty(odataIdentifier(A))) , "
+ "propertyListItem(propertyListProperty(odataIdentifier(B))) , "
+ "propertyListItem(propertyListProperty(odataIdentifier(C))) )))) )) "
+ "/ $delta)) <EOF>)");
test.run("$metadata#ODI(1)(NAVPROP+(A,B,C))/$entity").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) "
+ "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
+ "propertyList(( "
+ "propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + "
+ "propertyList(( "
+ "propertyListItem(propertyListProperty(odataIdentifier(A))) , "
+ "propertyListItem(propertyListProperty(odataIdentifier(B))) , "
+ "propertyListItem(propertyListProperty(odataIdentifier(C))) )))) )) "
+ "/ $entity)) <EOF>)");
test.run("$metadata#ODI(1)(NAVPROP+(A,B,C))/$delta/$entity").isText("odataRelativeUriEOF(odataRelativeUri("
+ "$metadata # contextFragment(odataIdentifier(ODI) "
+ "nameValueOptList(valueOnly(( primitiveLiteral(1) ))) "
+ "propertyList(( "
+ "propertyListItem(propertyListProperty(odataIdentifier(NAVPROP) + "
+ "propertyList(( "
+ "propertyListItem(propertyListProperty(odataIdentifier(A))) , "
+ "propertyListItem(propertyListProperty(odataIdentifier(B))) , "
+ "propertyListItem(propertyListProperty(odataIdentifier(C))) )))) )) "
+ "/ $delta / $entity)) <EOF>)");
}
@Test