Add local function definitions

This commit is contained in:
Joscha 2022-11-19 18:58:21 +01:00
parent b590f640f4
commit 86006933d7
2 changed files with 19 additions and 10 deletions

View file

@ -129,8 +129,11 @@ function() '{
}
```
| Sugar | Desugared |
|------------------------|---------------------------------|
| `function foo() a` | `foo = function() a` |
| `function foo(a) b` | `foo = function(a) b` |
| `function foo{..} a` | `foo = function{..} a` |
| Sugar | Desugared |
|----------------------------|------------------------------|
| `function foo() a` | `foo = function() a` |
| `function foo(a) b` | `foo = function(a) b` |
| `function foo{..} a` | `foo = function{..} a` |
| `local function foo() a` | `local foo = function() a` |
| `local function foo(a) b` | `local foo = function(a) b` |
| `local function foo{..} a` | `local foo = function{..} a` |

View file

@ -39,10 +39,12 @@ pub enum FuncDef {
span: Span,
},
/// `function foo() a`
/// - `function foo() a`
/// - `local function foo() a`
///
/// Structure: `function s0 name s1 ( s2 ) s3 body`
/// Structure: `local function s0 name s1 ( s2 ) s3 body`
NamedNoArg {
local: Option<Space>,
s0: Space,
name: Ident,
s1: Space,
@ -52,10 +54,12 @@ pub enum FuncDef {
span: Span,
},
/// `function foo(bar) a`
/// - `function foo(bar) a`
/// - `local function foo(bar) a`
///
/// Structure: `function s0 name s1 ( s2 arg s3 ) s4 body`
/// Structure: `local function s0 name s1 ( s2 arg s3 ) s4 body`
NamedArg {
local: Option<Space>,
s0: Space,
name: Ident,
s1: Space,
@ -68,9 +72,11 @@ pub enum FuncDef {
},
/// `function foo{..} a`
/// `local function foo{..} a`
///
/// Structure: `function s0 name s1 pattern s2 body`
/// Structure: `local function s0 name s1 pattern s2 body`
NamedDestr {
local: Option<Space>,
s0: Space,
name: Ident,
s1: Space,