简体   繁体   中英

What is “parser rule 'channels' not allowed in lexer” error in this ANTLR 4 Lexer file?

I am trying to build the Parser and Lexer from the MySQL .g4 files at https://github.com/antlr/grammars-v4/tree/master/mysql . I get the error "parser rule 'channels' not allowed in lexer" as demonstrated in the attached image.

这是Lexer文件中的错误

Lexer-only grammars can only contain lexer rules. What I think is happening here is that tool you're using is interpreting the "rule" channels as a parser rule because it does not begin with an uppercase letter and therefore out of place in this lexer-only grammar.

However, Mike's comment is correct. This channels construct is (currently) a valid ANTLR grammar for a lexer file. See this page. . It is supposed to go in the the lexer grammar file, and so the only thing I can surmise about the error you're getting is that the tool (IDE) you're using doesn't understand the channels custom specification syntax.

Be aware that not every grammar in that github list is perfect, and is not part of ANTLR proper, but are contributed by various authors and sometimes different versions of ANTLR than the one you're using at any given moment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM