mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
Issue #6.
This commit is contained in:
@@ -1 +1 @@
|
|||||||
var inline_code = code("");
|
var inline_code = code("var a = 1;var b = 2;if a < b {foo();}");
|
||||||
|
|||||||
@@ -297,7 +297,8 @@ func (c *Compiler) parseInlineCode() string {
|
|||||||
output := "{}"
|
output := "{}"
|
||||||
|
|
||||||
if len(code) > 2 {
|
if len(code) > 2 {
|
||||||
//output = "{"+Parse(Tokenize([]byte(code[1:len(code)-1])), pretty)+"}"
|
compiler := Compiler{}
|
||||||
|
output = "{"+compiler.Parse(Tokenize([]byte(code[1:len(code)-1])), false)+"}"
|
||||||
}
|
}
|
||||||
|
|
||||||
c.expect(")")
|
c.expect(")")
|
||||||
|
|||||||
@@ -146,6 +146,13 @@ func TestParserFunctionParams(t *testing.T) {
|
|||||||
equal(t, got, want)
|
equal(t, got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParserInlineCode(t *testing.T) {
|
||||||
|
got := getCompiled(t, "test/parser_code.asl")
|
||||||
|
want := "inline_code = {a = 1;b = 2;if (a<b) then {[] call foo;};};\r\n"
|
||||||
|
|
||||||
|
equal(t, got, want)
|
||||||
|
}
|
||||||
|
|
||||||
func getCompiled(t *testing.T, file string) string {
|
func getCompiled(t *testing.T, file string) string {
|
||||||
code, err := ioutil.ReadFile(file)
|
code, err := ioutil.ReadFile(file)
|
||||||
|
|
||||||
|
|||||||
1
test/parser_code.asl
Normal file
1
test/parser_code.asl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
var inline_code = code("var a = 1;var b = 2;if a < b {foo();}");
|
||||||
Reference in New Issue
Block a user