Skip to content

Commit

Permalink
lexer: update re2c
Browse files Browse the repository at this point in the history
use !entry instead of ^
  • Loading branch information
eilvelia committed Jan 25, 2025
1 parent 6d12aad commit 4311b66
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pkgs.mkShell {
src = fetchFromGitHub {
owner = "skvadrik";
repo = "re2c";
rev = "4fedb068c14c6a7aca023080ab90881af6688ce0";
hash = "sha256-NgwSUqnCbSNuYJcWvgILhEcf+N0jA4DUNs6QJ4/ORZ0=";
rev = "0e97d4917bcbdb8645cca2288c010b19c959278f";
hash = "sha256-q7Y68MfUrQZDM1bKleqgOD/P3R7WJY6jjXwFLBiX0V8=";
};
})
];
Expand Down
10 changes: 5 additions & 5 deletions src/lexer.ml.re
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ let rollback_start_to_newline st =
// Used in pretty-printing
re2c:YYFN = ["escape_string;string", "st;simple_state", "strbuf;Buffer.t"];

^ { st.yystart <- st.yycursor; }
!entry { st.yystart <- st.yycursor; }
[\n] { Buffer.add_string strbuf "\\n"; escape_string st strbuf }
[\r] { Buffer.add_string strbuf "\\r"; escape_string st strbuf }
[\t] { Buffer.add_string strbuf "\\t"; escape_string st strbuf }
Expand Down Expand Up @@ -358,7 +358,7 @@ let escape_string = function
(* Tokenizer *)

%{rules:tokenizer_base
^ { save_start_position st; }
!entry { save_start_position st; }
* { malformed_utf8 st }
%}

Expand Down Expand Up @@ -493,7 +493,7 @@ let multiline_contents strbuf =
%{local
re2c:YYFN = ["string;token", "st;tokenizer_state", "prefix;string"];

<single, multi> ^ { save_start_position st; }
<single, multi> !entry { save_start_position st; }
<multi> newline @t1 ws? / newline {
newline ~pos:st.t1 st;
(* Any newline is normalized to \n *)
Expand Down Expand Up @@ -566,7 +566,7 @@ let check_hashlen st exp_hashlen =
"exp_hashlen;int",
"prefix;string"];

<rsingle, rmulti> ^ { save_start_position st; }
<rsingle, rmulti> !entry { save_start_position st; }
<rmulti> newline @t1 ws? / newline {
newline ~pos:st.t1 st;
Buffer.add_char st.info.strbuf '\n';
Expand Down Expand Up @@ -609,7 +609,7 @@ let raw_string_singleline st exp_hashlen =
re2c:YYFN = ["main;token", "st;tokenizer_state"];

!use:tokenizer_base;
^ { save_token_position st; save_start_position st; }
!entry { save_token_position st; save_start_position st; }
ws { main st }
newline { newline st; NEWLINE }
"//" { singleline_comment st; NEWLINE }
Expand Down

0 comments on commit 4311b66

Please sign in to comment.