Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ANTLR4的外部输入错误_Antlr - Fatal编程技术网

使用ANTLR4的外部输入错误

使用ANTLR4的外部输入错误,antlr,Antlr,我是一名ANTLR新手,正在与我所犯的一些错误作斗争。下面我已经包括了我正在使用的语法,输入文件和我得到的错误 我的Antlr语法文件如下: grammar Simple; @header { package simple; } 分析器 program : anylinebefore+ processline anylineafter+ 'MSEND' NEWLINE '.' EOF ; an

我是一名ANTLR新手,正在与我所犯的一些错误作斗争。下面我已经包括了我正在使用的语法,输入文件和我得到的错误

我的Antlr语法文件如下:

grammar Simple;

@header
{
package simple;
}
分析器

program :
        anylinebefore+
        processline
        anylineafter+
        'MSEND' NEWLINE
         '.' EOF
        ;

anylinebefore:  CH* NEWLINE | commentline;

anylineafter:  statement | commentline;

statement: movestatement ; 

movestatement : 'MOVE' arg ('to' | 'TO')  ID '.' NEWLINE ;

arg : ID|STRING;

processline:  PROCESSLITERAL  NEWLINE; 

commentline:  '!' CH* NEWLINE;
雷克瑟

我的输入文件如下:

MODIFY   
         PROCESS SOURCE FOLLOWS  
MOVE 'WSFRED' TO AGRPASSEDTWO.   
         MSEND    
         .
我得到的错误是:

showtree:
     [java] line 1:0 extraneous input 'MODIFY' expecting {'!', CH, NEWLINE}
我不明白为什么这与语法中的之前的任何行都不匹配
任何帮助都将不胜感激。

修改”是一个ID,与之前的任何行都不匹配+

嘿,有ANTLR 4图书赠品吗?我想要一个,但我妈妈不给我钱。今晚我花了几个小时,得出了相同的结论。再次感谢。。。
showtree:
     [java] line 1:0 extraneous input 'MODIFY' expecting {'!', CH, NEWLINE}