use logos::{Logos};
#[derive(Debug, PartialEq, Logos)]
pub enum TokenType<'t> {
#[regex(r#"('|")([^('|")\\]|\\t|\\u|\\n|\\("|'))*('|")"#)]
String,
#[regex(r"[0-9]+")]
Integer,
#[regex(r"[0-9]+\.+[0-9]+", priority = 2)]
Float,
#[regex(r"[a-zA-Z_]+")]
Identifier(&'t str),
#[regex(r"\$[$]*[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*")]
Variable(&'t str),
#[token("function")]
Function,
#[token("fn")]
ShortFunction,
#[token("if")]
If,
#[token("else")]
Else,
#[token("while")]
While,
#[token("do")]
Do,
#[token("for")]
For,
#[token("foreach")]
Foreach,
#[token("as")]
As,
#[token("class")]
Class,
#[token("abstract")]
Abstract,
#[token("implements")]
Implements,
#[token("clone")]
Clone,
#[token("try")]
Try,
#[token("catch")]
Catch,
#[token("const")]
Const,
#[token("public")]
Public,
#[token("protected")]
Protected,
#[token("private")]
Private,
#[token("final")]
Final,
#[token("static")]
Static,
#[token("trait")]
Trait,
#[token("switch")]
Switch,
#[token("continue")]
Continue,
#[token("break")]
Break,
#[token("case")]
Case,
#[token("yield")]
Yield,
#[token("from")]
From,
#[token("callable")]
Callable,
#[token("default")]
Default,
#[token("declare")]
Declare,
#[token("echo")]
Echo,
#[token("elseif")]
ElseIf,
#[token("empty")]
Empty,
#[token("exit")]
Exit,
#[token("die")]
Die,
#[token("global")]
Global,
#[token("goto")]
Goto,
#[token("include")]
Include,
#[token("include_once")]
IncludeOnce,
#[token("require")]
Require,
#[token("require_once")]
RequireOnce,
#[token("isset")]
Isset,
#[token("namespace")]
Namespace,
#[token("new")]
New,
#[token("print")]
Print,
#[token("return")]
Return,
#[token("throw")]
Throw,
#[token("and")]
#[token("&&")]
And,
#[token("or")]
#[token("||")]
Or,
#[token("true")]
True,
#[token("false")]
False,
#[token("null")]
Null,
#[regex(r"[ \t\n\f]+", logos::skip)]
#[error]
Error,
}