From 466b7e69e49a5f4bba36b834a2e046f120ece07c Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Sun, 2 Oct 2016 12:02:53 +0200 Subject: Move bullet detection from lexer to parser (bug #5102). That way, bullet detection no longer depends on a global variable indicating whether a line is starting. This causes a small change in the recognized language. Before the commit, "--++" was recognized as a bullet "--" followed by a keyword "++" when at the start of a line; now it is always recognized as a keyword "--++". This also fixes a bug in Tok.to_string as a side-effect. --- parsing/cLexer.ml4 | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'parsing/cLexer.ml4') diff --git a/parsing/cLexer.ml4 b/parsing/cLexer.ml4 index bec891f7f..fcdc37c08 100644 --- a/parsing/cLexer.ml4 +++ b/parsing/cLexer.ml4 @@ -479,14 +479,6 @@ let find_keyword loc id s = | None -> raise Not_found | Some c -> KEYWORD c -let process_sequence loc bp c cs = - let rec aux n cs = - match Stream.peek cs with - | Some c' when c == c' -> Stream.junk cs; aux (n+1) cs - | _ -> BULLET (String.make n c), set_loc_pos loc bp (Stream.count cs) - in - aux 1 cs - (* Must be a special token *) let process_chars loc bp c cs = let t = progress_from_byte loc None (-1) !token_tree cs c in @@ -552,12 +544,6 @@ let rec next_token loc = parser bp | _ -> () in (t, set_loc_pos loc bp ep) - | [< ' ('-'|'+'|'*' as c); s >] -> - let t,new_between_com = - if !between_com then process_sequence loc bp c s, true - else process_chars loc bp c s,false - in - comment_stop bp; between_com := new_between_com; t | [< ''?'; s >] ep -> let t = parse_after_qmark loc bp s in comment_stop bp; (t, set_loc_pos loc ep bp) -- cgit v1.2.3