summaryrefslogtreecommitdiff
path: root/src/modules/parser/parser.scm
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/parser/parser.scm')
-rw-r--r--src/modules/parser/parser.scm36
1 files changed, 0 insertions, 36 deletions
diff --git a/src/modules/parser/parser.scm b/src/modules/parser/parser.scm
deleted file mode 100644
index cab690c..0000000
--- a/src/modules/parser/parser.scm
+++ /dev/null
@@ -1,36 +0,0 @@
-(define-module (modules parser parser)
- #:use-module (ice-9 match)
- #:use-module (modules ast syntax-tree)
- #:export (p-program))
-
-
-(define (die)
- (error "syntax error"))
-
-(define (p-program tokens)
- (match tokens
- ((func ...)
- (make-program (p-function func)))
- (_ (die))))
-
-(define (p-function tokens)
- (match tokens
- (('int (? string? id) 'left-paren 'void 'right-paren 'open-brace stmt ... 'close-brace)
- (make-function (make-id id) (p-stmt stmt)))
- (_ (die))))
-
-(define (p-stmt tokens)
- (match tokens
- (('return expr ... 'semi-colon)
- (make-stmt (p-expr expr)))
- (_ (die))))
-
-(define (p-expr tokens)
- (match tokens
- (((? integer? int))
- (make-const int))
- (((or 'sub 'complement) expr ...)
- (make-unary (car tokens) (p-expr expr)))
- (('left-paren expr ... 'right-paren)
- (p-expr expr))
- (_ (die))))