From 5c16aa8dace54e63046acc41f6f4d890abb665e3 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Fri, 9 Mar 2018 16:10:07 -0500 Subject: [PATCH] Added logic to end range at end of chunk if range started but not ended --- .gitignore | 1 + colormap.ml | 3 ++- lex_cpp.mll | 2 +- main.ml | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 463750a..c9bcfae 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.o lex_*.ml tide-hl +tide-hl.rb diff --git a/colormap.ml b/colormap.ml index 68b3980..535a706 100644 --- a/colormap.ml +++ b/colormap.ml @@ -44,4 +44,5 @@ let range_start ctx = let range_stop ctx clr = Printf.printf "%d,%d,%d\n" - ctx.pos (lexeme_end ctx.lbuf) (get_color clr) + ctx.pos (lexeme_end ctx.lbuf) (get_color clr); + ctx.pos <- (-1) diff --git a/lex_cpp.mll b/lex_cpp.mll index 658b0da..4ac935f 100644 --- a/lex_cpp.mll +++ b/lex_cpp.mll @@ -57,6 +57,6 @@ and comment ctx = parse | eof { raise Eof } and preproc ctx = parse - | sys_incl { set_color ctx Constant } + | sys_incl { set_color ctx String } | _ { (* skip *) } | eof { raise Eof } diff --git a/main.ml b/main.ml index ae96314..52c2226 100644 --- a/main.ml +++ b/main.ml @@ -36,6 +36,7 @@ let rec scan_string lexfn string = let ctx = Colormap.({ lbuf = lbuf; pos = 0; }) in try while true do lexfn ctx lbuf done with Colormap.Eof -> + if ctx.pos >= 0 then Colormap.range_stop ctx Comment; Printf.printf "0,0,0\n"; flush stdout; scan_input lexfn -- 2.54.0