Skip to content

Commit 589a033

Browse files
authored
Merge pull request #299 from LPCIC/fix-loc
Fix loc
2 parents b7d173c + a2f411f commit 589a033

File tree

5 files changed

+194
-170
lines changed

5 files changed

+194
-170
lines changed

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# v2.0.5 (December 2024)
2+
3+
4+
Requires Menhir 20211230 and OCaml 4.13 or above.
5+
6+
- Parser:
7+
- Fix loc issues involving quotations
8+
19
# v2.0.4 (November 2024)
210

311

src/parser/lexer.mll.in

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
open Elpi_lexer_config.Tokens
66
exception Error of string
77

8+
let real_skip b n =
9+
let open Lexing in
10+
b.lex_curr_p <- { b.lex_curr_p with pos_cnum = b.lex_curr_p.pos_cnum + n };
11+
b.lex_start_p <- { b.lex_start_p with pos_cnum = b.lex_start_p.pos_cnum + n }
12+
813
let new_line b =
914
Lexing.new_line b
1015

11-
let skip b n =
12-
let open Lexing in
13-
b.lex_curr_p <- { b.lex_curr_p with pos_cnum = b.lex_curr_p.pos_cnum + n }
14-
1516
let start_token f b =
1617
let open Lexing in
1718
let start = b.lex_start_pos in
@@ -68,65 +69,64 @@ let symbcharplus = symbchar +
6869
rule linecomment = parse
6970
| '\n' { new_line lexbuf; token lexbuf }
7071
| eof { token lexbuf }
71-
| "elpi:skip " (pnum as n) { skip lexbuf 10; skip lexbuf (String.length n); linecomment_skip (int_of_string n) lexbuf }
72-
| "elpi:if" (' '+ as sp1) "version" (' '+ as sp2) (['<' '>' '='] as op) (' '+ as sp3) (pnum as ma) "." (pnum as mi) "." (pnum as p) {
73-
skip lexbuf (7+7+1); skip lexbuf String.(length ma + length mi + length p + length sp1 + length sp2 + length sp3);
72+
| "elpi:skip " (pnum as n) { linecomment_skip (int_of_string n) lexbuf }
73+
| "elpi:if" (' '+) "version" (' '+) (['<' '>' '='] as op) (' '+) (pnum as ma) "." (pnum as mi) "." (pnum as p) {
7474
if not @@ version_test op ma mi p then linecomment_if lexbuf else linecomment_drop lexbuf }
75-
| ' ' { skip lexbuf 1; linecomment lexbuf }
76-
| _ { skip lexbuf 1; linecomment_drop lexbuf }
75+
| ' ' { linecomment lexbuf }
76+
| _ { linecomment_drop lexbuf }
7777

7878
and linecomment_drop = parse
7979
| '\n' { new_line lexbuf; token lexbuf }
8080
| eof { token lexbuf }
81-
| _ { skip lexbuf 1; linecomment_drop lexbuf }
81+
| _ { linecomment_drop lexbuf }
8282

8383
and linecomment_skip skipno = parse
8484
| '\n' { new_line lexbuf; if skipno > 0 then skip_lines skipno lexbuf else token lexbuf }
8585
| eof { token lexbuf }
86-
| _ { skip lexbuf 1; linecomment_skip skipno lexbuf }
86+
| _ { linecomment_skip skipno lexbuf }
8787

8888
and linecomment_if = parse
8989
| '\n' { new_line lexbuf; skip_lines_endif lexbuf }
9090
| eof { token lexbuf }
91-
| _ { skip lexbuf 1; linecomment_if lexbuf }
91+
| _ { linecomment_if lexbuf }
9292

9393
and skip_lines_endif = parse
9494
| '\n' { new_line lexbuf; skip_lines_endif lexbuf }
95-
| '%' (' '+ as sp) "elpi:endif" { skip lexbuf (1 + (String.length sp) + 10); token lexbuf }
95+
| '%' (' '+) "elpi:endif" { token lexbuf }
9696
| eof { token lexbuf }
97-
| _ { skip lexbuf 1; skip_lines_endif lexbuf }
97+
| _ { skip_lines_endif lexbuf }
9898

9999
and skip_lines skipno = parse
100100
| '\n' { new_line lexbuf; let skipno = skipno - 1 in if skipno > 0 then skip_lines skipno lexbuf else token lexbuf }
101101
| eof { token lexbuf }
102-
| _ { skip lexbuf 1; skip_lines skipno lexbuf }
102+
| _ { skip_lines skipno lexbuf }
103103

104104
and multilinecomment nest = parse
105105
| '\n' { new_line lexbuf; multilinecomment nest lexbuf }
106106
| "*/" { if nest = 0 then token lexbuf else multilinecomment (nest - 1) lexbuf }
107107
| "/*" { multilinecomment (nest+1) lexbuf }
108-
| _ { skip lexbuf 1; multilinecomment nest lexbuf }
108+
| _ { multilinecomment nest lexbuf }
109109

110110
and string b = parse
111111
| '\n' { Buffer.add_char b '\n'; new_line lexbuf; string b lexbuf }
112-
| '\\' 'n' { Buffer.add_char b '\n'; skip lexbuf 2; string b lexbuf }
113-
| '\\' 'b' { Buffer.add_char b '\b'; skip lexbuf 2; string b lexbuf }
114-
| '\\' 't' { Buffer.add_char b '\t'; skip lexbuf 2; string b lexbuf }
115-
| '\\' 'r' { Buffer.add_char b '\r'; skip lexbuf 2; string b lexbuf }
116-
| '\\' '\\' { Buffer.add_char b '\\'; skip lexbuf 2; string b lexbuf }
117-
| '\\' '"' { Buffer.add_char b '"'; skip lexbuf 2; string b lexbuf }
118-
| '"' '"' { Buffer.add_char b '"'; skip lexbuf 2; string b lexbuf }
112+
| '\\' 'n' { Buffer.add_char b '\n'; string b lexbuf }
113+
| '\\' 'b' { Buffer.add_char b '\b'; string b lexbuf }
114+
| '\\' 't' { Buffer.add_char b '\t'; string b lexbuf }
115+
| '\\' 'r' { Buffer.add_char b '\r'; string b lexbuf }
116+
| '\\' '\\' { Buffer.add_char b '\\'; string b lexbuf }
117+
| '\\' '"' { Buffer.add_char b '"'; string b lexbuf }
118+
| '"' '"' { Buffer.add_char b '"'; string b lexbuf }
119119
| '"' { STRING (Buffer.contents b) }
120-
| _ # '"' as c { Buffer.add_char b c; skip lexbuf 1; string b lexbuf }
120+
| _ # '"' as c { Buffer.add_char b c; string b lexbuf }
121121

122122
and quoted n = parse
123-
| '{' { skip lexbuf 1; quoted (n+1) lexbuf }
124-
| '\n' { let b = Buffer.create 80 in Buffer.add_char b '\n'; skip lexbuf 1; new_line lexbuf; quoted_inner b n 0 lexbuf }
125-
| _ as c { let b = Buffer.create 80 in Buffer.add_char b c; skip lexbuf 1; quoted_inner b n 0 lexbuf }
123+
| '{' { quoted (n+1) lexbuf }
124+
| '\n' { let b = Buffer.create 80 in Buffer.add_char b '\n'; new_line lexbuf; quoted_inner b n 0 lexbuf }
125+
| _ as c { let b = Buffer.create 80 in Buffer.add_char b c; quoted_inner b n 0 lexbuf }
126126

127127
and quoted_inner b n l = parse
128128
| '}' {
129-
Buffer.add_char b '}'; skip lexbuf 1;
129+
Buffer.add_char b '}';
130130
try lookahead_close b (n-1) lexbuf;
131131
if l = 0 then begin
132132
lexbuf.lex_curr_p <- { lexbuf.lex_curr_p with pos_cnum = lexbuf.lex_curr_p.pos_cnum - 1};
@@ -136,7 +136,7 @@ and quoted_inner b n l = parse
136136
with Failure _ -> quoted_inner b n l lexbuf
137137
}
138138
| '{' {
139-
Buffer.add_char b '{'; skip lexbuf 1;
139+
Buffer.add_char b '{';
140140
try lookahead_open b (n-1) lexbuf; quoted_inner b n (l+1) lexbuf
141141
with Failure _ -> quoted_inner b n l lexbuf
142142
}
@@ -145,13 +145,13 @@ and quoted_inner b n l = parse
145145

146146
and lookahead_close b n = parse
147147
| '}' {
148-
Buffer.add_char b '}'; skip lexbuf 1;
148+
Buffer.add_char b '}'; real_skip lexbuf 1;
149149
if n = 1 then () else lookahead_close b (n-1) lexbuf
150150
}
151151

152152
and lookahead_open b n = parse
153153
| '{' {
154-
Buffer.add_char b '{'; skip lexbuf 1;
154+
Buffer.add_char b '{'; real_skip lexbuf 1;
155155
if n = 1 then () else lookahead_open b (n-1) lexbuf
156156
}
157157

@@ -167,7 +167,7 @@ and token = parse
167167
lexbuf.lex_abs_pos <- - (String.length x) - lexbuf.lex_start_p.pos_cnum;
168168
lexbuf.lex_start_p <- lexbuf.lex_curr_p;
169169
token lexbuf }
170-
| ( ' ' | '\t' | '\r' ) { skip lexbuf 1; token lexbuf }
170+
| ( ' ' | '\t' | '\r' ) { token lexbuf }
171171
| '\n' { new_line lexbuf; token lexbuf }
172172
| '%' { linecomment lexbuf }
173173
| "/*" { multilinecomment 0 lexbuf }
@@ -189,7 +189,7 @@ and token = parse
189189
| "{" { LCURLY }
190190
| "}" { RCURLY }
191191
| "|" { PIPE }
192-
| "{{" { start_token (fun b -> skip b 2; quoted 2 b) lexbuf }
192+
| "{{" { start_token (fun b -> quoted 2 b) lexbuf }
193193
| (("i" | "o") as s) ':' { IO_COLON s }
194194
| ("i" | "o") as s { IO s }
195195
| "shorten" { SHORTEN }

src/parser/parse.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ let lexing_set_position lexbuf loc =
107107
let open Lexing in
108108
lexbuf.lex_abs_pos <- loc.pos_cnum;
109109
lexbuf.lex_start_p <- loc;
110-
lexbuf.lex_curr_p <- { loc with pos_cnum = loc.pos_cnum + 1 }
110+
lexbuf.lex_curr_p <- loc
111111

112112
let goal_from ~loc lexbuf =
113113
lexing_set_position lexbuf loc;

src/parser/test_lexer.ml

Lines changed: 80 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,14 @@ let error s n msg =
9999
Printf.eprintf "lexing '%s' at char %d: %s\n" s n msg;
100100
exit 1
101101

102-
let validate s (tok1,lnum1,bol1,cnum1) (tok2,lnum2, bol2, cnum2) =
102+
let validate s (tok1,lnum1,bol1,bnum1,cnum1) (tok2,lnum2, bol2, bnum2,cnum2) =
103103
if tok1 <> tok2 then error s cnum2 (Printf.sprintf "wrong token: got %s instead of %s" (show tok2) (show tok1));
104104
if lnum1 <> lnum2 then error s cnum2 (Printf.sprintf "wrong line number: got %d instead of %d" lnum2 lnum1);
105-
if bol1 <> bol2 then error s cnum2 (Printf.sprintf "wrong begin of line: got %d instead of %d" bol2 bol1);
106-
if cnum1 <> cnum2 then error s cnum2 (Printf.sprintf "wrong char count: got %d instead of %d" cnum2 cnum1)
105+
if bnum1 <> bnum2 then error s bnum2 (Printf.sprintf "wrong char begin count: got %d instead of %d" bnum2 bnum1);
106+
if cnum1 <> cnum2 then error s cnum2 (Printf.sprintf "wrong char end count: got %d instead of %d" cnum2 cnum1);
107+
if bol1 <> bol2 then error s cnum2 (Printf.sprintf "wrong begin of line: got %d instead of %d" bol2 bol1)
107108

108-
type exp = T of t * int * int * int | E
109+
type exp = T of t * int * int * int * int | E
109110

110111
let rec expect s b = function
111112
| [] -> ()
@@ -114,95 +115,108 @@ let rec expect s b = function
114115
let tok2 = Lexer.token b in
115116
let open Lexing in
116117
let p = b.lex_curr_p in
117-
let lnum2, bol2, cnum2 = p.pos_lnum, p.pos_bol, p.pos_cnum in
118+
let lnum2, bol2, bnum2, cnum2 = p.pos_lnum, p.pos_bol, b.lex_start_p.pos_cnum, p.pos_cnum in
118119
match sp with
119-
| T (tok1,lnum1,bol1,cnum1) -> validate s (tok1,lnum1,bol1,cnum1) (tok2,lnum2, bol2, cnum2)
120+
| T (tok1,lnum1,bol1,bnum1,cnum1) -> validate s (tok1,lnum1,bol1,bnum1,cnum1) (tok2,lnum2, bol2, bnum2, cnum2)
120121
| E -> error s cnum2 (Printf.sprintf "wrong lexing: got %s instead of error" (show tok2))
121122
with Failure _ ->
122123
match sp with
123124
| E -> ()
124-
| T (tok1,_,_,cnum1) -> error s cnum1 (Printf.sprintf "wrong lexing: got error instead of %s" (show tok1))
125+
| T (tok1,_,_,_,cnum1) -> error s cnum1 (Printf.sprintf "wrong lexing: got error instead of %s" (show tok1))
125126
end;
126127
expect s b spec
127128

128129
let test s spec =
129130
let s = Str.global_replace (Str.regexp_string "\r") "" s in
130131
let b = Lexing.from_string s in
132+
Printf.eprintf "=============================\n";
131133
expect s b spec
132134

133135
let () =
136+
134137
(* 01234567890123456789012345 *)
135-
test "3.4" [T(FLOAT 3.4, 1, 0, 3)];
136-
test " 3.4" [T(FLOAT 3.4, 1, 0, 4)];
137-
test "\n3.4" [T(FLOAT 3.4, 2, 1, 4)];
138-
test "3.4 .5" [T(FLOAT 3.4, 1, 0, 3); T(FLOAT 0.5, 1, 0, 6)];
139-
test "3.4\n .5" [T(FLOAT 3.4, 1, 0, 3); T(FLOAT 0.5, 2, 4, 7)];
138+
test "3.4" [T(FLOAT 3.4, 1, 0, 0, 3)];
139+
test " 3.4" [T(FLOAT 3.4, 1, 0, 1, 4)];
140+
test "\n3.4" [T(FLOAT 3.4, 2, 1, 1, 4)];
141+
test "3.4 .5" [T(FLOAT 3.4, 1, 0, 0, 3); T(FLOAT 0.5, 1, 0, 4, 6)];
142+
test "3.4\n .5" [T(FLOAT 3.4, 1, 0, 0, 3); T(FLOAT 0.5, 2, 4, 5, 7)];
140143
(* 01234567890123456789012345 *)
141-
test "3 .4" [T(INTEGER 3, 1, 0, 1); T(FLOAT 0.4, 1, 0, 4)];
142-
test "3..4" [T(INTEGER 3, 1, 0, 1); T(FULLSTOP, 1, 0, 2); T(FLOAT 0.4, 1, 0, 4)];
143-
test "3." [T(INTEGER 3, 1, 0, 1); T(FULLSTOP, 1, 0, 2)];
144-
test "-3." [T(INTEGER (-3), 1, 0, 2); T(FULLSTOP, 1, 0, 3)];
144+
test "3 .4" [T(INTEGER 3, 1, 0, 0, 1); T(FLOAT 0.4, 1, 0, 2, 4)];
145+
test "3..4" [T(INTEGER 3, 1, 0, 0, 1); T(FULLSTOP, 1, 0, 1, 2); T(FLOAT 0.4, 1, 0, 2, 4)];
146+
test "3." [T(INTEGER 3, 1, 0, 0, 1); T(FULLSTOP, 1, 0, 1, 2)];
147+
test "-3." [T(INTEGER (-3), 1, 0, 0, 2); T(FULLSTOP, 1, 0, 2, 3)];
145148
(* 01234567890123456789012345 *)
146-
test "3%...\n3" [T(INTEGER 3, 1, 0, 1); T(INTEGER 3, 2, 6, 7)];
147-
test "3/*..*/3" [T(INTEGER 3, 1, 0, 1); T(INTEGER 3, 1, 0, 8)];
148-
test "3/** T **/3" [T(INTEGER 3, 1, 0, 1); T(INTEGER 3, 1, 0, 11)];
149-
test "3/*\n.*/3" [T(INTEGER 3, 1, 0, 1); T(INTEGER 3, 2, 4, 8)];
150-
test "3/*\n/*\n*/*/3" [T(INTEGER 3, 1, 0, 1); T(INTEGER 3, 3, 7, 12)];
151-
test "3/*" [T(INTEGER 3, 1, 0, 1); E];
149+
test "3%...\n3" [T(INTEGER 3, 1, 0, 0, 1); T(INTEGER 3, 2, 6, 6, 7)];
150+
test "3/*..*/3" [T(INTEGER 3, 1, 0, 0, 1); T(INTEGER 3, 1, 0, 7, 8)];
151+
test "3/** T **/3" [T(INTEGER 3, 1, 0, 0, 1); T(INTEGER 3, 1, 0, 10, 11)];
152+
test "3/*\n.*/3" [T(INTEGER 3, 1, 0, 0, 1); T(INTEGER 3, 2, 4, 7, 8)];
153+
test "3/*\n/*\n*/*/3" [T(INTEGER 3, 1, 0, 0, 1); T(INTEGER 3, 3, 7, 11, 12)];
154+
test "3/*" [T(INTEGER 3, 1, 0, 0, 1); E];
152155
(* 01234567890123456789012345 *)
153-
test {|"a"|} [T(STRING "a", 1, 0, 3)];
154-
test {|"a""b"|} [T(STRING "a\"b", 1, 0, 6)];
155-
test {|"a\nb"|} [T(STRING "a\nb", 1, 0, 6)];
156+
test {|"a"|} [T(STRING "a", 1, 0, 0, 3)];
157+
test {|"a""b"|} [T(STRING "a\"b", 1, 0, 0, 6)];
158+
test {|"a\nb"|} [T(STRING "a\nb", 1, 0, 0, 6)];
156159
test {|"a
157-
b"|} [T(STRING "a\nb", 2, 3, 5)];
160+
b"|} [T(STRING "a\nb", 2, 3, 0, 5)];
161+
(* 01234567890123456789012345 *)
162+
test "x" [T(CONSTANT "x", 1, 0, 0, 1)];
163+
test " x" [T(CONSTANT "x", 1, 0, 1, 2)];
164+
test "xx" [T(CONSTANT "xx", 1, 0, 0, 2)];
165+
test " xx" [T(CONSTANT "xx", 1, 0, 1, 3)];
166+
167+
test "x-y" [T(CONSTANT "x-y", 1, 0, 0,3)];
168+
test "-y" [T(MINUS, 1, 0, 0,1); T(CONSTANT "y",1,0,1,2)];
169+
test "_y" [T(CONSTANT "_y", 1, 0, 0,2)];
170+
test "_X" [T(CONSTANT "_X", 1, 0, 0,2)];
171+
test "X_" [T(CONSTANT "X_", 1, 0, 0,2)];
172+
test "x?" [T(CONSTANT "x?", 1, 0, 0,2)];
173+
test "X" [T(CONSTANT "X", 1, 0, 0,1)];
174+
test "X1>@!" [T(CONSTANT "X1>@!", 1, 0, 0,5)];
175+
test "a.B.c" [T(CONSTANT "a.B.c", 1, 0, 0,5)];
176+
test "a.B." [T(CONSTANT "a.B", 1, 0, 0,3); T(FULLSTOP, 1, 0, 3, 4)];
177+
test "a. >" [T(CONSTANT "a", 1, 0, 0,1); T(FULLSTOP, 1, 0, 1, 2); T(FAMILY_GT ">", 1, 0, 3,4)];
158178
(* 01234567890123456789012345 *)
159-
test "x" [T(CONSTANT "x", 1, 0, 1)];
160-
test "x-y" [T(CONSTANT "x-y", 1, 0, 3)];
161-
test "-y" [T(MINUS, 1, 0, 1); T(CONSTANT "y",1,0,2)];
162-
test "_y" [T(CONSTANT "_y", 1, 0, 2)];
163-
test "_X" [T(CONSTANT "_X", 1, 0, 2)];
164-
test "X_" [T(CONSTANT "X_", 1, 0, 2)];
165-
test "x?" [T(CONSTANT "x?", 1, 0, 2)];
166-
test "X" [T(CONSTANT "X", 1, 0, 1)];
167-
test "X1>@!" [T(CONSTANT "X1>@!", 1, 0, 5)];
168-
test "a.B.c" [T(CONSTANT "a.B.c", 1, 0, 5)];
169-
test "a.B." [T(CONSTANT "a.B", 1, 0, 3); T(FULLSTOP, 1, 0, 4)];
170-
test "a. >" [T(CONSTANT "a", 1, 0, 1); T(FULLSTOP, 1, 0, 2); T(FAMILY_GT ">", 1, 0, 4)];
179+
test "-->" [T(FAMILY_MINUS "-->", 1, 0, 0,3)];
180+
test "x.y->z" [T(CONSTANT "x.y->z", 1, 0, 0,6)];
171181
(* 01234567890123456789012345 *)
172-
test "-->" [T(FAMILY_MINUS "-->", 1, 0, 3)];
173-
test "x.y->z" [T(CONSTANT "x.y->z", 1, 0, 6)];
182+
test "{{{ }} }}}" [T(QUOTED (3," }} "), 1, 0, 0,10)];
183+
test "{{ {{ } }} }}" [T(QUOTED (2," {{ } }} "), 1, 0, 0,13)];
184+
174185
(* 01234567890123456789012345 *)
175-
test "{{{ }} }}}" [T(QUOTED (3," }} "), 1, 0, 10)];
176-
test "{{ {{ } }} }}" [T(QUOTED (2," {{ } }} "), 1, 0, 13)];
177-
test "{{ x }}3" [T(QUOTED (2," x "), 1, 0, 7); T(INTEGER 3, 1, 0, 8)];
178-
test "{{{ x }}}3" [T(QUOTED (3," x "), 1, 0, 9); T(INTEGER 3, 1, 0, 10)];
179-
test "{{\n x }}3" [T(QUOTED (2,"\n x "), 2, 4, 8); T(INTEGER 3, 2, 4, 9)];
186+
test "{{ x }}3" [T(QUOTED (2," x "), 1, 0, 0, 7); T(INTEGER 3, 1, 0, 7, 8)];
187+
test "2{{ x }}" [T(INTEGER 2, 1, 0, 0, 1); T(QUOTED (2," x "), 1, 0, 1, 8)];
188+
test "2 {{ x }}" [T(INTEGER 2, 1, 0, 0, 1); T(QUOTED (2," x "), 1, 0, 2, 9)];
189+
test "{{{ x }}}3" [T(QUOTED (3," x "), 1, 0, 0, 9); T(INTEGER 3, 1, 0, 9, 10)];
190+
test "{{\n x }}3" [T(QUOTED (2,"\n x "), 2, 3, 0, 8); T(INTEGER 3, 2, 3, 8, 9)];
191+
180192
(* 01234567890123456789012345 *)
181-
test "foo :- bar." [T(CONSTANT "foo", 1, 0, 3); T(VDASH, 1, 0, 6); T(CONSTANT "bar", 1, 0, 10); T(FULLSTOP, 1, 0, 11)];
182-
test "foo ?- bar." [T(CONSTANT "foo", 1, 0, 3); T(QDASH, 1, 0, 6); T(CONSTANT "bar", 1, 0, 10); T(FULLSTOP, 1, 0, 11)];
183-
test "foo :- x \\ bar." [T(CONSTANT "foo", 1, 0, 3); T(VDASH, 1, 0, 6); T(CONSTANT "x", 1, 0, 8); T(BIND, 1, 0, 10); T(CONSTANT "bar", 1, 0, 14); T(FULLSTOP, 1, 0, 15)];
184-
test "foo, bar" [T(CONSTANT "foo", 1, 0, 3); T(CONJ, 1, 0, 4); T(CONSTANT "bar", 1, 0, 8) ];
185-
test "foo & bar" [T(CONSTANT "foo", 1, 0, 3); T(CONJ2, 1, 0, 5); T(CONSTANT "bar", 1, 0, 9) ];
186-
test "[]" [T(LBRACKET, 1, 0, 1); T(RBRACKET, 1, 0, 2)];
193+
test "foo :- bar." [T(CONSTANT "foo", 1, 0, 0,3); T(VDASH, 1, 0, 4,6); T(CONSTANT "bar", 1, 0, 7,10); T(FULLSTOP, 1, 0, 10,11)];
194+
test "foo ?- bar." [T(CONSTANT "foo", 1, 0, 0,3); T(QDASH, 1, 0, 4,6); T(CONSTANT "bar", 1, 0, 7,10); T(FULLSTOP, 1, 0, 10,11)];
195+
test "foo :- x \\ bar." [T(CONSTANT "foo", 1, 0, 0,3); T(VDASH, 1, 0, 4,6); T(CONSTANT "x", 1, 0, 7,8); T(BIND, 1, 0, 9,10); T(CONSTANT "bar", 1, 0, 11,14); T(FULLSTOP, 1, 0, 14,15)];
196+
test "foo, bar" [T(CONSTANT "foo", 1, 0, 0,3); T(CONJ, 1, 0, 3,4); T(CONSTANT "bar", 1, 0, 5,8) ];
197+
test "foo & bar" [T(CONSTANT "foo", 1, 0, 0,3); T(CONJ2, 1, 0, 4,5); T(CONSTANT "bar", 1, 0, 6,9) ];
198+
test "[]" [T(LBRACKET, 1, 0, 0,1); T(RBRACKET, 1, 0, 1,2)];
187199
(* 01234567890123456789012345 *)
188-
test "X" [T(CONSTANT "X", 1, 0, 1) ];
189-
test "is" [T(IS, 1, 0, 2) ];
190-
test "#line 3 \"xx\"\na" [T(CONSTANT "a", 3, 0, 1) ];
191-
test "b\n#line 3 \"xx\"\na" [T(CONSTANT "b", 1, 0, 1);T(CONSTANT "a", 3, 2, 1) ];
200+
test "X" [T(CONSTANT "X", 1, 0, 0,1) ];
201+
test "is" [T(IS, 1, 0, 0,2) ];
202+
test "#line 3 \"xx\"\na" [T(CONSTANT "a", 3, 0, 0,1) ];
203+
test "b\n#line 3 \"xx\"\na" [T(CONSTANT "b", 1, 0, 0,1);T(CONSTANT "a", 3, 2, 0,1) ];
192204
test {|
193205
b
194206
c
195207
#line 7 "xx"
196-
a|} [T(CONSTANT "b", 2, 1, 2);T(CONSTANT "c", 3, 3, 4);T(CONSTANT "a", 7, 5, 1) ];
208+
a|} [T(CONSTANT "b", 2, 1, 1,2);T(CONSTANT "c", 3, 3, 3,4);T(CONSTANT "a", 7, 5, 0,1) ];
209+
197210
(* 01234567890123456789012345 *)
198-
test ":name" [T(COLON,1,0,1); T(NAME,1,0,5)];
199-
test "@foo" [T(CONSTANT "@foo",1,0,4)];
200-
test "a && b" [T(CONSTANT "a",1,0,1);T(FAMILY_AND "&&",1,0,4);T(CONSTANT "b",1,0,6)];
211+
test ":name" [T(COLON,1,0,0,1); T(NAME,1,0,1,5)];
212+
test "@foo" [T(CONSTANT "@foo",1,0,0,4)];
213+
test "a && b" [T(CONSTANT "a",1,0,0,1);T(FAMILY_AND "&&",1,0,2,4);T(CONSTANT "b",1,0,5,6)];
214+
201215
(* 01234567890123456789012345 *)
202-
test "i:" [T(IO_COLON 'i', 1, 0, 2)];
203-
test "o:" [T(IO_COLON 'o', 1, 0, 2)];
204-
test "i :" [T(IO 'i', 1, 0, 1); T(COLON,1,0,3)];
205-
test "o :" [T(IO 'o', 1, 0, 1); T(COLON,1,0,3)];
206-
test "i" [T(IO 'i', 1, 0, 1)];
207-
test "o" [T(IO 'o', 1, 0, 1)];
208-
test "func" [T(FUNC, 1, 0, 4)];
216+
test "i:" [T(IO_COLON 'i', 1, 0, 0,2)];
217+
test "o:" [T(IO_COLON 'o', 1, 0, 0,2)];
218+
test "i :" [T(IO 'i', 1, 0, 0,1); T(COLON,1,0,2,3)];
219+
test "o :" [T(IO 'o', 1, 0, 0,1); T(COLON,1,0,2,3)];
220+
test "i" [T(IO 'i', 1, 0, 0,1)];
221+
test "o" [T(IO 'o', 1, 0, 0,1)];
222+
test "func" [T(FUNC, 1, 0, 0,4)];

0 commit comments

Comments
 (0)