Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

C# Abstract Syntax Tree Example: Simple Pascal Compiler

Language: Layout:
+ ] Show input
Compilation time: 0,16 sec, absolute running time: 0,13 sec, cpu time: 0,12 sec, average memory usage: 16 Mb, average nr of threads: 3 
edit mode |  history  | discussion
Input an expression, for example:

    begin x := 5; y := 6.5; begin z := 7; z := (2.11*-z*(5+7.18+9.23))+---x+++(-+-+--(y+2))*(-+-3+x)*(5+y)+3*(2+1);end; t := z*2 end.

Tree graph:

(Root)
   └── (Compound)
       │    ┌──  x
       ├── (:=)
       │    └──  5
       │    ┌──  y
       ├── (:=)
       │    └──  6.5
       ├── (Compound)
       │   │    ┌──  z
       │   ├── (:=)
       │   │    └──  7
       │   │    ┌──  z
       │   └── (:=)
       │        │                        ┌──  2.11
       │        │                   ┌── (*)
       │        │                   │    └── (-)
       │        │                   │         └──  z
       │        │              ┌── (*)
       │        │              │    │         ┌──  5
       │        │              │    │    ┌── (+)
       │        │              │    │    │    └──  7.18
       │        │              │    └── (+)
       │        │              │         └──  9.23
       │        │         ┌── (+)
       │        │         │    └── (-)
       │        │         │         └── (-)
       │        │         │              └── (-)
       │        │         │                   └──  x
       │        │    ┌── (+)
       │        │    │    │         ┌── (+)
       │        │    │    │         │    └── (+)
       │        │    │    │         │         └── (-)
       │        │    │    │         │              └── (+)
       │        │    │    │         │                   └── (-)
       │        │    │    │         │                        └── (+)
       │        │    │    │         │                             └── (-)
       │        │    │    │         │                                  └── (-)
       │        │    │    │         │                                       │    ┌──  y
       │        │    │    │         │                                       └── (+)
       │        │    │    │         │                                            └──  2
       │        │    │    │    ┌── (*)
       │        │    │    │    │    │    ┌── (-)
       │        │    │    │    │    │    │    └── (+)
       │        │    │    │    │    │    │         └── (-)
       │        │    │    │    │    │    │              └──  3
       │        │    │    │    │    └── (+)
       │        │    │    │    │         └──  x
       │        │    │    └── (*)
       │        │    │         │    ┌──  5
       │        │    │         └── (+)
       │        │    │              └──  y
       │        └── (+)
       │             │    ┌──  3
       │             └── (*)
       │                  │    ┌──  2
       │                  └── (+)
       │                       └──  1
       │    ┌──  t
       └── (:=)
            │    ┌──  z
            └── (*)
                 └──  2



Value:

x = 5
y = 65
z = -2393618
t = -4787236


Lisp form:

(:= x 5)
(:= y 6.5)
(:= z 7)
(:= z (+ (+ (+ (* (* 2.11 (- z)) (+ (+ 5 7.18) 9.23)) (- (- (- x)))) (* (* (+ (+ (- (+ (- (+ (- (- (+ y 2))))))))) (+ (- (+ (- 3))) x)) (+ 5 y))) (* 3 (+ 2 1))))
(:= t (* z 2))


    
                
λ
.NET NoSQL database for rapid development