feat: Emit keyword

This commit is contained in:
Micah Kendall
2024-04-01 15:16:35 +11:00
committed by Lucas
parent 23713ce6fa
commit d25b8f91c7
11 changed files with 148 additions and 6 deletions

View File

@@ -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),
}),
))
}

View File

@@ -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,

View File

@@ -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",