mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
number and string wrappers
This commit is contained in:
parent
8b3b055ab1
commit
0269a90c8c
2 changed files with 41 additions and 3 deletions
|
@ -12,7 +12,8 @@ use crate::parser::{
|
||||||
self, allocated, and_then_with_indent_level, ascii_char, ascii_string, attempt, backtrackable,
|
self, allocated, and_then_with_indent_level, ascii_char, ascii_string, attempt, backtrackable,
|
||||||
map, newline_char, not, not_followed_by, optional, sep_by1, sep_by1_e, specialize,
|
map, newline_char, not, not_followed_by, optional, sep_by1, sep_by1_e, specialize,
|
||||||
specialize_ref, then, trailing_sep_by0, unexpected, unexpected_eof, word1, word2, EExpr,
|
specialize_ref, then, trailing_sep_by0, unexpected, unexpected_eof, word1, word2, EExpr,
|
||||||
EInParens, ELambda, ERecord, Either, If, List, ParseResult, Parser, State, SyntaxError, When,
|
EInParens, ELambda, ERecord, EString, Either, If, List, Number, ParseResult, Parser, State,
|
||||||
|
SyntaxError, When,
|
||||||
};
|
};
|
||||||
use crate::pattern::loc_closure_param;
|
use crate::pattern::loc_closure_param;
|
||||||
use crate::type_annotation;
|
use crate::type_annotation;
|
||||||
|
@ -2225,6 +2226,20 @@ fn record_literal<'a>(min_indent: u16) -> impl Parser<'a, Expr<'a>, SyntaxError<
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn string_literal<'a>() -> impl Parser<'a, Expr<'a>, SyntaxError<'a>> {
|
fn string_literal<'a>() -> impl Parser<'a, Expr<'a>, SyntaxError<'a>> {
|
||||||
map!(crate::string_literal::parse(), Expr::Str)
|
specialize(
|
||||||
|
|_, r, c| SyntaxError::Expr(EExpr::Str(EString::EndlessSingle, r, c)),
|
||||||
|
map!(crate::string_literal::parse(), Expr::Str),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn string_literal_help<'a>() -> impl Parser<'a, Expr<'a>, EString> {
|
||||||
|
specialize(
|
||||||
|
|_, _, _| EString::EndlessSingle,
|
||||||
|
map!(crate::string_literal::parse(), Expr::Str),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn number_literal_help<'a>() -> impl Parser<'a, Expr<'a>, Number> {
|
||||||
|
specialize(|_, _, _| Number::NumberEnd, number_literal())
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,12 +393,35 @@ pub enum EExpr<'a> {
|
||||||
|
|
||||||
InParens(EInParens<'a>, Row, Col),
|
InParens(EInParens<'a>, Row, Col),
|
||||||
Record(ERecord<'a>, Row, Col),
|
Record(ERecord<'a>, Row, Col),
|
||||||
|
Str(EString, Row, Col),
|
||||||
|
Number(Number, Row, Col),
|
||||||
List(List<'a>, Row, Col),
|
List(List<'a>, Row, Col),
|
||||||
|
|
||||||
IndentStart(Row, Col),
|
IndentStart(Row, Col),
|
||||||
IndentEnd(Row, Col),
|
IndentEnd(Row, Col),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub enum Number {
|
||||||
|
NumberEnd,
|
||||||
|
NumberDot(i64),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub enum EString {
|
||||||
|
EndlessSingle,
|
||||||
|
EndlessMulti,
|
||||||
|
StringEscape(Escape),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub enum Escape {
|
||||||
|
EscapeUnknown,
|
||||||
|
BadUnicodeFormat(u16),
|
||||||
|
BadUnicodeCode(u16),
|
||||||
|
BadUnicodeLength(u16, i32, i32),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum ERecord<'a> {
|
pub enum ERecord<'a> {
|
||||||
End(Row, Col),
|
End(Row, Col),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue