A barebone compiler for the academic static analysis playground language Tiny Imperative Programming.
Master branch
Latest commit
TIP is meant as a playground for various static analysis tools. It is meant to continually expand its capabilities as I progress through the Static Analysis course.
- Lexer/parser creating a nice abstract syntax tree of the source code in hiccup style.
- Control flow graph.
All use of TIP is currently intended to happen through Leiningen, which is all but a necessity for using the project at all at this stage.
Having installed Leiningen, the easiest way to fire up the compiler is to run
lein run myfile.tip
which will pass myfile.tip
through the stages currently implemented by the compiler project and present the result.
If you want to run the test suite, simply run
lein midje
to run the full suite of behavioral tests.
If you want to explore the functions provided by the TIP compiler, you should run
lein repl
and use
the namespaces you desire.
An example of an exploratory REPL session could be:
(use 'tip.parser)
;; => nil
(def program "inc(number) { return number + 1; }")
;; => #'tip.core/program
(def parsed-program
(grammar program))
;; => #'tip.core/parsed-program
(clojure.pprint/pprint parsed-program)
;; => [:program
;; [:function
;; [:identifier "inc"]
;; [:arg-list [:identifier "number"]]
;; [:return [:addition [:identifier "number"] [:constant "1"]]]]]
;; => nil
Let's say GPLv3. Why not?