I am trying to create a parser for a PGN file and am getting errors on the moves. If my input is Ng4
, the output should be (standard_move (moving_Piece N) (moving_File g) (moving_Rank 4)
)
. This works well with the below .g4 file:
grammar MOVE;
standard_move: moving_Piece moving_File moving_Rank Newline;
moving_Piece: Moving_Piece ;
moving_File: Moving_File;
moving_Rank: Moving_Rank;
Moving_Piece: ( K | Q | R | B | N ) ;
Moving_File: [a-h];
Moving_Rank: [1-8];
Newline: [
];
WHITESPACE : -> skip ;
然而,如果我把同样的逻辑列入我较大型的.g4文档中,有其他的国产总值要素,那么我就获得了<代码>1:0不匹配的投入。 Ng Requesting Moving_Piece
grammar PGN;
annotations: annotation+;
annotation : Open_Bracket tag value Close_Bracket Newline ;
value: String;
tag: Chars;
move_time: Move_time Newline;
move_number: Move_Number Newline;
standard_move: moving_Piece moving_File moving_Rank Newline;
moving_Piece: Moving_Piece ;
moving_File: Moving_File;
moving_Rank: Moving_Rank;
Moving_Piece: ( K | Q | R | B | N ) ;
Moving_File: [a-h];
Moving_Rank: [1-8];
Move_Number: [0-9]+ . ;
Move_time: {[%emt .*? ]} ;
Chars: [a-zA-Z]*;
String : " ~["]* " ;
Quote : " ;
Open_Bracket : [ ;
Close_Bracket : ] ;
Newline: [
];
WHITESPACE : -> skip ;
任何帮助为什么发生这种情况都会受到高度赞赏!