0
오류를 throw합니다. 하지만 질문의 뒷부분에 나오는 것과는 다른 행동을합니다.캔 Ragel 개별 명령 구문 분석을 수행하고 내가 명령의 각 단계 (<code>:LoadSdf</code>, <code>12</code>, <code>abc.ldf</code>)에서 오류를 얻기 위해 노력하고 <code>:LoadSdf 12 abc.ldf</code> 명령을 구문 분석을 시도하고 그에 따라
내 Ragel 의사 코드는 다음
%%
machine ldf;
LOAD_CMD = ":LoadSdf" $!(cmd_error);
CHANNEL_NR = [digit]+ $!(channel_error);
FILENAME = [a-zA-Z0-9\.\-\_]+ $!(filename_error);
SPACE = ' ';
main:= (LOAD_CMD.SPACE+.CHANNEL_NR.SPACE.FILENAME) %/job_done;
%%
예상 출력 :
./a.out ":Load"
incorrect command //corresponding actions contain these error messages
./a.out ":LoadSdf"
whitespace missing //corresponding actions contain these error messages
./a.out ":LoadSdf "
channel number missing //corresponding actions contain these error messages
./a.out ":LoadSdf 12 "
file name missing //corresponding actions contain these error messages
./a.out ":LoadSdf 12 abc.ldf"
parsing success //corresponding actions contain these messages
관찰 출력 :
./a.out ":Load"
incorrect command
./a.out ":LoadSdf"
whitespace missing
./a.out ":LoadSdf "
whitespace missing
channel number missing
./a.out ":LoadSdf 12 "
whitespace missing
file name missing
./a.out ":LoadSdf 12"
channel number missing
./a.out ":LoadSdf 12 abc.ldf"
parsing success
오류 처리에 대한 Ragel 구문은 매우 어렵고 매우 제한적으로 설명 . 현재 사건에 대한 제안이 있으면 큰 도움이 될 것입니다.