cleishm / libcypher-parser

Cypher Parser Library
Apache License 2.0
147 stars 39 forks source link

Support for REGEX operator? #9

Closed rafaelcaricio closed 5 years ago

rafaelcaricio commented 5 years ago

I've posted a question in Stackoverflow, but just cross-posting here since I could not use the libcypher-parser tag.

https://stackoverflow.com/questions/54573401/does-libcypher-parser-has-support-for-regex-operator

An more succinct example here:

echo "RETURN word =~ '.*'" | cypher-lint -a
<stdin>:1:14: Invalid input '~': expected NOT, '+', '-', TRUE, FALSE, NULL, "...string...", a float, an integer, '[', a parameter, '{', CASE, FILTER, EXTRACT, REDUCE, ALL, ANY, NONE, SINGLE, shortestPath, allShortestPaths, '(', a function name or an identifier
RETURN word =~ '.*'
             ^
@0   0..20  statement           body=@1
@1   0..20  > query             clauses=[@2]
@2   0..12  > > RETURN          projections=[@3]
@3   7..12  > > > projection    expression=@4
@4   7..11  > > > > identifier  `word`
@5  12..20  > > error           >>=~ '.*'\n<<

I can see references to an CYPHER_OP_REGEX in the code. But cannot find why it's not parsing as expected.

cleishm commented 5 years ago

Good catch. I've tracked down why it wasn't parsing, adding a test and fixing the issue.

rafaelcaricio commented 5 years ago

@cleishm Thank you for the quick reply and fix. Great work!