Skip to content
Snippets Groups Projects
Commit 27a156f0 authored by Allan Blanchard's avatar Allan Blanchard
Browse files

[Parsing] Fixes location of errors for ghost else with comments

parent 875373ce
No related branches found
No related tags found
No related merge requests found
...@@ -347,6 +347,10 @@ let lex_comment remainder buffer lexbuf = ...@@ -347,6 +347,10 @@ let lex_comment remainder buffer lexbuf =
(match buffer with None -> () | Some b -> Buffer.add_string b s) ; (match buffer with None -> () | Some b -> Buffer.add_string b s) ;
remainder buffer lexbuf remainder buffer lexbuf
let error_count_lines comments =
let newline_if_n c = if c = '\n' then E.newline () in
String.iter newline_if_n comments
let do_lex_comment ?(first_string="") remainder lexbuf = let do_lex_comment ?(first_string="") remainder lexbuf =
let buffer = let buffer =
if Kernel.PrintComments.get () then begin if Kernel.PrintComments.get () then begin
...@@ -809,11 +813,13 @@ and msasmnobrace = parse ...@@ -809,11 +813,13 @@ and msasmnobrace = parse
cur ^ (msasmnobrace lexbuf) } cur ^ (msasmnobrace lexbuf) }
and annot_first_token = parse and annot_first_token = parse
| "ghost" (blank| '\n' | ("//" [^'\n']* '\n') )* "else" { | "ghost" ((blank| '\n' | ("//" [^'\n']* '\n') )* as comments) "else" {
if is_oneline_ghost () then E.parse_error "nested ghost code"; if is_oneline_ghost () then E.parse_error "nested ghost code";
Buffer.clear buf; Buffer.clear buf;
let loc = currentLoc () in
error_count_lines comments ;
enter_ghost_code (); enter_ghost_code ();
LGHOST_ELSE (currentLoc ()) LGHOST_ELSE (loc)
} }
| "ghost" { | "ghost" {
if is_oneline_ghost () then E.parse_error "nested ghost code"; if is_oneline_ghost () then E.parse_error "nested ghost code";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment