extend go syntax
This commit is contained in:
parent
1e83b66ba5
commit
7d2abdafb2
41
mml.parser
41
mml.parser
@ -150,6 +150,45 @@ string-type = "string";
|
|||||||
bool-type = "bool";
|
bool-type = "bool";
|
||||||
error-type = "error";
|
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
|
primitive-type:alias = int-type
|
||||||
| float-type
|
| float-type
|
||||||
| string-type
|
| string-type
|
||||||
@ -290,7 +329,7 @@ select = "select" wsnlc* "{" (wsnlc | ";")*
|
|||||||
(sep (select-case-line | default-line | statement))*)?
|
(sep (select-case-line | default-line | statement))*)?
|
||||||
(wsnlc | ";")* "}";
|
(wsnlc | ";")* "}";
|
||||||
|
|
||||||
go = "go" wsnlc* function-application;
|
go = "go" wsnlc* (function-application | block);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
require . = "mml/foo"
|
require . = "mml/foo"
|
||||||
|
22
mml_test.go
22
mml_test.go
@ -1983,6 +1983,28 @@ func TestMML(t *testing.T) {
|
|||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
ignorePosition: true,
|
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",
|
msg: "require, dot, equal",
|
||||||
text: "require . = \"mml/foo\"",
|
text: "require . = \"mml/foo\"",
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
cleanup
|
|
||||||
error reporting
|
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
|
custom tokens
|
||||||
indentation
|
indentation
|
||||||
streaming
|
streaming
|
||||||
|
Loading…
Reference in New Issue
Block a user