feat: Emit keyword
This commit is contained in:
@@ -36,6 +36,14 @@ pub fn parser<'a>(
|
||||
then: Box::new(then_.unwrap_or_else(|| UntypedExpr::todo(None, span))),
|
||||
text: Box::new(text),
|
||||
}),
|
||||
just(Token::Emit)
|
||||
.ignore_then(choice((string::hybrid(), expression.clone())))
|
||||
.then(sequence.clone().or_not())
|
||||
.map_with_span(|(text, then_), span| UntypedExpr::Emit {
|
||||
location: span,
|
||||
then: Box::new(then_.unwrap_or_else(|| UntypedExpr::todo(None, span))),
|
||||
text: Box::new(text),
|
||||
}),
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -220,6 +220,7 @@ pub fn lexer() -> impl Parser<char, Vec<(Token, Span)>, Error = ParseError> {
|
||||
|
||||
let keyword = text::ident().map(|s: String| match s.as_str() {
|
||||
"trace" => Token::Trace,
|
||||
"emit" => Token::Emit,
|
||||
// TODO: remove this in a future release
|
||||
"error" => Token::Fail,
|
||||
"fail" => Token::Fail,
|
||||
|
||||
@@ -89,6 +89,7 @@ pub enum Token {
|
||||
Type,
|
||||
When,
|
||||
Trace,
|
||||
Emit,
|
||||
Validator,
|
||||
Via,
|
||||
}
|
||||
@@ -175,6 +176,7 @@ impl fmt::Display for Token {
|
||||
Token::Pub => "pub",
|
||||
Token::Todo => "todo",
|
||||
Token::Trace => "trace",
|
||||
Token::Emit => "emit",
|
||||
Token::Type => "type",
|
||||
Token::Test => "test",
|
||||
Token::Fail => "fail",
|
||||
|
||||
Reference in New Issue
Block a user