File size: 1,279 Bytes
59da845
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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),
}