summaryrefslogtreecommitdiff
path: root/src/modules/ast/syntax-tree.scm
blob: b7db8ddbd7edf561010bd43ee51eb8d4dc208476 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(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-type

            make-unary
            unary?
            unary-operator
            unary-expr

            make-const
            const?
            const-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 type)
  expr?
  (type expr-type))

(define-record-type <unary>
  (make-unary op expr)
  unary?
  (op unary-operator)
  (expr unary-expr))

(define-record-type <const>
  (make-const int)
  const?
  (int const-int))

(define-record-type <id>
  (make-id symbol)
  id?
  (symbol id-symbol))