stdlib/lang/bolt.bolt: Mock a macro that generates the Bolt AST

This commit is contained in:
Sam Vervaeck 2020-05-25 22:46:22 +02:00
parent d72301fa07
commit 3a7c65025f

View file

@ -19,32 +19,36 @@ mod Bolt::Lang {
end: Pos, end: Pos,
} }
pub struct Identifier { define_nodes! {
text: String,
span: Option<Span>, Identifier : Symbol {
orig_node: Option<Node>, text: String,
parent: Option<Node>, },
Statement,
ReturnStatement : Statement {
expression: Option<Expression>,
},
ConditionalCase {
test: Option<Expression>,
result: Vec<FunctionBodyElement>,
},
ConditionalStatement : Statement {
cases: Vec<ConditionalCase>,
},
Expression,
ReferenceExpression : Expression {
modulePath: Option<ModulePath>,
name: Symbol,
}
} }
pub type Token
= Identifier
pub struct ConditionalCase {
test: Option<Expression>,
result: Vec<FunctionBodyElement>,
}
pub struct ConditionalStatement {
cases: Vec<ConditionalCase>,
}
pub type Statement
= ReturnStatement
| ConditionalStatement
pub type Expression
= ReferenceExpression
pub type Transformer = fn (node: Node) -> Node; pub type Transformer = fn (node: Node) -> Node;
fn build_predicate_from_pattern(pattern: Pattern) -> Expression { fn build_predicate_from_pattern(pattern: Pattern) -> Expression {