ligasgr / intellij-xquery

Plugin to support XQuery in Intellij Idea
Apache License 2.0
35 stars 23 forks source link

Valid expressions of the form `... < (...)` are reported as errors. #198

Closed rhdunn closed 7 years ago

rhdunn commented 8 years ago

Given:

if (1 < (2 * 3)) then
    true()
else
    false()

incorrectly generates the following errors:

if (1 < (2 * 3)) then
     ^--- (list of valid tokens) expected, got '<'

if (1 < (2 * 3)) then
       ^--- XmlTagNCName expected, got '('

if (1 < (2 * 3)) then
        ^--- '(:', AttrNCName, XmlTagEnd or XmlTagNCName expected, got '('

if (1 < (2 * 3)) then
               ^--- (list of valid tokens) expected, got ')'

It looks like the '<' operator is being interpreted as the start of an XML tag.

NOTE: Neither if (1 < 2) then ... nor if ((1+1) < 2) then ... generate errors.

ligasgr commented 8 years ago

This is affected by the same problem as #9

rhdunn commented 8 years ago

According to the XQuery 3.0 grammar, a DirElemConstructor item does not have a space between the < and NCName. Saxon generates an XPST0003 error (syntax error) for the following construct:

< a/>

NOTE: The "Building a Tokenizer for XPath or XQuery" document is taken from the appendix of a pre-1.0 version of XQuery. From 1.0, the structure of the document is fully described as an EBNF grammar. A tokenizer/lexer would need to process a subset of that grammar (e.g. for direct XML element construction).