File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change 22
22
Lexing. pos_bol = p.Lexing. pos_cnum }
23
23
;;
24
24
25
+ let newline lexbuf =
26
+ lexbuf.Lexing. lex_curr_p
27
+ < - (bump_line lexbuf.Lexing. lex_curr_p)
28
+ ;;
29
+
25
30
let mach_suf_table = Hashtbl. create 0
26
31
;;
27
32
let _ =
@@ -155,8 +160,7 @@ let id = ['a'-'z' 'A'-'Z' '_']['a'-'z' 'A'-'Z' '0'-'9' '_']*
155
160
156
161
rule token = parse
157
162
ws+ { token lexbuf }
158
- | '\n' { lexbuf.Lexing. lex_curr_p
159
- < - (bump_line lexbuf.Lexing. lex_curr_p);
163
+ | '\n' { newline lexbuf;
160
164
token lexbuf }
161
165
| " //" [^ '\n' ]* { token lexbuf }
162
166
| " /*" { comment 1 lexbuf }
@@ -389,8 +393,9 @@ and bracequote buf depth = parse
389
393
bracequote buf depth lexbuf }
390
394
391
395
392
- | [^ '\\' '{' '}' ]+ { let s = Lexing. lexeme lexbuf in
393
- Buffer. add_string buf s;
396
+ | [^ '\\' '{' '}' ] as c { Buffer. add_char buf c;
397
+ if c = '\n'
398
+ then newline lexbuf;
394
399
bracequote buf depth lexbuf }
395
400
396
401
@@ -402,6 +407,7 @@ and comment depth = parse
402
407
then token lexbuf
403
408
else comment (depth-1 ) lexbuf }
404
409
405
- | '*' [^ '{' ] { comment depth lexbuf }
406
- | '/' [^ '*' ] { comment depth lexbuf }
407
- | [^ '/' '*' ]+ { comment depth lexbuf }
410
+ | '\n' { newline lexbuf;
411
+ comment depth lexbuf }
412
+
413
+ | _ { comment depth lexbuf }
Original file line number Diff line number Diff line change
1
+ // -*- rust -*-
2
+ // error-pattern:9:2:E
3
+
4
+ /* 1
5
+ * 2
6
+ * 3
7
+ */
8
+ fn main ( ) {
9
+ %; // parse error on line 9, but is reported on line 6 instead.
10
+ }
You can’t perform that action at this time.
0 commit comments