algorembrant's picture
Upload 25 files
59da845 verified
use crate::compiler::lexer::Token;
#[derive(Debug, Clone, PartialEq)]
pub enum AstNode {
Program(Vec<AstNode>),
// Declarations
VarDecl {
var_type: Token,
is_input: bool,
name: String,
init_value: Option<Box<AstNode>>,
},
FunctionDecl {
return_type: Token,
name: String,
params: Vec<AstNode>, // VarDecl
body: Box<AstNode>, // Block
},
Block(Vec<AstNode>),
// Statements
IfStatement {
condition: Box<AstNode>,
then_branch: Box<AstNode>,
else_branch: Option<Box<AstNode>>,
},
ReturnStatement(Option<Box<AstNode>>),
ExpressionStatement(Box<AstNode>),
// Expressions
BinaryOp {
left: Box<AstNode>,
op: Token,
right: Box<AstNode>,
},
UnaryOp {
op: Token,
expr: Box<AstNode>,
},
FunctionCall {
name: String,
args: Vec<AstNode>,
},
// Built-in MQL5 logic
OrderSendCall {
symbol: String,
cmd: Token, // OP_BUY, OP_SELL (represented as tokens or mapped strings)
volume: f64,
price: f64,
sl: f64,
tp: f64,
},
Identifier(String),
Literal(Token),
}