-
I have the following grammer: ?start: condition
?condition: condition_1
| condition "AND" condition_1 -> and_
| condition "OR" condition_1 -> or_
?condition_1: predicate
| "NOT" predicate -> not_
| "(" condition ")"
?predicate: expression "=" expression -> eq
| expression "<>" expression -> ne
| expression "<" expression -> lt
| expression "<=" expression -> lte
| expression ">" expression -> gt
| expression ">=" expression -> gte
| expression "BETWEEN" expression "AND" expression -> between
| expression "NOT" "BETWEEN" expression "AND" expression -> not_between
| expression "LIKE" SINGLE_QUOTED -> like
| expression "NOT" "LIKE" SINGLE_QUOTED -> not_like
| expression "ILIKE" SINGLE_QUOTED -> ilike
| expression "NOT" "ILIKE" SINGLE_QUOTED -> not_ilike
| expression "IN" "(" expression ( "," expression )* ")" -> in_
| expression "NOT" "IN" "(" expression ( "," expression )* ")" -> not_in
| expression "IS" "NULL" -> null
| expression "IS" "NOT" "NULL" -> not_null
| attribute "EXISTS" -> exists
| attribute "DOES-NOT-EXIST" -> does_not_exist
| "INCLUDE" -> include
| "EXCLUDE" -> exclude
| temporal_predicate
| spatial_predicate
?temporal_predicate: expression "BEFORE" DATETIME -> before
| expression "BEFORE" "OR" "DURING" period -> before_or_during
| expression "DURING" period -> during
| expression "DURING" "OR" "AFTER" period -> during_or_after
| expression "AFTER" DATETIME -> after
?spatial_predicate: _binary_spatial_predicate_func "(" expression "," expression ")" -> binary_spatial_predicate
| "RELATE" "(" expression "," expression "," SINGLE_QUOTED ")" -> relate_spatial_predicate
| _distance_spatial_predicate_func "(" expression "," expression "," number "," distance_units ")" -> distance_spatial_predicate
| "BBOX" "(" expression "," full_number "," full_number "," full_number "," full_number [ "," SINGLE_QUOTED] ")" -> bbox_spatial_predicate
!_binary_spatial_predicate_func: "INTERSECTS" | "DISJOINT" | "CONTAINS" | "WITHIN" | "TOUCHES" | "CROSSES" | "OVERLAPS" | "EQUALS"
!_distance_spatial_predicate_func: "DWITHIN" | "BEYOND"
!distance_units: "feet" | "meters" | "statute miles" | "nautical miles" | "kilometers" -> distance_units
?expression: sum
?sum: product
| sum "+" product -> add
| sum "-" product -> sub
?product: atom
| product "*" atom -> mul
| product "/" atom -> div
?atom: attribute
| literal
| "-" atom -> neg
| NAME "(" [ expression ("," expression)* ] ")" -> function
| "(" expression ")"
attribute: NAME
| DOUBLE_QUOTED
| NAME ":" NAME
?literal: number
| BOOLEAN
| SINGLE_QUOTED
| ewkt_geometry -> geometry
| envelope
?full_number: number
| "-" number -> neg
?number: FLOAT | INT
period: DATETIME "/" DATETIME
| DURATION "/" DATETIME
| DATETIME "/" DURATION
envelope: "ENVELOPE" "(" number number number number ")"
BOOLEAN: ( "TRUE" | "FALSE" )
DOUBLE_QUOTED: "\"" /.*?/ "\""
SINGLE_QUOTED: "'" /.*?/ "'"
%import .wkt.ewkt_geometry
%import .iso8601.DATETIME
%import .iso8601.DURATION
%import common.CNAME -> NAME
%import common.WORD
%import common.INT
%import common.FLOAT
%import common.WS_INLINE
%ignore WS_INLINE
and i want to parse But this will result in the following exception
This means, that the Why does lark split the attribute? |
Beta Was this translation helpful? Give feedback.
Answered by
MegaIng
Oct 24, 2023
Replies: 1 comment 1 reply
-
If you want to strings to be part of the same terminal, they need to be part of the same terminal definition. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jokiefer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to strings to be part of the same terminal, they need to be part of the same terminal definition.
attribute
is a rule definition, not a terminal definition.