|
|
@ -4,6 +4,7 @@ use std::collections::HashMap; |
|
|
|
use commands; |
|
|
|
use commands; |
|
|
|
|
|
|
|
|
|
|
|
/// Token represents a parsable token in the string sent via STDIN from the GUI
|
|
|
|
/// Token represents a parsable token in the string sent via STDIN from the GUI
|
|
|
|
|
|
|
|
#[derive(Debug)] |
|
|
|
pub enum Token { |
|
|
|
pub enum Token { |
|
|
|
UCI, |
|
|
|
UCI, |
|
|
|
DEBUG, |
|
|
|
DEBUG, |
|
|
@ -18,6 +19,7 @@ pub enum Token { |
|
|
|
QUIT, |
|
|
|
QUIT, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, PartialOrd)] |
|
|
|
pub enum CommandValue { |
|
|
|
pub enum CommandValue { |
|
|
|
Int(i32), |
|
|
|
Int(i32), |
|
|
|
Float(f64), |
|
|
|
Float(f64), |
|
|
@ -39,6 +41,7 @@ pub struct Parser {} |
|
|
|
///
|
|
|
|
///
|
|
|
|
/// The user is still responsible for knowing what to look for in the hashmap but this structure makes it far
|
|
|
|
/// The user is still responsible for knowing what to look for in the hashmap but this structure makes it far
|
|
|
|
/// easier to work with commands. Some commands don't have arguments, in that case the args will be None.
|
|
|
|
/// easier to work with commands. Some commands don't have arguments, in that case the args will be None.
|
|
|
|
|
|
|
|
#[derive(Debug)] |
|
|
|
pub struct TokenResult { |
|
|
|
pub struct TokenResult { |
|
|
|
token: Token, |
|
|
|
token: Token, |
|
|
|
args: Option<HashMap<&'static str, CommandValue>>, |
|
|
|
args: Option<HashMap<&'static str, CommandValue>>, |
|
|
@ -61,6 +64,10 @@ impl Parser { |
|
|
|
|
|
|
|
|
|
|
|
// TODO: Parse things based on the token, probably need a special function for each token based on a switch
|
|
|
|
// TODO: Parse things based on the token, probably need a special function for each token based on a switch
|
|
|
|
// of tokens[0].
|
|
|
|
// of tokens[0].
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// remove this when it's working
|
|
|
|
|
|
|
|
Err("lol") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|