Added preprocessor line.

This commit is contained in:
Marvin Blum
2015-10-31 16:20:04 +01:00
parent dc4eaf4b0f
commit 276ab86668
5 changed files with 69 additions and 7 deletions

View File

@@ -4,6 +4,8 @@ import (
"tokenizer"
)
const new_line = "\r\n"
// Parses tokens, validates code to a specific degree
// and writes SQF code into desired location.
func (c *Compiler) Parse(token []tokenizer.Token, prettyPrinting bool) string {
@@ -19,7 +21,9 @@ func (c *Compiler) Parse(token []tokenizer.Token, prettyPrinting bool) string {
}
func (c *Compiler) parseBlock() {
if c.accept("var") {
if c.get().Preprocessor {
c.parsePreprocessor()
} else if c.accept("var") {
c.parseVar()
} else if c.accept("if") {
c.parseIf()
@@ -52,6 +56,12 @@ func (c *Compiler) parseBlock() {
}
}
func (c *Compiler) parsePreprocessor() {
// we definitely want a new line here
c.appendOut(c.get().Token+new_line, false)
c.next()
}
func (c *Compiler) parseVar() {
c.expect("var")
c.appendOut(c.get().Token, false)