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

[Suggestion] Add let ... in ... expr syntax #21

Open
Flexilis-anatis opened this issue Jul 2, 2019 · 2 comments
Open

[Suggestion] Add let ... in ... expr syntax #21

Flexilis-anatis opened this issue Jul 2, 2019 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Flexilis-anatis
Copy link

Add a basic let syntax for simple mathematical functions.
Proposed EBNF:

expr ::= NUMBER
           | NAME
           | NAME '(' args? ')'
           | 'let' NAME+ '=' expr 'in' expr
args = expr (',' expr)*

Where an expression in the form let name = 5 in expr binds name to 5 in expr, and an expression in the form let name a b = a + b in expr binds name to the function f(a, b) = a + b in expr.

@nerdypepper
Copy link
Owner

i am planning on rewriting the parsing logic using nom or lalrpop. variable support and assignments are top priorities!

@nerdypepper nerdypepper added enhancement New feature or request help wanted Extra attention is needed labels Jul 8, 2019
@minijackson
Copy link

If this helps, a while ago I implemented a variant on the language in the Modern Compiler Implementation with lalrpop. The language is very ML-inspired, expression based, and contains exactly this let ... in ... syntax. Here is the lalrpop file with the let expression (and a lot of other things which you may or may not find useful):

https://github.com/minijackson/INF-4301A/blob/master/src/parser/parser.lalrpop#L206-L222

I'm happy to answer questions about this project and my experience with lalrpop ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants