This commit is contained in:
Marvin Blum
2015-10-28 18:58:40 +01:00
parent 393ddd4326
commit c3d4661b7f
4 changed files with 11 additions and 2 deletions

View File

@@ -1 +1 @@
var inline_code = code(""); var inline_code = code("var a = 1;var b = 2;if a < b {foo();}");

View File

@@ -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(")")

View File

@@ -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
View File

@@ -0,0 +1 @@
var inline_code = code("var a = 1;var b = 2;if a < b {foo();}");