Skip to content

Commit

Permalink
Merge pull request gfngfn#104 from matsud224/fix-range-fname
Browse files Browse the repository at this point in the history
Fix empty filename bug on parser error message
  • Loading branch information
gfngfn committed Aug 12, 2018
2 parents ccf8ec9 + dae8d21 commit 285ff60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
11 changes: 3 additions & 8 deletions src/frontend/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@
| MathState (* math mode *)


let file_name_ref = ref ""


let get_pos lexbuf =
let posS = Lexing.lexeme_start_p lexbuf in
let posE = Lexing.lexeme_end_p lexbuf in
let fname = !file_name_ref (* posS.Lexing.pos_fname *) in
let fname = posS.Lexing.pos_fname in
let lnum = posS.Lexing.pos_lnum in
let cnumS = posS.Lexing.pos_cnum - posS.Lexing.pos_bol in
let cnumE = posE.Lexing.pos_cnum - posE.Lexing.pos_bol in
Expand Down Expand Up @@ -95,13 +92,11 @@
stack


let reset_to_progexpr fname =
file_name_ref := fname;
let reset_to_progexpr () =
initialize ProgramState


let reset_to_vertexpr fname =
file_name_ref := fname;
let reset_to_vertexpr () =
initialize VerticalState


Expand Down
5 changes: 4 additions & 1 deletion src/frontend/parserInterface.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ exception Error of Range.t

module I = Parser.MenhirInterpreter

open Lexing


let k_success utast =
utast
Expand All @@ -23,6 +25,7 @@ let k_fail chkpt =

let process fname lexbuf =
(* print_endline "parserInterface.process"; (* for debug *) *)
let stack = Lexer.reset_to_progexpr fname in
let stack = Lexer.reset_to_progexpr () in
let () = lexbuf.lex_curr_p <- { lexbuf.lex_curr_p with pos_fname = fname } in
let supplier = I.lexer_lexbuf_to_supplier (Lexer.cut_token stack) lexbuf in
I.loop_handle k_success k_fail supplier (Parser.Incremental.main lexbuf.Lexing.lex_curr_p)

0 comments on commit 285ff60

Please sign in to comment.