Created
December 2, 2013 15:13
-
-
Save tylereaves/7750953 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type | |
| PNode = ref TNode | |
| TNode = object | |
| variant | |
| of nkInt: val: int | |
| of nkFloat: val: float | |
| of nkString: val: string | |
| of nkAdd, nkSub: | |
| leftOp, rightOp: PNode | |
| of nkIf: | |
| condition, thenPart, elsePart: PNode | |
| # create a new case object: | |
| var n = nkIf(condition: nil) | |
| # accessing n.thenPart is valid because the ``nkIf`` branch is active: | |
| n.thenPart = nkFloat(val: 2.0) | |
| var x = PNode(nkAdd(leftOp: PNode(nkInt(val: 4)), | |
| rightOp: PNode(nkInt(val: 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment