XQuery 3.1的Antlr V4语法

时间:2017-07-03 16:24:40

标签: xquery antlr4

我发现了以下Antlr 4语法:

https://gist.github.com/JoeyAcc/829c28fcf18091ed6ebfcf91d7519f58

尝试从中生成代码时收到以下错误:

error(134): xquery31.g4:178:26: rule reference PragmaContentsInternal is not currently supported in a set
error(134): xquery31.g4:264:25: rule reference DirPIContentsInternal is not currently supported in a set
error(134): xquery31.g4:268:32: rule reference CDataSectionContentsInternal is not currently supported in a set
error(134): xquery31.g4:311:17: rule reference StringConstructorCharsInternal is not currently supported in a set
warning(156): xquery31.g4:377:59: invalid escape sequence
warning(156): xquery31.g4:378:60: invalid escape sequence
warning(156): xquery31.g4:392:30: invalid escape sequence
warning(156): xquery31.g4:394:30: invalid escape sequence
error(134): xquery31.g4:416:27: rule reference CommentContentsInternal is not currently supported in a set
warning(146): xquery31.g4:13:0: non-fragment lexer rule Prolog can match the empty string
warning(146): xquery31.g4:110:0: non-fragment lexer rule WindowVars can match the empty string
warning(146): xquery31.g4:127:0: non-fragment lexer rule OrderModifier can match the empty string
warning(146): xquery31.g4:211:0: non-fragment lexer rule PredicateList can match the empty string
warning(146): xquery31.g4:248:0: non-fragment lexer rule DirAttributeList can match the empty string
warning(146): xquery31.g4:261:0: non-fragment lexer rule DirCommentContents can match the empty string
error(99): xquery31.g4::: grammar xquery31 has no rules

有没有建议修复这个ANTLR V4语法?

EBNF for XQuery v3.1就在这里

3 个答案:

答案 0 :(得分:0)

您的错误消息的最后一行非常有说服力。如果你看一下语法,每个单词都是大写的。这意味着这只是词法分析器规则,以及那些有错误的规则。解析器规则完全不存在。也许联系这个语法的海报或在将时间投入此文件之前搜索解析器规则。

答案 1 :(得分:0)

我认为JoeyACC的工作结论就在这里 - https://gist.github.com/JoeyAcc/375663dfc21cd7ec4d35ea8f7ff251d0#file-xquery31-g4

另一种方法是采用这个Antlrv4 XQuery 1.0语法并为3.1添加缺少的部分:https://github.com/bluezio/xquery-parser

答案 2 :(得分:0)

我最终为XQuery 3.1创建了自己的Antlr4语法。它位于:https://github.com/xqdoc/xqdoc/tree/master/src/main/antlr4/org/xqdoc