Added documentation, added new line before preprocessor line.

This commit is contained in:
Marvin Blum
2015-10-31 16:27:10 +01:00
parent 276ab86668
commit 8d5c0a6905
3 changed files with 27 additions and 3 deletions

View File

@@ -196,6 +196,29 @@ var x = code("var y = 5;"); // pass as string
x = {y = 5;}; x = {y = 5;};
``` ```
## Preprocessor
The preprocessor works like the original one, with some limitations.
Please visit the link at the bottom, to read about the preprocessor and how to use it. Generally, preprocessor lines must start with the hash key (#) and must stay in their own line. They are always printed as seperate lines.
These features are not supported:
* replacing parts of words
* multi line preprocessor commands
* __EXEC (not used in SQF anyway)
If you use *__EXEC*, it will be replaced by a function call to it ([] call __EXEC).
*__LINE__* and *__FILE__* can be used, since they are identifiers:
```
if __LINE__ == 22 {
// ...
}
if __FILE__ == "myScript.sqf" {
// ...
}
```
## List of all keywords ## List of all keywords
Keywords should not be used as identifiers. Here is a full list of all keywords in ASL. Remember that build in function names should not be used neither. Keywords should not be used as identifiers. Here is a full list of all keywords in ASL. Remember that build in function names should not be used neither.
@@ -248,6 +271,7 @@ For further information you can read the SQF tutorial and documentation of scrip
* [Arma Wiki](https://community.bistudio.com/wiki/Main_Page) * [Arma Wiki](https://community.bistudio.com/wiki/Main_Page)
* [Scripting commands](https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3) * [Scripting commands](https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3)
* [Scripting preprocessor](https://community.bistudio.com/wiki/PreProcessor_Commands)
## License ## License

View File

@@ -57,8 +57,8 @@ func (c *Compiler) parseBlock() {
} }
func (c *Compiler) parsePreprocessor() { func (c *Compiler) parsePreprocessor() {
// we definitely want a new line here // we definitely want a new line before and after
c.appendOut(c.get().Token+new_line, false) c.appendOut(new_line+c.get().Token+new_line, false)
c.next() c.next()
} }

View File

@@ -156,7 +156,7 @@ func TestParserInlineCode(t *testing.T) {
func TestParserPreprocessor(t *testing.T) { func TestParserPreprocessor(t *testing.T) {
got := getCompiled(t, "test/tokenizer_preprocessor.asl") got := getCompiled(t, "test/tokenizer_preprocessor.asl")
want := "#define HELLO_WORLD \"Hello World!\"\r\nhint HELLO_WORLD;\r\n" want := "\r\n#define HELLO_WORLD \"Hello World!\"\r\nhint HELLO_WORLD;\r\n"
equal(t, got, want) equal(t, got, want)
} }