继续查看readme的inmemantlr中的示例代码,我无法使用任何grammars-v4。例如,用java8.g4初始化GenericParser
时,它说:
error(50): :1426:3: syntax error: 'lL' came as a complete surprise to me while matching a lexer rule
error(50): :1448:3: syntax error: '1-9' came as a complete surprise to me while matching a lexer rule
error(50): :1469:7: syntax error: 'xX' came as a complete surprise to me while looking for lexer rule element
error(50): :1479:3: syntax error: '0-9a-fA-F' came as a complete surprise to me while matching a lexer rule
error(50): :1505:3: syntax error: '0-7' came as a complete surprise to me while matching a lexer rule
error(50): :1521:7: syntax error: 'bB' came as a complete surprise to me while looking for lexer rule element
error(50): :1531:3: syntax error: '01' came as a complete surprise to me while matching a lexer rule
error(50): :1567:3: syntax error: 'eE' came as a complete surprise to me while matching a lexer rule
error(50): :1577:3: syntax error: '+-' came as a complete surprise to me while matching a lexer rule
error(50): :1582:3: syntax error: 'fFdD' came as a complete surprise to me while matching a lexer rule
error(50): :1593:7: syntax error: 'xX' came as a complete surprise to me while looking for lexer rule element
error(50): :1603:3: syntax error: 'pP' came as a complete surprise to me while matching a lexer rule
error(50): :1622:4: syntax error: ''\\\r\n]\n\t;\n\n// §3.10.5 String Literals\n\nStringLiteral\n\t:\t'"' StringCharacters? '"'\n\t;\n\nfragment\nStringCharacters\n\t:\tStringCharacter+\n\t;\n\nfragment\nStringCharacter\n\t:\t~["\\\r\n]\n\t|\tEscapeSequence\n\t;\n\n// §3.10.6 Escape Sequences for Character and String Literals\n\nfragment\nEscapeSequence\n\t:\t'\\' [btnfr"'\\' came as a complete surprise to me while looking for lexer rule element
error(50): :1660:3: syntax error: '0-3' came as a complete surprise to me while matching a lexer rule
error(50): :1735:3: syntax error: 'a-zA-Z$_' came as a complete surprise to me while matching a lexer rule
error(50): :1737:3: syntax error: '\u0000-\u007F\uD800-\uDBFF' came as a complete surprise to me while looking for lexer rule element
error(50): :1740:2: syntax error: '\uD800-\uDBFF' came as a complete surprise to me while matching a lexer rule
error(50): :1746:3: syntax error: 'a-zA-Z0-9$_' came as a complete surprise to me while matching a lexer rule
error(50): :1748:3: syntax error: '\u0000-\u007F\uD800-\uDBFF' came as a complete surprise to me while looking for lexer rule element
error(50): :1751:2: syntax error: '\uD800-\uDBFF' came as a complete surprise to me while matching a lexer rule
error(50): :1766:7: syntax error: ' \t\r\n\u000C' came as a complete surprise to me while matching a lexer rule
error(50): :1774:14: syntax error: '\r\n' came as a complete surprise to me while looking for lexer rule element
产生上面输出的行很简单:
this.parser = new GenericParser(grammarFile);
其中grammarFile
是java8.g4文件。
忽略以上消息,然后执行以下操作:
this.parser.setListener(new ParserListener());
this.parser.compile();
由于以下异常而失败:
org.snt.inmemantlr.exceptions.CompilationException: No string code pipeline availabe
at org.snt.inmemantlr.GenericParser.compile(GenericParser.java:313)
使用version 1.4 of inmemantlr(与Java 8兼容)。任何指针都表示赞赏。