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/tok.ml | 7 ------- 1 file changed, 7 deletions(-) (limited to 'parsing/tok.ml') diff --git a/parsing/tok.ml b/parsing/tok.ml index 8ae106512..99d5c972c 100644 --- a/parsing/tok.ml +++ b/parsing/tok.ml @@ -18,7 +18,6 @@ type t = | INT of string | STRING of string | LEFTQMARK - | BULLET of string | EOI let equal t1 t2 = match t1, t2 with @@ -30,7 +29,6 @@ let equal t1 t2 = match t1, t2 with | INT s1, INT s2 -> string_equal s1 s2 | STRING s1, STRING s2 -> string_equal s1 s2 | LEFTQMARK, LEFTQMARK -> true -| BULLET s1, BULLET s2 -> string_equal s1 s2 | EOI, EOI -> true | _ -> false @@ -42,7 +40,6 @@ let extract_string = function | FIELD s -> s | INT s -> s | LEFTQMARK -> "?" - | BULLET s -> s | EOI -> "" let to_string = function @@ -53,7 +50,6 @@ let to_string = function | INT s -> Format.sprintf "INT %s" s | STRING s -> Format.sprintf "STRING %S" s | LEFTQMARK -> "LEFTQMARK" - | BULLET s -> Format.sprintf "STRING %S" s | EOI -> "EOI" let match_keyword kwd = function @@ -75,7 +71,6 @@ let of_pattern = function | "INT", s -> INT s | "STRING", s -> STRING s | "LEFTQMARK", _ -> LEFTQMARK - | "BULLET", s -> BULLET s | "EOI", _ -> EOI | _ -> failwith "Tok.of_pattern: not a constructor" @@ -87,7 +82,6 @@ let to_pattern = function | INT s -> "INT", s | STRING s -> "STRING", s | LEFTQMARK -> "LEFTQMARK", "" - | BULLET s -> "BULLET", s | EOI -> "EOI", "" let match_pattern = @@ -100,7 +94,6 @@ let match_pattern = | "INT", "" -> (function INT s -> s | _ -> err ()) | "STRING", "" -> (function STRING s -> s | _ -> err ()) | "LEFTQMARK", "" -> (function LEFTQMARK -> "" | _ -> err ()) - | "BULLET", "" -> (function BULLET s -> s | _ -> err ()) | "EOI", "" -> (function EOI -> "" | _ -> err ()) | pat -> let tok = of_pattern pat in -- cgit v1.2.3