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

@ -130,7 +130,10 @@ function() '{
``` ```
| Sugar | Desugared | | Sugar | Desugared |
|------------------------|---------------------------------| |----------------------------|------------------------------|
| `function foo() a` | `foo = function() a` | | `function foo() a` | `foo = function() a` |
| `function foo(a) b` | `foo = function(a) b` | | `function foo(a) b` | `foo = function(a) b` |
| `function foo{..} a` | `foo = function{..} a` | | `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, 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 { NamedNoArg {
local: Option<Space>,
s0: Space, s0: Space,
name: Ident, name: Ident,
s1: Space, s1: Space,
@ -52,10 +54,12 @@ pub enum FuncDef {
span: Span, 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 { NamedArg {
local: Option<Space>,
s0: Space, s0: Space,
name: Ident, name: Ident,
s1: Space, s1: Space,
@ -68,9 +72,11 @@ pub enum FuncDef {
}, },
/// `function foo{..} a` /// `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 { NamedDestr {
local: Option<Space>,
s0: Space, s0: Space,
name: Ident, name: Ident,
s1: Space, s1: Space,