Skip to content

Instantly share code, notes, and snippets.

@sejr
Last active January 5, 2019 03:37
Show Gist options
  • Save sejr/315ad3d7edb9be9d19e2fcdccb43c1ba to your computer and use it in GitHub Desktop.
Save sejr/315ad3d7edb9be9d19e2fcdccb43c1ba to your computer and use it in GitHub Desktop.
This is a human-readable representation of an AST, or abstract syntax tree, for an Iron module that has been parsed by Forge.
```iron
function main {
let greeting: String = "Hello"
let target: String = " world!"
assert((greeting + target) == "Hello world!")
}
```
Module {
name: "hello",
environment: {
"main": Function {
public: false,
name: "main",
parameters: None,
returns: None,
body: [
Assignment {
identifier: "greeting",
kind: Some("String"),
value: Stack {
root: [
Singleton {
item: StringValue {
value: "\"Hello\""
}
}
]
}
},
Assignment {
identifier: "target",
kind: Some("String"),
value: Stack {
root: [
Singleton {
item: StringValue {
value: "\" world!\""
}
}
]
}
},
Stack {
root: [
Singleton {
item: FunctionCall {
identifier: "assert",
arguments: [
FunctionArgument {
label: None,
value: [
NestedStack {
root: [
Singleton {
item: Identifier {
name: "greeting"
}
},
Singleton {
item: Operator {
name: Add
}
},
Singleton {
item: Identifier {
name: "target"
}
}
]
},
Singleton {
item: Operator {
name: EqualTo
}
},
Singleton {
item: FunctionCall {
identifier: "hello",
arguments: [
FunctionArgument {
label: Some("to"),
value: [
Singleton {
item: StringValue {
value: "\"world\""
}
}
]
}
]
}
}
]
}
]
}
}
]
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment