|
|
@ -4,13 +4,25 @@ use syntax::ast::pos::Position; |
|
|
|
use syntax::ast::punc::Punctuator; |
|
|
|
use syntax::ast::punc::Punctuator; |
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, PartialEq)] |
|
|
|
#[derive(Clone, PartialEq)] |
|
|
|
|
|
|
|
/// Represents a token
|
|
|
|
pub struct Token { |
|
|
|
pub struct Token { |
|
|
|
// // The token
|
|
|
|
// // The token
|
|
|
|
pub data: TokenData, |
|
|
|
pub data: TokenData, |
|
|
|
pub pos: Position, |
|
|
|
pub pos: Position, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Token { |
|
|
|
|
|
|
|
/// Create a new detailed token from the token data, line number and column number
|
|
|
|
|
|
|
|
pub fn new(data: TokenData, line_number: u64, column_number: u64) -> Token { |
|
|
|
|
|
|
|
Token { |
|
|
|
|
|
|
|
data: data, |
|
|
|
|
|
|
|
pos: Position::new(line_number, column_number), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, PartialEq)] |
|
|
|
#[derive(Clone, PartialEq)] |
|
|
|
|
|
|
|
/// Represents the type of Token
|
|
|
|
pub enum TokenData { |
|
|
|
pub enum TokenData { |
|
|
|
/// A boolean literal, which is either `true` or `false`
|
|
|
|
/// A boolean literal, which is either `true` or `false`
|
|
|
|
TBooleanLiteral(bool), |
|
|
|
TBooleanLiteral(bool), |
|
|
|