mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-25 21:37:48 +00:00
Improve parsing of scalar literals
* Unify parsing of string literals and scalar literals, to (e.g.) ensure escapes are handled uniformly. Notably, this makes unicode escapes valid in scalar literals.
* Add a variety of custom error messages about specific failure cases of parsing string/scalar literals. For example, if we're expecting a string (e.g. a package name in the header) and the user tried using single quotes, give a clear message about that.
* Fix formatting of unicode escapes (they previously used {}, now correctly use () to match roc strings)
This commit is contained in:
parent
6fc593142d
commit
94070e8ba6
22 changed files with 411 additions and 173 deletions
1
crates/compiler/test_syntax/fuzz/Cargo.lock
generated
1
crates/compiler/test_syntax/fuzz/Cargo.lock
generated
|
|
@ -448,7 +448,6 @@ dependencies = [
|
|||
"roc_module",
|
||||
"roc_parse",
|
||||
"roc_region",
|
||||
"roc_test_utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Expr(Str(EndlessMulti(@3), @0), @0)
|
||||
Expr(Str(EndlessMultiLine(@3), @0), @0)
|
||||
|
|
@ -1 +1 @@
|
|||
Expr(Str(EndlessSingle(@1), @0), @0)
|
||||
Expr(Str(EndlessSingleLine(@1), @0), @0)
|
||||
|
|
@ -0,0 +1 @@
|
|||
'\u(7)'
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
SingleQuote(
|
||||
"\u{7}",
|
||||
)
|
||||
|
|
@ -0,0 +1 @@
|
|||
''
|
||||
|
|
@ -258,6 +258,7 @@ mod test_snapshots {
|
|||
pass/comment_before_op.expr,
|
||||
pass/comment_inside_empty_list.expr,
|
||||
pass/comment_with_non_ascii.expr,
|
||||
pass/control_characters_in_scalar.expr,
|
||||
pass/crash.expr,
|
||||
pass/dbg.expr,
|
||||
pass/def_without_newline.expr,
|
||||
|
|
@ -567,7 +568,7 @@ mod test_snapshots {
|
|||
("\\n", EscapedChar::Newline),
|
||||
("\\r", EscapedChar::CarriageReturn),
|
||||
("\\t", EscapedChar::Tab),
|
||||
("\\\"", EscapedChar::Quote),
|
||||
("\\\"", EscapedChar::DoubleQuote),
|
||||
] {
|
||||
let actual = parse_expr_with(&arena, arena.alloc(to_input(string)));
|
||||
let expected_slice = to_expected(*escaped, &arena);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue