Updated README, added todo.

This commit is contained in:
Marvin Blum
2015-10-09 15:53:21 +02:00
parent 7c4e3c1077
commit b908525d34
5 changed files with 121 additions and 28 deletions

111
README.md
View File

@@ -1,5 +1,7 @@
# ASL # ASL
**ASL is under heavy development and not production ready, the features listed here are not fully implemented. Please visit again when the final version is releaesed. If you like to contribute or if you are just interested, go on.**
ASL stands for Arma Scripting Language, a C-style scripting language compiled to SQF. ASL stands for Arma Scripting Language, a C-style scripting language compiled to SQF.
ASL is intended to simplify Arma 3 mod and mission development and eliminate the pain of SQF's bad syntax. ASL is intended to simplify Arma 3 mod and mission development and eliminate the pain of SQF's bad syntax.
@@ -8,7 +10,7 @@ Main reasons for ASL:
* consistent and clean syntax * consistent and clean syntax
* less writing * less writing
* easier to read and maintain * easier to read and maintain
* easy to lern and understand * easy to learn and understand
* full replacement of SQF * full replacement of SQF
* compatible with Arma wiki and commands * compatible with Arma wiki and commands
@@ -16,7 +18,112 @@ The compiler is written in Go and implemented as a simple recursive decent parse
## Syntax ## Syntax
*coming soon* ### Comments
Comments are declared exactly like in SQF:
```
// single line comment
/* multi
line
comment */
```
### Variables
Variables are declared using the keyword *var*. They keep the visibility mechanic used by SQF. Identifiers starting with an underscore are considered private.
```
var publicVariable = "value";
var _privateVariable = "value";
var number = 123;
var floatingPointNumber = 1.23;
var string = "string";
var array = [1, 2, 3];
```
### Controll structures
Controll structure syntax is C-like. Notice they are all using the same brackets and do not require to set a semicolon at the end.
```
if 1 < 2 {
// ...
}
while 1 < 2 {
// ...
}
for var _i = 0; _i < 100; _i = _i+1 { // var before identifier is optional
// ...
}
each allUnits { // foreach, iterates over all units in this case
// element is available as _x here
}
```
### Functions
Functions are declared using the keyword *func*. The parameters will be available by their specified identifier.
```
func add(_a, _b) {
return _a+_b;
}
```
Call it:
```
var _x = add(1, 2);
// result is 3
```
### Embed SQF Code
To allow copy and paste of SQF code and reduce migration costs, it is possible (but not recommended) to embed SQF code.
To start a SQF block, use *SQF:* or *sqf:*. To end it use *SQF* or *sqf*.
```
var _a = 1;
var _b = 2;
if _a < _b {
SQF:
hint format ["%1 is lower than %2", _a, _b];
SQF
}
```
This will compile to:
```
_a = 1;
_b = 2;
if(_a < _b) then {
hint format ["%1 is lower than %2", _a, _b];
};
```
### Call build in commands
To call SQF build in commands (like hint, getDir, addItem, ...) we have to call them differently.
Since SQF commands can take arguments in the front and behind the keyword, we use a special syntax. So this SQF code:
```
someUnit addItem "NVGoogles";
```
is equivalent to:
```
$addItem(someUnit)("NVGoogles");
```
## Contribute ## Contribute

10
ToDo.md Normal file
View File

@@ -0,0 +1,10 @@
# ToDo
* assign to returned values
* special cases (like if ... exitWith)
* sqf: ... sqf whitespace
* solution for build in commands which do not require left values
* pretty/minified printing
* usage
* recursive compiling
* concurrent compiling

View File

@@ -1,23 +1 @@
// comment $hint()("Hello World");
func Foo(_a, _b) {
var _i = 0;
// yeah...
while _a < _b {
/*
So this will just compile to plain SQF.
*/
sqf:
sleep 3;
hint format ["%1", _i];
sqf
_i = _i+1;
}
}
/* comment */
var _a = 1;
var _b = 2;
Foo(_a, _b);

View File

@@ -1,2 +0,0 @@
var _x = "/* multi line comment */";
var _y = "// single line comment";

View File

@@ -8,7 +8,7 @@ import (
func main() { func main() {
// read test file // read test file
code, _ := ioutil.ReadFile("in/test.asl") code, _ := ioutil.ReadFile("in/simple.asl")
token := asl.Tokenize(code) token := asl.Tokenize(code)
out := asl.Parse(token) out := asl.Parse(token)