mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
Added documentation, added new line before preprocessor line.
This commit is contained in:
24
README.md
24
README.md
@@ -196,6 +196,29 @@ var x = code("var y = 5;"); // pass as string
|
||||
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
|
||||
|
||||
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)
|
||||
* [Scripting commands](https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3)
|
||||
* [Scripting preprocessor](https://community.bistudio.com/wiki/PreProcessor_Commands)
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -57,8 +57,8 @@ func (c *Compiler) parseBlock() {
|
||||
}
|
||||
|
||||
func (c *Compiler) parsePreprocessor() {
|
||||
// we definitely want a new line here
|
||||
c.appendOut(c.get().Token+new_line, false)
|
||||
// we definitely want a new line before and after
|
||||
c.appendOut(new_line+c.get().Token+new_line, false)
|
||||
c.next()
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ func TestParserInlineCode(t *testing.T) {
|
||||
|
||||
func TestParserPreprocessor(t *testing.T) {
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user