Skip to content

Commit 8df1ac4

Browse files
authored
Fix parser (#199)
1 parent abd355a commit 8df1ac4

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,15 @@ jobs:
6666

6767
- name: Extra setup on Linux
6868
if: runner.os == 'Linux'
69-
run: opam exec -- echo "workspace=${{ github.workspace }}" >> $GITHUB_ENV
69+
run: |
70+
opam exec -- echo "workspace=${{ github.workspace }}" >> $GITHUB_ENV
71+
sudo apt-get install wdiff
7072
7173
- name: Extra setup on macOS
7274
if: runner.os == 'macOS'
7375
run: |
7476
brew install gnu-time
77+
brew install wdiff
7578
opam exec -- echo "workspace=${{ github.workspace }}" >> $GITHUB_ENV
7679
7780
- name: Extra setup on Windows
@@ -82,9 +85,11 @@ jobs:
8285
opam exec -- sed -i ' ' tests/sources/*.elpi
8386
& "$Env:CYGWIN_ROOT/setup-x86_64.exe" -q -P time
8487
& "$Env:CYGWIN_ROOT/setup-x86_64.exe" -q -P which
88+
& "$Env:CYGWIN_ROOT/setup-x86_64.exe" -q -P wdiff
8589
opam exec -- which which
8690
opam exec -- time which
8791
opam exec -- which time
92+
opam exec -- which wdiff
8893
8994
# Build ######################################################################
9095
#

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# v1.17.4 (October 2023)
2+
3+
Requires Menhir 20211230 and OCaml 4.08 or above.
4+
Camlp5 8.0 or above is optional.
5+
6+
Parser:
7+
- Fix location handling (used to ignore the char count of the initial loc)
8+
19
# v1.17.3 (September 2023)
210

311
Requires Menhir 20211230 and OCaml 4.08 or above.

src/parser/parse.ml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,16 @@ let to_lexing_loc { Util.Loc.source_name; line; line_starts_at; source_start; _
9292
pos_bol = line_starts_at;
9393
pos_cnum = source_start; }
9494

95+
let lexing_set_position lexbuf loc =
96+
let loc = to_lexing_loc loc in
97+
let open Lexing in
98+
lexbuf.lex_curr_p <- { loc with pos_fname = lexbuf.lex_curr_p.pos_fname };
99+
lexbuf.lex_abs_pos <- loc.pos_cnum;
100+
lexbuf.lex_start_p <- loc;
101+
lexbuf.lex_curr_p <- loc
102+
95103
let goal_from ~loc lexbuf =
96-
let lexbuf = { lexbuf with Lexing.lex_start_p = to_lexing_loc loc } in
97-
let lexbuf = { lexbuf with Lexing.lex_curr_p = to_lexing_loc loc } in
104+
lexing_set_position lexbuf loc;
98105
snd @@ parse Grammar.goal "" lexbuf
99106

100107
let goal ~loc ~text =
@@ -103,8 +110,7 @@ let goal ~loc ~text =
103110

104111
let program_from ~loc lexbuf =
105112
Hashtbl.clear already_parsed;
106-
let lexbuf = { lexbuf with Lexing.lex_start_p = to_lexing_loc loc } in
107-
let lexbuf = { lexbuf with Lexing.lex_curr_p = to_lexing_loc loc } in
113+
lexing_set_position lexbuf loc;
108114
snd @@ parse Grammar.program "" lexbuf
109115

110116
let program ~file =

0 commit comments

Comments
 (0)