jpcs / xqueryparser.xq

An parser for XQuery 3.0 and MarkLogic extensions.
Apache License 2.0
13 stars 3 forks source link

Grammar does not handle newest ML extensions #6

Open fgeorges opened 8 years ago

fgeorges commented 8 years ago

The grammar is not up-to-date with the latest MarkLogic extensions to the language. For instance, ItemTest such as object-node().

fgeorges commented 8 years ago

An example query that fails to parse is:

xquery version "1.0-ml";

module namespace bin = "http://expath.org/ns/ml/console/binary";

declare namespace xdmp = "http://marklogic.com/xdmp";

(:~
 : Return true if the parameter is a binary node.
 :)
declare function bin:is-binary($arg as node())
   as xs:boolean
{
   $arg instance of binary()
};

(:~
 : Return true if the parameter is a JSON node.
 : 
 : http://markmail.org/message/mypneadypxmj4xly
 :)
declare function bin:is-json($arg as node())
   as xs:boolean
{
   typeswitch ( $arg )
      case object-node()  return fn:true()
      case array-node()   return fn:true()
      case number-node()  return fn:true()
      case boolean-node() return fn:true()
      case null-node()    return fn:true()
      default             return fn:false()
};

The parser returns:

<ERROR b="522" e="523" s="266">lexical analysis failed
while expecting '(:'
after successfully scanning 1 characters at line 25, column 23
...()  return fn:true()
      case ...</ERROR>