Fix locations reported by the parser (#609)

The start position of atoms wasn't saved by the parser.
This commit is contained in:
Jérémie Dimino 2018-03-12 18:41:49 +00:00 committed by GitHub
parent a9b84a6259
commit ca5c383b3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 13 deletions

View File

@ -41,6 +41,8 @@ next
- Add a `best` mode which is native with fallback to byte-code when
native compilation is not available (#23)
- Fix locations reported in error messages (609)
1.0+beta18 (25/02/2018)
-----------------------

View File

@ -176,9 +176,9 @@ type 'a epsilon_action = 'a state -> stack -> stack
let current_pos ?(delta=0) state : Lexing.position =
let offset = state.offset + delta in
{ pos_fname = state.fname
; pos_lnum = state.line_number
; pos_cnum = offset
; pos_bol = state.bol_offset
; pos_lnum = state.line_number
; pos_cnum = offset
; pos_bol = state.bol_offset
}
let set_automaton_state state x = state.automaton_state <- x
@ -211,16 +211,13 @@ let check_new_sexp_allowed : type a. a state -> unit = fun state ->
let add_first_char state char stack =
check_new_sexp_allowed state;
Buffer.add_char state.atom_buffer char;
(* For non-quoted atoms, we save both positions at the end. We can always determine the
start position from the end position and the atom length for non-quoted atoms.
Doing it this way allows us to detect single characater atoms for which we need to
save the position twice. *)
state.token_start_pos <- current_pos state;
stack
let eps_add_first_char_hash state stack =
check_new_sexp_allowed state;
Buffer.add_char state.atom_buffer '#';
state.token_start_pos <- current_pos state ~delta:(-1);
stack
let start_quoted_string state _char stack =

View File

@ -1,3 +1,3 @@
$ $JBUILDER build --display short --root . -j 1
File "jbuild", line 1, characters 0-50:
File "jbuild", line 3, characters 24-28:
Warning: Module Fake is excluded but it doesn't exist.

View File

@ -7,7 +7,7 @@
Reproduction case for #484. The error should point to src/jbuild
$ $JBUILDER build --root . -j1 --display quiet @install
File "src/jbuild", line 1, characters 0-66:
File "src/jbuild", line 4, characters 16-17:
Error: Library "a" not found.
Hint: try: jbuilder external-lib-deps --missing --root . @install
[1]

View File

@ -38,8 +38,8 @@ Errors:
ocamlc .foo.objs/foo.{cmi,cmo,cmt}
ocamlc foo.cma
$ $JBUILDER build --display short --root c -j1 foo.cma 2>&1 | grep -v Entering
File "jbuild", line 1, characters 0-58:
File "jbuild", line 3, characters 35-36:
Error: Module X doesn't exist.
$ $JBUILDER build --display short --root d -j1 foo.cma 2>&1 | grep -v Entering
File "jbuild", line 1, characters 0-58:
File "jbuild", line 3, characters 35-36:
Error: Module X has an implementation, it cannot be listed here

View File

@ -1,5 +1,5 @@
$ $JBUILDER runtest -j1 --display short --root .
File "jbuild", line 54, characters 10-209:
File "jbuild", line 65, characters 21-44:
Warning: Directory dir-that-doesnt-exist doesn't exist.
diff alias runtest
diff alias runtest