+++ /dev/null
-/*--------------------------------------------------------------------------\r
- * Copyright 2009 Taro L. Saito\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *--------------------------------------------------------------------------*/\r
-//--------------------------------------\r
-// XerialJ\r
-//\r
-// LensQuery.g\r
-// Since: Aug 6, 2009 08:30:02 AM\r
-//\r
-//--------------------------------------\r
- \r
-grammar LensQuery;\r
-options \r
-{\r
- language=Java;\r
- output=AST;\r
-}\r
-tokens {\r
- QUERY;\r
- RELATION;\r
- COMPARE;\r
- OPERATOR;\r
- OPERAND;\r
- PATTERNMATCH;\r
- NODE;\r
- ALIAS;\r
- NODEVALUE;\r
- NAME;\r
- VALUE;\r
-}\r
-\r
-\r
-@lexer::header\r
-{\r
-/*--------------------------------------------------------------------------\r
- * Copyright 2009 Taro L. Saito\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *--------------------------------------------------------------------------*/\r
-//--------------------------------------\r
-// XerialJ\r
-//\r
-// LensQueryLexer.g\r
-// Since: Aug 6, 2009 08:30:02 AM\r
-//\r
-//--------------------------------------\r
-\r
-package org.xerial.lens.relation.query.impl;\r
-\r
-}\r
-\r
- \r
-@header\r
-{\r
-/*--------------------------------------------------------------------------\r
- * Copyright 2009 Taro L. Saito\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *--------------------------------------------------------------------------*/\r
-//--------------------------------------\r
-// XerialJ\r
-//\r
-// LensQueryParser.g\r
-// Since: Aug 6, 2009 08:30:02 AM\r
-//\r
-//--------------------------------------\r
-package org.xerial.lens.relation.query.impl;\r
-\r
-}\r
-\r
-@lexer::members {\r
-\r
-}\r
-\r
-@members {\r
-} \r
-\r
-// lexer rules\r
-\r
-// Line Comment\r
-fragment LineBreakChar: '\n' | '\r'; // r: <CR> n : <LF>\r
-LineComment: '#' ~(LineBreakChar)* { $channel = HIDDEN; };\r
-\r
-\r
-LineBreak: ('\r' '\n' | '\r' | '\n' ) { $channel = HIDDEN; }; \r
-\r
-\r
-fragment Digit: '0' .. '9';\r
-fragment Letter: 'A' .. 'F' | 'a' .. 'f';\r
-fragment HexDigit: Digit | Letter;\r
-fragment UnicodeChar: ~('"'| '\\');\r
-fragment EscapeSequence\r
- : '\\' ('\"' | '\\' | '/' | 'b' | 'f' | 'n' | 'r' | 't' | 'u' HexDigit HexDigit HexDigit HexDigit)\r
- ; \r
-\r
-fragment StringChar : UnicodeChar | EscapeSequence;\r
-fragment StringChar_s: StringChar*;\r
-\r
-String: '"' s=StringChar_s '"' { setText($s.text); };\r
-\r
-\r
-Integer: '-'? ('0' | '1'..'9' Digit*);\r
-fragment Frac: '.' Digit+;\r
-fragment Exp: ('e' | 'E') ('+' | '-')? Digit+;\r
-Double: Integer (Frac Exp? | Exp);\r
-\r
-True: 'true';\r
-False: 'false';\r
-Null: 'null';\r
-\r
-\r
-// comparison operator\r
-Lt: '<';\r
-Gt: '>';\r
-Leq: '<=';\r
-Geq: '>=';\r
-Eq: '=';\r
-Neq: '!=';\r
-Match: '~=';\r
-Regex: '/' (options{greedy=false;}: .)* '/' ('a' .. 'z' | 'A' .. 'Z')* ;\r
-\r
-\r
-Dot: '.';\r
-Comma: ',';\r
-Colon: ':';\r
-\r
-As: 'as';\r
-\r
-LParen: '('; \r
-RParen: ')';\r
-\r
-Star: '*';\r
-\r
-fragment\r
-UnsafeUnicodeChar: '(' | ')' | '[' | ']' | '{' | '}' | ',' | ':' | '#' | '<' | '>' | '|' | '*' | '\'' | '"' | '@' | '%' | '\\' | '.' | '-'; \r
-\r
-fragment SafeFirstLetter: 'A' .. 'Z' | 'a' .. 'z';\r
-fragment SafeLetter: SafeFirstLetter | '0' .. '9' | '-' | '_';\r
-\r
-\r
-fragment QNameChar: ~(LineBreakChar | UnsafeUnicodeChar | WhiteSpace);\r
-QName: QNameChar+ (Dot QNameChar+)*;\r
-\r
-\r
-fragment \r
-WhiteSpace: ' ' | '\t';\r
- \r
-WhiteSpaces: WhiteSpace+ { $channel = HIDDEN; }; \r
-\r
- \r
-// parser rules \r
- \r
-expr:\r
- relation \r
- ; \r
- \r
-relation \r
- : relation_i -> ^(RELATION relation_i)\r
-;\r
-\r
-relation_i: nodeName alias? LParen! nodeItem (Comma! nodeItem)* RParen!;\r
-\r
-\r
-fragment\r
-nodeName\r
- : QName -> NAME[$QName.text]\r
- | String -> NAME[$String.text]\r
- ;\r
-\r
-fragment\r
-alias: As QName -> ALIAS[$QName.text];\r
- \r
-\r
-fragment\r
-nodeItem\r
- : nodeName alias? nodeValue? \r
- -> ^(NODE nodeName alias? nodeValue?)\r
- | relation \r
- ;\r
-\r
-fragment\r
-value\r
- : String | Integer | Double | QName\r
- ; \r
- \r
-fragment \r
-nodeValue\r
- : Colon value -> NODEVALUE[$value.text]\r
- | nodeCmp \r
- ; \r
-\r
-fragment \r
-nodeCmp\r
- : cmpOp value -> ^(COMPARE OPERATOR[$cmpOp.text] OPERAND[$value.text])\r
- | Match Regex -> ^(PATTERNMATCH OPERAND[$Regex.text])\r
- ;\r
- \r
-fragment \r
-cmpOp: (Lt | Gt | Eq | Leq | Geq | Neq) \r
- ;\r
-
\ No newline at end of file