fix: todo and fail spans
This commit is contained in:
parent
69fdee9f7e
commit
db3b5c74bb
|
@ -14,25 +14,19 @@ pub fn parser<'a>(
|
|||
expression: Recursive<'a, Token, UntypedExpr, ParseError>,
|
||||
sequence: Recursive<'a, Token, UntypedExpr, ParseError>,
|
||||
) -> impl Parser<Token, UntypedExpr, Error = ParseError> + 'a {
|
||||
let message = choice((
|
||||
clause(expression.clone()).ignored().rewind().to(None),
|
||||
choice((string::hybrid(), expression.clone())).or_not(),
|
||||
))
|
||||
.boxed();
|
||||
|
||||
choice((
|
||||
just(Token::Todo).ignore_then(choice((
|
||||
clause(expression.clone())
|
||||
.ignored()
|
||||
.rewind()
|
||||
.map_with_span(|_, span| UntypedExpr::todo(None, span)),
|
||||
choice((string::hybrid(), expression.clone()))
|
||||
.or_not()
|
||||
.map_with_span(UntypedExpr::todo),
|
||||
))),
|
||||
just(Token::Fail).ignore_then(choice((
|
||||
clause(expression.clone())
|
||||
.ignored()
|
||||
.rewind()
|
||||
.map_with_span(|_, span| UntypedExpr::fail(None, span)),
|
||||
choice((string::hybrid(), expression.clone()))
|
||||
.or_not()
|
||||
.map_with_span(UntypedExpr::fail),
|
||||
))),
|
||||
just(Token::Todo)
|
||||
.ignore_then(message.clone())
|
||||
.map_with_span(UntypedExpr::todo),
|
||||
just(Token::Fail)
|
||||
.ignore_then(message)
|
||||
.map_with_span(UntypedExpr::fail),
|
||||
just(Token::Trace)
|
||||
.ignore_then(choice((string::hybrid(), expression.clone())))
|
||||
.then(sequence.clone().or_not())
|
||||
|
|
|
@ -4,9 +4,9 @@ description: "Code:\n\nfail @\"foo\"\n"
|
|||
---
|
||||
Trace {
|
||||
kind: Error,
|
||||
location: 5..11,
|
||||
location: 0..11,
|
||||
then: ErrorTerm {
|
||||
location: 5..11,
|
||||
location: 0..11,
|
||||
},
|
||||
text: String {
|
||||
location: 5..11,
|
||||
|
|
|
@ -4,9 +4,9 @@ description: "Code:\n\nfail \"foo\"\n"
|
|||
---
|
||||
Trace {
|
||||
kind: Error,
|
||||
location: 5..10,
|
||||
location: 0..10,
|
||||
then: ErrorTerm {
|
||||
location: 5..10,
|
||||
location: 0..10,
|
||||
},
|
||||
text: String {
|
||||
location: 5..10,
|
||||
|
|
|
@ -4,12 +4,12 @@ description: "Code:\n\nfail\n"
|
|||
---
|
||||
Trace {
|
||||
kind: Error,
|
||||
location: 1..2,
|
||||
location: 0..4,
|
||||
then: ErrorTerm {
|
||||
location: 1..2,
|
||||
location: 0..4,
|
||||
},
|
||||
text: String {
|
||||
location: 1..2,
|
||||
location: 0..4,
|
||||
value: "aiken::error",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ description: "Code:\n\nfail str.join([@\"Some string \", some_params, @\" some s
|
|||
---
|
||||
Trace {
|
||||
kind: Error,
|
||||
location: 5..67,
|
||||
location: 0..67,
|
||||
then: ErrorTerm {
|
||||
location: 5..67,
|
||||
location: 0..67,
|
||||
},
|
||||
text: Call {
|
||||
arguments: [
|
||||
|
|
|
@ -4,9 +4,9 @@ description: "Code:\n\ntodo @\"foo\"\n"
|
|||
---
|
||||
Trace {
|
||||
kind: Todo,
|
||||
location: 5..11,
|
||||
location: 0..11,
|
||||
then: ErrorTerm {
|
||||
location: 5..11,
|
||||
location: 0..11,
|
||||
},
|
||||
text: String {
|
||||
location: 5..11,
|
||||
|
|
|
@ -4,12 +4,12 @@ description: "Code:\n\ntodo\n"
|
|||
---
|
||||
Trace {
|
||||
kind: Todo,
|
||||
location: 1..2,
|
||||
location: 0..4,
|
||||
then: ErrorTerm {
|
||||
location: 1..2,
|
||||
location: 0..4,
|
||||
},
|
||||
text: String {
|
||||
location: 1..2,
|
||||
location: 0..4,
|
||||
value: "aiken::todo",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ description: "Code:\n\ntodo string.join([\"foo\", \"bar\"])\n"
|
|||
---
|
||||
Trace {
|
||||
kind: Todo,
|
||||
location: 5..32,
|
||||
location: 0..32,
|
||||
then: ErrorTerm {
|
||||
location: 5..32,
|
||||
location: 0..32,
|
||||
},
|
||||
text: Call {
|
||||
arguments: [
|
||||
|
|
|
@ -4,9 +4,9 @@ description: "Code:\n\ntodo \"foo\"\n"
|
|||
---
|
||||
Trace {
|
||||
kind: Todo,
|
||||
location: 5..10,
|
||||
location: 0..10,
|
||||
then: ErrorTerm {
|
||||
location: 5..10,
|
||||
location: 0..10,
|
||||
},
|
||||
text: String {
|
||||
location: 5..10,
|
||||
|
|
|
@ -26,12 +26,12 @@ When {
|
|||
guard: None,
|
||||
then: Trace {
|
||||
kind: Todo,
|
||||
location: 35..39,
|
||||
location: 28..32,
|
||||
then: ErrorTerm {
|
||||
location: 35..39,
|
||||
location: 28..32,
|
||||
},
|
||||
text: String {
|
||||
location: 35..39,
|
||||
location: 28..32,
|
||||
value: "aiken::todo",
|
||||
},
|
||||
},
|
||||
|
@ -53,12 +53,12 @@ When {
|
|||
guard: None,
|
||||
then: Trace {
|
||||
kind: Todo,
|
||||
location: 52..53,
|
||||
location: 47..51,
|
||||
then: ErrorTerm {
|
||||
location: 52..53,
|
||||
location: 47..51,
|
||||
},
|
||||
text: String {
|
||||
location: 52..53,
|
||||
location: 47..51,
|
||||
value: "aiken::todo",
|
||||
},
|
||||
},
|
||||
|
|
|
@ -26,12 +26,12 @@ When {
|
|||
guard: None,
|
||||
then: Trace {
|
||||
kind: Error,
|
||||
location: 33..34,
|
||||
location: 28..32,
|
||||
then: ErrorTerm {
|
||||
location: 33..34,
|
||||
location: 28..32,
|
||||
},
|
||||
text: String {
|
||||
location: 33..34,
|
||||
location: 28..32,
|
||||
value: "aiken::error",
|
||||
},
|
||||
},
|
||||
|
|
|
@ -46,9 +46,9 @@ When {
|
|||
guard: None,
|
||||
then: Trace {
|
||||
kind: Todo,
|
||||
location: 52..68,
|
||||
location: 47..68,
|
||||
then: ErrorTerm {
|
||||
location: 52..68,
|
||||
location: 47..68,
|
||||
},
|
||||
text: String {
|
||||
location: 52..68,
|
||||
|
|
Loading…
Reference in New Issue