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

make parser capable of treating AST instuctions as first-class symbols #29

Open
sfultong opened this issue Jun 24, 2018 · 4 comments
Open

Comments

@sfultong
Copy link
Owner

sfultong commented Jun 24, 2018

E.G. you should be able to pass AST instructions as arguments, like app (pair zero zero) left

so right now in a .sil file, we could have a line like
test = left {0,0}

left is a keyword, and the parser always expects it to be followed by an argument.

So if I wanted to use it in a function, I'd have to do something like
test = (\f -> f {0,0}) (\x -> left x)

I want to be able to do this instead:
test = (\f -> f {0,0}) left

So we can parse left as a regular function, but it should also generate the same grammar as before when parsing old syntax (e.g. left {0,0})

@hhefesto
Copy link
Contributor

Hi!

This is my train of thought and some questions along the way:

assumptions: in branch master

As I understand it, SILParser Term1 is a parser that, when ran by feeding it a String, will produce a IExpr that can be eventually evaluated by evalLoop.

AST instructions (i.e. import SIL (zero, pair, app, check, pleft, pright, varN, ite, lam, completeLam)) are values or functions whose last Codomain are of type IExpr

So a parser that treats AST instructionts as first class symbols would be a parser capable of consuming strings with two types of encodings: SIL's AST instruction language and normal SIL language. Am I interpreting this part correctly?

Should the parser be able to consume a string with a mix of both encondings? Or should the parser accept just one (either SIL lang or AST instructions)?

@hhefesto
Copy link
Contributor

AST instructions (i.e. import SIL (zero, pair, app, check, pleft, pright, varN, ite, lam, completeLam))
are values or functions whose last Codomain are of type IExpr

SILParser Term1 takes a string an converts it to ParserTerm (Either Int String) which turns to Either ParseError IExpr through convertPT <$> debruijinize []

It feels like AST instructions would go a different way because the are already IExpr themselves... Does that make sense?

@sfultong
Copy link
Owner Author

sfultong commented Oct 26, 2019

Ah, I didn't do a very good job at describing this. I'll edit the original description to try to make it clearer.

You won't be changing what the parser is consuming. You'll just be writing new methods that consume Strings to produce SILParser Term1

@sfultong
Copy link
Owner Author

Since you're not that familiar with Parsec, this might be a tricky issue to start with, now that I think about it. It'll probably be a lot of researching for a tiny amount of code.

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