mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
error messages for escaped things
This commit is contained in:
parent
41720ec5db
commit
2f4099f1f0
5 changed files with 218 additions and 31 deletions
|
@ -429,17 +429,17 @@ pub enum EString<'a> {
|
|||
Space(BadInputError, Row, Col),
|
||||
EndlessSingle(Row, Col),
|
||||
EndlessMulti,
|
||||
StringEscape(Escape),
|
||||
Format(&'a SyntaxError<'a>),
|
||||
UnknownEscape(Row, Col),
|
||||
Format(&'a SyntaxError<'a>, Row, Col),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Escape {
|
||||
EscapeUnknown,
|
||||
BadUnicodeFormat(u16),
|
||||
BadUnicodeCode(u16),
|
||||
BadUnicodeLength(u16, i32, i32),
|
||||
}
|
||||
// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
// pub enum Escape {
|
||||
// EscapeUnknown,
|
||||
// BadUnicodeFormat(u16),
|
||||
// BadUnicodeCode(u16),
|
||||
// BadUnicodeLength(u16, i32, i32),
|
||||
// }
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum ERecord<'a> {
|
||||
|
|
|
@ -2,8 +2,8 @@ use crate::ast::{EscapedChar, StrLiteral, StrSegment};
|
|||
use crate::expr;
|
||||
use crate::parser::Progress::*;
|
||||
use crate::parser::{
|
||||
allocated, ascii_char, loc, parse_utf8, specialize_ref, unexpected_eof, word1, BadInputError,
|
||||
EString, Escape, ParseResult, Parser, State, SyntaxError,
|
||||
allocated, ascii_char, loc, parse_utf8, specialize_ref, word1, BadInputError, EString, Parser,
|
||||
State,
|
||||
};
|
||||
use bumpalo::collections::vec::Vec;
|
||||
use bumpalo::Bump;
|
||||
|
@ -232,7 +232,7 @@ pub fn parse<'a>() -> impl Parser<'a, StrLiteral<'a>, EString<'a>> {
|
|||
// canonicalization error if that expression variant
|
||||
// is not allowed inside a string interpolation.
|
||||
let (_progress, loc_expr, new_state) = specialize_ref(
|
||||
|e, _, _| EString::Format(e),
|
||||
EString::Format,
|
||||
skip_second!(loc(allocated(expr::expr(0))), ascii_char(b')')),
|
||||
)
|
||||
.parse(arena, state)?;
|
||||
|
@ -296,7 +296,7 @@ pub fn parse<'a>() -> impl Parser<'a, StrLiteral<'a>, EString<'a>> {
|
|||
// escapable characters (\n, \t, \", \\, etc)
|
||||
return Err((
|
||||
MadeProgress,
|
||||
EString::StringEscape(Escape::EscapeUnknown),
|
||||
EString::UnknownEscape(state.line, state.column),
|
||||
state,
|
||||
));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue