chsasank / llama.lisp

Lisp dialect designed for HPC and AI
GNU Lesser General Public License v2.1
3 stars 3 forks source link

Implement sexp parser in python #30

Open chsasank opened 3 weeks ago

chsasank commented 3 weeks ago

Better to do sexp also in python to make everything super easy to use.

adi-lb-phoenix commented 2 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"]]]% 
adi-lb-phoenix commented 2 weeks ago

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?

chsasank commented 1 week ago

This is on hold until sometime

adi-lb-phoenix commented 5 days ago

https://outline.von-neumann.ai/doc/parser-using-lark-HtORucDnxX parser-using-lark.md