2021-04-12 13:20:45 -05:00
|
|
|
use logos::Logos;
|
|
|
|
|
|
|
|
#[derive(Logos, Debug, PartialEq)]
|
|
|
|
pub enum Token {
|
|
|
|
/// A C-complaint identifier
|
|
|
|
#[regex(r"[a-zA-Z_][a-zA-Z_0-9]*")]
|
|
|
|
Identifier,
|
|
|
|
|
|
|
|
#[token("(")]
|
|
|
|
LeftParenthesis,
|
|
|
|
|
|
|
|
#[token(")")]
|
|
|
|
RightParenthesis,
|
|
|
|
|
|
|
|
#[token("[")]
|
|
|
|
LeftBracket,
|
|
|
|
|
|
|
|
#[token("]")]
|
|
|
|
RightBracket,
|
|
|
|
|
|
|
|
#[token("{")]
|
|
|
|
LeftBrace,
|
|
|
|
|
|
|
|
#[token("}")]
|
|
|
|
RightBrace,
|
|
|
|
|
|
|
|
#[token(";")]
|
|
|
|
Semicolon,
|
|
|
|
|
|
|
|
#[regex(r"#.*")]
|
|
|
|
Comment,
|
|
|
|
|
|
|
|
#[token("-")]
|
|
|
|
Subtract,
|
|
|
|
|
|
|
|
#[token("+")]
|
|
|
|
Addition,
|
|
|
|
|
|
|
|
#[token("*")]
|
|
|
|
Multiply,
|
|
|
|
|
|
|
|
#[token("/")]
|
|
|
|
Divide,
|
|
|
|
|
|
|
|
#[token("=")]
|
|
|
|
Assignment,
|
|
|
|
|
|
|
|
/// Base52 based character ('a')
|
|
|
|
#[token("'.*'")]
|
|
|
|
Char,
|
|
|
|
|
|
|
|
#[token("functio")]
|
|
|
|
Function,
|
|
|
|
|
|
|
|
/// Brain fuck FFI
|
|
|
|
#[token("bff")]
|
|
|
|
BfFunction,
|
|
|
|
|
|
|
|
/// Variable bro
|
|
|
|
#[token("var")]
|
|
|
|
Variable,
|
|
|
|
|
|
|
|
/// True, False
|
|
|
|
#[regex("true|false")]
|
|
|
|
Boolean,
|
|
|
|
|
|
|
|
/// Always, Sometimes, Never
|
|
|
|
#[regex("always|sometimes|never")]
|
|
|
|
Aboolean,
|
|
|
|
|
|
|
|
/// String
|
|
|
|
#[regex("\"(\\.|[^\"])*\"")]
|
|
|
|
String,
|
|
|
|
|
|
|
|
/// Integer
|
|
|
|
#[regex(r"[0-9]+")]
|
|
|
|
Integer,
|
|
|
|
|
|
|
|
/// Prints the preceding things
|
|
|
|
#[token("print")]
|
|
|
|
Print,
|
|
|
|
|
|
|
|
/// Ban the following variable from ever being used again
|
|
|
|
#[token("melo")]
|
|
|
|
Melo,
|
|
|
|
|
|
|
|
#[token("T-Dark")]
|
|
|
|
TDark,
|
|
|
|
|
|
|
|
#[regex(r"[ \t\n\f]+", logos::skip)]
|
|
|
|
#[error]
|
|
|
|
Error,
|
2021-04-11 17:22:06 -05:00
|
|
|
}
|
2021-04-12 13:20:45 -05:00
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub enum Abool {
|
|
|
|
Never = -1,
|
|
|
|
Sometimes = 0,
|
|
|
|
Always = 1,
|
2021-04-08 16:11:20 -05:00
|
|
|
}
|