diff options
Diffstat (limited to 'src/modules/ast')
-rw-r--r-- | src/modules/ast/assembly-tree.scm | 25 | ||||
-rw-r--r-- | src/modules/ast/syntax-tree.scm | 48 |
2 files changed, 73 insertions, 0 deletions
diff --git a/src/modules/ast/assembly-tree.scm b/src/modules/ast/assembly-tree.scm new file mode 100644 index 0000000..ee3e116 --- /dev/null +++ b/src/modules/ast/assembly-tree.scm @@ -0,0 +1,25 @@ +(define-module (modules ast assembly-tree) + #:use-module (srfi srfi-9) + #:export (make-subroutine + subroutine? + subroutine-label + subroutine-instructions + + make-instruction + instruction? + instruction-operator + instruction-operand-1 + instruction-operand-2)) + +(define-record-type <subroutine> + (make-subroutine label instrs) + subroutine? + (label subroutine-label) + (instrs subroutine-instructions)) + +(define-record-type <instruction> + (make-instruction op oper1 oper2) + instruction? + (op instruction-operator) + (oper1 instruction-operand-1) + (oper2 instruction-operand-2)) diff --git a/src/modules/ast/syntax-tree.scm b/src/modules/ast/syntax-tree.scm new file mode 100644 index 0000000..738b115 --- /dev/null +++ b/src/modules/ast/syntax-tree.scm @@ -0,0 +1,48 @@ +(define-module (modules ast syntax-tree) + #:use-module (srfi srfi-9) + #:export (make-program + program? + program-function + + make-function + function? + function-id + function-stmt + + make-stmt + stmt? + stmt-expr + + make-expr + expr? + expr-int + + make-id + id? + id-symbol)) + +(define-record-type <program> + (make-program func) + program? + (func program-function)) + +(define-record-type <function> + (make-function id stmt) + function? + (id function-id) + (stmt function-stmt)) + +(define-record-type <stmt> + (make-stmt expr) + stmt? + (expr stmt-expr)) + +(define-record-type <expr> + (make-expr int) + expr? + (int expr-int)) + +(define-record-type <id> + (make-id symbol) + id? + (symbol id-symbol)) |