F # Power Pack의 fsyacc/fslex를 사용하여 일부 소스 코드를 구문 분석하고 있습니다.FSyacc로 구문 분석하는 동안 의미있는 오류가 발생했습니다.
use inputChannel = new StreamReader(File.OpenRead tempFileName)
let lexbuf = Lexing.LexBuffer<_>.FromTextReader inputChannel
let ast = try
Parser.start Lexer.tokenize lexbuf
with e ->
let pos = lexbuf.EndPos
let line = pos.Line
let column = pos.Column
let message = e.Message
let lastToken = new System.String(lexbuf.Lexeme)
printf "Parse failed at line %d, column %d:\n" line column
printf "Last loken: %s" lastToken
printf "\n"
exit 1
그러나이 코드는 여러 줄의 소스 파일을 구문 분석에 오류 메시지를 표시 할 때, 내가 잘못 라인과 열 위치는군요 :
Parse failed at line 0, column 10899:
을
내가 다음 코드를 사용하여 오류를 감지하려면
오류가 발생한 행 번호를 올바르게 가져올 수 있습니까? 렉싱 동안
같은 규칙과 줄 번호를 증가해야합니까? 또한 fslex 프로젝트를 추가하여 디버깅 할 수도 있습니다 – Cynede