mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +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
|
@ -355,8 +355,10 @@ pub enum EExpr<'a> {
|
|||
|
||||
InParens(EInParens<'a>, Position),
|
||||
Record(ERecord<'a>, Position),
|
||||
|
||||
// SingleQuote errors are folded into the EString
|
||||
Str(EString<'a>, Position),
|
||||
SingleQuote(EString<'a>, Position),
|
||||
|
||||
Number(ENumber, Position),
|
||||
List(EList<'a>, Position),
|
||||
|
||||
|
@ -376,13 +378,24 @@ pub enum EString<'a> {
|
|||
CodePtOpen(Position),
|
||||
CodePtEnd(Position),
|
||||
|
||||
InvalidSingleQuote(ESingleQuote, Position),
|
||||
|
||||
Space(BadInputError, Position),
|
||||
EndlessSingle(Position),
|
||||
EndlessMulti(Position),
|
||||
EndlessSingleLine(Position),
|
||||
EndlessMultiLine(Position),
|
||||
EndlessSingleQuote(Position),
|
||||
UnknownEscape(Position),
|
||||
Format(&'a EExpr<'a>, Position),
|
||||
FormatEnd(Position),
|
||||
MultilineInsufficientIndent(Position),
|
||||
ExpectedDoubleQuoteGotSingleQuote(Position),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ESingleQuote {
|
||||
Empty,
|
||||
TooLong,
|
||||
InterpolationNotAllowed,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue