Open chsasank opened 3 weeks ago
we have llvm<->Bril-json<-> brillisp <-> c-lisp. I have to write a parser.
What does a parser do? A parser converts data from one form to another ex it converts the syntax of the code from one form to another.
What does my parser do? It convert from sexpression into json. that is list of list into json .
convert the below
(brilisp
(define ((print int) (n int)))
(define ((print4 void))
(set (v int) (const 4))
(set (tmp int) (call print v))
(ret))
(define ((main int))
(set (v int) (const 2))
(set (tmp void) (call print4))
(set (tmp int) (call print v))
(ret tmp)))
to
(llvm_venv) adithyalbhat@Adithyas-MacBook-Pro utils % guile sexp-json.scm < test.sexp
["brilisp",["define",[["print","int"],["n","int"]]],["define",[["print4","void"]],["set",["v","int"],["const",4]],["set",["tmp","int"],["call","print","v"]],["ret"]],["define",[["main","int"]],["set",["v","int"],["const",2]],["set",["tmp","void"],["call","print4"]],["set",["tmp","int"],["call","print","v"]],["ret","tmp"]]]%
I need to understand the tree structure. How do i understand the tree structure ? how do i navigate between Tree(token(‘rule’,’list’). what is tree token?
This is on hold until sometime
Better to do sexp also in python to make everything super easy to use.