flycatcher_parser/ast/
mod.rs

1//! Tools for generating AST trees.
2
3pub mod meta;
4pub mod opcode;
5
6pub use meta::AstMeta;
7pub use opcode::Opcode;
8
9/// A list of possible AST expressions.
10#[derive(Clone, Debug)]
11pub enum Ast {
12
13    NullLiteral,
14
15    /// A boolean literal, either `true` or `false`.
16    BooleanLiteral(bool),
17
18    /// A 64-bit floating point number literal.
19    FloatLiteral(f64),
20
21    /// A 64-bit integer literal.
22    IntegerLiteral(i64),
23
24    /// An identifier literal.
25    IdentifierLiteral(String),
26
27    /// A string literal.
28    StringLiteral(String),
29
30    /// A literal array of items, such as `[item1, 2, 3, true, false]`.
31    ListLiteral(Vec<AstMeta>),
32
33    /// A function call with the given arguments.
34    FunctionCall(Box<AstMeta>, Vec<AstMeta>),
35
36    /// A binary expression with two operands.
37    /// 
38    /// ```flycatcher
39    /// 1 + 1
40    /// ```
41    BinaryExpression(Opcode, Box<AstMeta>, Box<AstMeta>),
42
43    /// An expression made with an unlimited amount of indexes, for example,
44    /// `item1["item2"].item3[item4()]`
45    IndexExpression(Vec<AstMeta>),
46
47    /// An index for an IndexExpression that may contain something other than an identifier.
48    /// 
49    /// ```flycatcher
50    /// item1["BracketIndexHere"]
51    /// ```
52    BracketIndex(Box<AstMeta>),
53
54    /// This is caused by using the `+` operator at the start of an operand, such as `+10`.
55    PositiveUnary(Box<AstMeta>),
56
57    /// This is caused by using the `-` operator at the start of an operand, such as `-10`.
58    NegativeUnary(Box<AstMeta>),
59
60    /// Negates a logical expression, the `!` operator.  For example, (`!1 == 1`).
61    NotUnary(Box<AstMeta>),
62
63    /// A preprocessor statement with a given name and arguments.
64    PreprocessorStatement(Box<AstMeta>, Vec<AstMeta>),
65
66}