Remove some legacy stuff from the new dune lexer
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
d7ab3d962c
commit
1e5dc322e2
|
@ -8,8 +8,7 @@ let blank = [' ' '\t' '\012']
|
||||||
let digit = ['0'-'9']
|
let digit = ['0'-'9']
|
||||||
let hexdigit = ['0'-'9' 'a'-'f' 'A'-'F']
|
let hexdigit = ['0'-'9' 'a'-'f' 'A'-'F']
|
||||||
|
|
||||||
let atom_char =
|
let atom_char = [^ '%' ';' '(' ')' '"' '\000'-'\032' '\127'-'\255']
|
||||||
[^ '%' ';' '(' ')' '"' '\000'-'\032' '\127'-'\255']
|
|
||||||
|
|
||||||
rule token = parse
|
rule token = parse
|
||||||
| newline
|
| newline
|
||||||
|
@ -39,7 +38,7 @@ and start_quoted_string = parse
|
||||||
| "\\>"
|
| "\\>"
|
||||||
{ block_string_start Raw lexbuf }
|
{ block_string_start Raw lexbuf }
|
||||||
| ""
|
| ""
|
||||||
{ quoted_string New_syntax lexbuf }
|
{ quoted_string lexbuf }
|
||||||
|
|
||||||
and block_string_start kind = parse
|
and block_string_start kind = parse
|
||||||
| newline as s
|
| newline as s
|
||||||
|
@ -66,7 +65,7 @@ and block_string = parse
|
||||||
block_string_after_newline lexbuf
|
block_string_after_newline lexbuf
|
||||||
}
|
}
|
||||||
| '\\'
|
| '\\'
|
||||||
{ match escape_sequence New_syntax lexbuf with
|
{ match escape_sequence lexbuf with
|
||||||
| Newline -> block_string_after_newline lexbuf
|
| Newline -> block_string_after_newline lexbuf
|
||||||
| Other -> block_string lexbuf
|
| Other -> block_string lexbuf
|
||||||
}
|
}
|
||||||
|
@ -101,30 +100,28 @@ and raw_block_string = parse
|
||||||
{ Buffer.contents escaped_buf
|
{ Buffer.contents escaped_buf
|
||||||
}
|
}
|
||||||
|
|
||||||
and quoted_string mode = parse
|
and quoted_string = parse
|
||||||
| '"'
|
| '"'
|
||||||
{ Buffer.contents escaped_buf }
|
{ Buffer.contents escaped_buf }
|
||||||
| '\\'
|
| '\\'
|
||||||
{ match escape_sequence mode lexbuf with
|
{ match escape_sequence lexbuf with
|
||||||
| Newline -> quoted_string_after_escaped_newline mode lexbuf
|
| Newline -> quoted_string_after_escaped_newline lexbuf
|
||||||
| Other -> quoted_string mode lexbuf
|
| Other -> quoted_string lexbuf
|
||||||
}
|
}
|
||||||
| newline as s
|
| newline as s
|
||||||
{ Lexing.new_line lexbuf;
|
{ Lexing.new_line lexbuf;
|
||||||
Buffer.add_string escaped_buf s;
|
Buffer.add_string escaped_buf s;
|
||||||
quoted_string mode lexbuf
|
quoted_string lexbuf
|
||||||
}
|
}
|
||||||
| _ as c
|
| _ as c
|
||||||
{ Buffer.add_char escaped_buf c;
|
{ Buffer.add_char escaped_buf c;
|
||||||
quoted_string mode lexbuf
|
quoted_string lexbuf
|
||||||
}
|
}
|
||||||
| eof
|
| eof
|
||||||
{ if mode <> In_block_comment then
|
{ error lexbuf "unterminated quoted string"
|
||||||
error lexbuf "unterminated quoted string";
|
|
||||||
Buffer.contents escaped_buf
|
|
||||||
}
|
}
|
||||||
|
|
||||||
and escape_sequence mode = parse
|
and escape_sequence = parse
|
||||||
| newline
|
| newline
|
||||||
{ Lexing.new_line lexbuf;
|
{ Lexing.new_line lexbuf;
|
||||||
Newline }
|
Newline }
|
||||||
|
@ -142,44 +139,33 @@ and escape_sequence mode = parse
|
||||||
}
|
}
|
||||||
| (digit as c1) (digit as c2) (digit as c3)
|
| (digit as c1) (digit as c2) (digit as c3)
|
||||||
{ let v = eval_decimal_escape c1 c2 c3 in
|
{ let v = eval_decimal_escape c1 c2 c3 in
|
||||||
if mode <> In_block_comment && v > 255 then
|
if v > 255 then
|
||||||
error lexbuf "escape sequence in quoted string out of range"
|
error lexbuf "escape sequence in quoted string out of range"
|
||||||
~delta:(-1);
|
~delta:(-1);
|
||||||
Buffer.add_char escaped_buf (Char.chr v);
|
Buffer.add_char escaped_buf (Char.chr v);
|
||||||
Other
|
Other
|
||||||
}
|
}
|
||||||
| digit* as s
|
| digit digit digit
|
||||||
{ if mode <> In_block_comment then
|
{ error lexbuf "escape sequence in quoted string out of range" ~delta:(-1);
|
||||||
error lexbuf "unterminated decimal escape sequence" ~delta:(-1);
|
}
|
||||||
Buffer.add_char escaped_buf '\\';
|
| digit*
|
||||||
Buffer.add_string escaped_buf s;
|
{ error lexbuf "unterminated decimal escape sequence" ~delta:(-1);
|
||||||
Other
|
|
||||||
}
|
}
|
||||||
| 'x' (hexdigit as c1) (hexdigit as c2)
|
| 'x' (hexdigit as c1) (hexdigit as c2)
|
||||||
{ let v = eval_hex_escape c1 c2 in
|
{ let v = eval_hex_escape c1 c2 in
|
||||||
Buffer.add_char escaped_buf (Char.chr v);
|
Buffer.add_char escaped_buf (Char.chr v);
|
||||||
Other
|
Other
|
||||||
}
|
}
|
||||||
| 'x' hexdigit* as s
|
| 'x' hexdigit*
|
||||||
{ if mode <> In_block_comment then
|
{ error lexbuf "unterminated hexadecimal escape sequence" ~delta:(-1);
|
||||||
error lexbuf "unterminated hexadecimal escape sequence" ~delta:(-1);
|
|
||||||
Buffer.add_char escaped_buf '\\';
|
|
||||||
Buffer.add_string escaped_buf s;
|
|
||||||
Other
|
|
||||||
}
|
}
|
||||||
| _ as c
|
| _
|
||||||
{ if mode = New_syntax then
|
{ error lexbuf "unknown escape sequence" ~delta:(-1);
|
||||||
error lexbuf "unknown escape sequence" ~delta:(-1);
|
|
||||||
Buffer.add_char escaped_buf '\\';
|
|
||||||
Buffer.add_char escaped_buf c;
|
|
||||||
Other
|
|
||||||
}
|
}
|
||||||
| eof
|
| eof
|
||||||
{ if mode <> In_block_comment then
|
{ error lexbuf "unterminated escape sequence" ~delta:(-1);
|
||||||
error lexbuf "unterminated escape sequence" ~delta:(-1);
|
|
||||||
Other
|
|
||||||
}
|
}
|
||||||
|
|
||||||
and quoted_string_after_escaped_newline mode = parse
|
and quoted_string_after_escaped_newline = parse
|
||||||
| [' ' '\t']*
|
| [' ' '\t']*
|
||||||
{ quoted_string mode lexbuf }
|
{ quoted_string lexbuf }
|
||||||
|
|
Loading…
Reference in New Issue