That's it basically, need own context to compile sub parts within other

compilation.
This commit is contained in:
Marvin Blum
2015-10-28 18:26:29 +01:00
parent 0a66f15704
commit 53ea74a19b
3 changed files with 22 additions and 4 deletions

View File

@@ -205,6 +205,7 @@ Keywords should not be used as identifiers. Here is a full list of all keywords
| catch |
| exitwith |
| waituntil |
| code |
## What's missing?

View File

@@ -1 +1 @@
var inline_code = code("var x = 5;");
var inline_code = code("");

View File

@@ -4,8 +4,6 @@ import (
)
const TAB = " "
// Parses tokens, validates code to a specific degree
// and writes SQF code into desired location.
func Parse(token []Token, prettyPrinting bool) string {
@@ -290,6 +288,23 @@ func parseWaitUntil() {
appendOut("};", true)
}
func parseInlineCode() string {
expect("code")
expect("(")
code := get().token
next()
output := "{}"
if len(code) > 2 {
output = "{"+Parse(Tokenize([]byte(code[1:len(code)-1])), pretty)+"}"
}
expect(")")
return output
}
// Everything that does not start with a keyword.
func parseStatement() {
// empty block
@@ -426,7 +441,9 @@ func parseExpression(out bool) string {
func parseIdentifier() string {
output := ""
if seek("(") && !accept("!") && !accept("-") {
if accept("code") {
output += parseInlineCode()
} else if seek("(") && !accept("!") && !accept("-") {
name := get().token
next()
output = "(" + parseFunctionCall(false, name) + ")"