You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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):
Add a basic let syntax for simple mathematical functions.
Proposed EBNF:
Where an expression in the form
let name = 5 in expr
bindsname
to5
inexpr
, and an expression in the formlet name a b = a + b in expr
bindsname
to the functionf(a, b) = a + b
inexpr
.The text was updated successfully, but these errors were encountered: