extend go syntax

This commit is contained in:
Arpad Ryszka 2017-07-15 19:04:04 +02:00
parent 1e83b66ba5
commit 7d2abdafb2
4 changed files with 79 additions and 13 deletions

View File

@ -150,6 +150,45 @@ string-type = "string";
bool-type = "bool";
error-type = "error";
/*
support:
go {
foo()
bar()
}
go { for { f() } }
go func() { for { f() } }()
fn f() { go f() }; go f()
and not:
go for {foo()}
or:
go for foo()
because we don't know what the arguments are
*/
/*
fn foo() {
bar()
baz()
}
let qux foo()
equivalent to:
let qux {
bar()
baz()
}
*/
primitive-type:alias = int-type
| float-type
| string-type
@ -290,7 +329,7 @@ select = "select" wsnlc* "{" (wsnlc | ";")*
(sep (select-case-line | default-line | statement))*)?
(wsnlc | ";")* "}";
go = "go" wsnlc* function-application;
go = "go" wsnlc* (function-application | block);
/*
require . = "mml/foo"

View File

@ -1983,6 +1983,28 @@ func TestMML(t *testing.T) {
}},
}},
ignorePosition: true,
}, {
msg: "go, block",
text: "go { for { f() } }",
nodes: []*Node{{
Name: "go",
Nodes: []*Node{{
Name: "block",
Nodes: []*Node{{
Name: "loop",
Nodes: []*Node{{
Name: "block",
Nodes: []*Node{{
Name: "function-application",
Nodes: []*Node{{
Name: "symbol",
}},
}},
}},
}},
}},
}},
ignorePosition: true,
}, {
msg: "require, dot, equal",
text: "require . = \"mml/foo\"",

View File

@ -1,5 +1,10 @@
cleanup
error reporting
- longest parse
- count the lines
- print the line
- print the deepest non-alias node name
- print the documentation of the node name
read, with error reporting
custom tokens
indentation
streaming