mirror of
https://github.com/urinalcaketopper/fddl.git
synced 2025-06-06 13:24:46 +00:00
added Some and Not
This commit is contained in:
parent
6c61db4b57
commit
b5ab9f51ff
@ -248,6 +248,8 @@ impl Lexer {
|
||||
"sym" => Token::Sym,
|
||||
"module" => Token::Module,
|
||||
"import" => Token::Import,
|
||||
"some" => Token::Some,
|
||||
"not" => Token::Not,
|
||||
_ => Token::Identifier(text),
|
||||
};
|
||||
|
||||
|
@ -46,6 +46,8 @@ pub enum Token {
|
||||
Sym,
|
||||
Module,
|
||||
Import,
|
||||
Some,
|
||||
Not,
|
||||
|
||||
// Comments
|
||||
Comment(String),
|
||||
|
@ -24,6 +24,8 @@ pub enum Operator {
|
||||
// Unary
|
||||
Minus, // For unary negation e.g. -5
|
||||
Almost, // For unary ~ e.g. ~5
|
||||
Some, // For unary ? e.g. ?5
|
||||
Not, // For unary ! e.g. !true
|
||||
|
||||
// Binary
|
||||
Plus, // For addition e.g. 5 + 5
|
||||
|
@ -238,11 +238,13 @@ impl Parser {
|
||||
let operator_token_snapshot = self.current_token().clone();
|
||||
|
||||
match operator_token_snapshot {
|
||||
Token::Minus | Token::Tilde => {
|
||||
Token::Minus | Token::Tilde | Token::Some | Token::Not => {
|
||||
self.advance();
|
||||
let ast_operator = match operator_token_snapshot {
|
||||
Token::Minus => Operator::Minus,
|
||||
Token::Tilde => Operator::Almost,
|
||||
Token::Some => Operator::Some,
|
||||
Token::Not => Operator::Not,
|
||||
_ => unreachable!("Lexer should not produce other tokens here if first match is minus/tilde. Checked by matches! macro."),
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user