Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement sexp parser in python #30

Open
chsasank opened this issue Jun 13, 2024 · 4 comments
Open

Implement sexp parser in python #30

chsasank opened this issue Jun 13, 2024 · 4 comments

Comments

@chsasank
Copy link
Owner

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

@adi-lb-phoenix
Copy link
Contributor

adi-lb-phoenix commented Jun 17, 2024

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
Copy link
Contributor

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
Copy link
Owner Author

This is on hold until sometime

@adi-lb-phoenix
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants