... | @@ -38,25 +38,25 @@ withForeignPtr fptr (\ptr -> c_memcpy buf ptr size) |
... | @@ -38,25 +38,25 @@ withForeignPtr fptr (\ptr -> c_memcpy buf ptr size) |
|
# Changes to the grammar
|
|
# Changes to the grammar
|
|
|
|
|
|
|
|
|
|
The Haskell report [ defines](https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-220003) the `lexp` nonterminal thus:
|
|
The Haskell report [ defines](https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-220003) the `lexp` nonterminal thus (`*` indicates a rule of interest):
|
|
|
|
|
|
```wiki
|
|
```wiki
|
|
lexp → \ apat1 … apatn -> exp (lambda abstraction, n ≥ 1)
|
|
lexp → \ apat1 … apatn -> exp (lambda abstraction, n ≥ 1) *
|
|
| let decls in exp (let expression)
|
|
| let decls in exp (let expression) *
|
|
| if exp [;] then exp [;] else exp (conditional)
|
|
| if exp [;] then exp [;] else exp (conditional) *
|
|
| case exp of { alts } (case expression)
|
|
| case exp of { alts } (case expression) *
|
|
| do { stmts } (do expression)
|
|
| do { stmts } (do expression) *
|
|
| fexp
|
|
| fexp
|
|
|
|
|
|
fexp → [fexp] aexp (function application)
|
|
fexp → [fexp] aexp (function application)
|
|
|
|
|
|
aexp → qvar (variable)
|
|
aexp → qvar (variable)
|
|
| gcon (general constructor)
|
|
| gcon (general constructor)
|
|
| literal
|
|
| literal
|
|
| ( exp ) (parenthesized expression)
|
|
| ( exp ) (parenthesized expression)
|
|
| qcon { fbind1 .. fbindn } (labeled construction)
|
|
| qcon { fbind1 … fbindn } (labeled construction)
|
|
| aexp { fbind1 .. fbindn } (labelled update)
|
|
| aexp { fbind1 … fbindn } (labelled update)
|
|
...
|
|
| …
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
... | @@ -66,24 +66,23 @@ which means lambda, `let`, `if`, `case`, and `do` constructs cannot be used as e |
... | @@ -66,24 +66,23 @@ which means lambda, `let`, `if`, `case`, and `do` constructs cannot be used as e |
|
The `ArgumentDo` extension would allow all these constructs in argument positions. This is accomplished by moving their production rules under `aexp`:
|
|
The `ArgumentDo` extension would allow all these constructs in argument positions. This is accomplished by moving their production rules under `aexp`:
|
|
|
|
|
|
```wiki
|
|
```wiki
|
|
lexp → fexp
|
|
lexp → fexp
|
|
|
|
|
|
fexp → [fexp] aexp (function application)
|
|
fexp → [fexp] aexp (function application)
|
|
|
|
|
|
aexp → qvar (variable)
|
|
aexp → qvar (variable)
|
|
| gcon (general constructor)
|
|
| gcon (general constructor)
|
|
| literal
|
|
| literal
|
|
| ( exp ) (parenthesized expression)
|
|
| ( exp ) (parenthesized expression)
|
|
| qcon { fbind1 .. fbindn } (labeled construction)
|
|
| qcon { fbind1 … fbindn } (labeled construction)
|
|
| aexp { fbind1 .. fbindn } (labelled update)
|
|
| aexp { fbind1 … fbindn } (labelled update)
|
|
-- Here are the moved rules
|
|
-- Here are the moved rules
|
|
| \ apat1 … apatn -> exp (lambda abstraction, n ≥ 1)
|
|
| \ apat1 … apatn -> exp (lambda abstraction, n ≥ 1) *
|
|
| let decls in exp (let expression)
|
|
| let decls in exp (let expression) *
|
|
| if exp [;] then exp [;]
|
|
| if exp [;] then exp [;] else exp (conditional) *
|
|
else exp (conditional)
|
|
| case exp of { alts } (case expression) *
|
|
| case exp of { alts } (case expression)
|
|
| do { stmts } (do expression) *
|
|
| do { stmts } (do expression)
|
|
| …
|
|
...
|
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
... | | ... | |