22 Commits
1.2.0 ... 1.2.1

Author SHA1 Message Date
Marvin Blum
9096adfeed Updated changelog. 2016-02-08 15:10:56 +01:00
Marvin Blum
944b91c16b Added test for bugfix, cleaned up repo (issue #35 and #36). 2016-02-08 15:09:48 +01:00
Marvin Blum
28fbbd7e10 Fixed unary function compile. 2016-02-07 17:13:33 +01:00
Ozan Eğitmen
3311fa79c7 Merge pull request #34 from 654wak654/master
Updated np++ Highlighting
2016-01-26 22:12:48 +02:00
Ozan Eğitmen
bb026d45c7 Merge remote-tracking branch 'refs/remotes/DeKugelschieber/master' 2016-01-26 22:07:21 +02:00
Ozan Eğitmen
80cbcd8f9a Updated np++ Highlighting
Changed comments to not so bright colors, added BIS function
highlighting.
2016-01-26 22:07:20 +02:00
Marvin Blum
346859761e Update README.md 2016-01-25 18:38:40 +01:00
Marvin Blum
b13dc22807 Update README.md 2016-01-25 18:14:57 +01:00
Marvin Blum
da3d097d5d Update README.md 2016-01-25 18:14:17 +01:00
Marvin Blum
6dd9323d78 Updated version number for next release (but not worth yet). 2016-01-24 16:45:25 +01:00
Marvin Blum
e598cae71f Updated changelog. 2016-01-20 18:42:59 +01:00
Marvin Blum
97d220eb47 Merge branch 'master' of https://github.com/DeKugelschieber/asl 2016-01-20 18:38:45 +01:00
Marvin Blum
9786c63d52 Issue #31, added new line after while for pretty printing. 2016-01-20 18:38:04 +01:00
Ozan Eğitmen
51cc0f5700 Update README.md Again 2016-01-20 18:34:38 +02:00
Ozan Eğitmen
3b40b3427d Update README.md 2016-01-20 18:31:01 +02:00
Ozan Eğitmen
3c1ccbba76 Merge pull request #32 from 654wak654/master
Tools Update
2016-01-20 18:29:27 +02:00
Ozan Eğitmen
3ee4000ef5 Tools Update
New ASL GUI, updated syntax highlighting.
2016-01-20 18:26:57 +02:00
Marvin Blum
005a3bf101 Added type info to readme. 2016-01-14 12:01:12 +01:00
Ozan Eğitmen
90e8941a2c np++ highlighter update 2015-11-29 14:35:45 +02:00
Ozan Eğitmen
7ca3cfb1ad Update README.md 2015-11-26 18:46:04 +02:00
Ozan Eğitmen
65a7c4aae3 Update README.md 2015-11-26 18:45:23 +02:00
Ozan Eğitmen
acced0474b GUI Tools Refurnishing 2015-11-26 18:44:08 +02:00
18 changed files with 143 additions and 537 deletions

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>asl</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.googlecode.goclipse.goBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.googlecode.goclipse.core.goNature</nature>
</natures>
</projectDescription>

View File

@@ -1,5 +1,10 @@
# Changelog # Changelog
**1.2.1**
* bugfix: new line after while for pretty printing
* bugfix: build in unary function with multiple arguments
**1.2.0** **1.2.0**
* better error output * better error output

View File

@@ -15,27 +15,40 @@ Main reasons for ASL:
## Usage ## Usage
ASL is a command line tool. After you have downloaded it, navigation to the binary and execute it: ASL is a command line tool. After you have downloaded it, navigate to the binary and execute it:
``` ```
asl [-v|-r|-pretty|--help] <input directory> <output directory> asl.exe [-v|-r|-pretty|--help] <input directory> <output directory>
``` ```
| Parameter | Optional/Required | Meaning | | Parameter | Optional/Required | Description |
| --------- | ----------------- | ------- | | --------- | ----------------- | ----------- |
| -v | optional | Shows ASL version. | | -v | optional | Show ASL version. |
| -r | optional | Read input directory recursively. | | -r | optional | Read input directory recursively. |
| -pretty | optional | Enable pretty printing to SQF. | | -pretty | optional | Enable pretty printing to SQF. |
| --help | optional | Show usage. | | --help | optional | Show usage. |
| input directory | required | Directory to read ASL files from (use ./ for relative paths). | | input directory | required | Input directory for ASL files (use ./ for relative paths). |
| output directory | required | Directory for SQF output. Can be the same as input directory (use ./ for relative paths). | | output directory | required | Output directory for SQF files. Can be the same as input directory (use ./ for relative paths). |
**Example:** **Example:**
``` ```
asl ./missions/myMission/myScripts ./missions/myMission/compiledScripts asl.exe ./missions/myMission/myScripts ./missions/myMission/compiledScripts
``` ```
Since 1.2.0 ASL requires a [supportInfo](https://community.bistudio.com/wiki/supportInfo) file, which must be generated, named "types" and placed right next to the binary. The content looks like:
```
...
t:DIARY_RECORD
t:LOCATION
b:ARRAY waypointattachobject SCALAR,OBJECT
b:OBJECT,GROUP enableattack BOOL
...
```
The types file will be delivered with the current release, but not updated when Arma is.
## Syntax ## Syntax
### Comments ### Comments
@@ -70,12 +83,12 @@ var one = array[0];
var zwo = array[33/3-2]; var zwo = array[33/3-2];
// it is possble to use arrays in expressions: // it is possble to use arrays in expressions:
var emptyArray = one-[0]; var emptyArray = one-[1];
``` ```
### Control structures ### Control 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, unlike in SQF. Controll structure syntax is C-like. Notice the same brackets for all structures and no semicolon at the end, unlike in SQF:
``` ```
if 1 < 2 { if 1 < 2 {
@@ -88,13 +101,16 @@ while 1 < 2 {
// ... // ...
} }
for var _i = 0; _i < 100; _i = _i+1 { // var before identifier is optional for var _i = 0; _i < 100; _i = _i+1 {
// ... // ...
} }
foreach unit => allUnits { // foreach, iterates over all units in this case for _i = 0; _i < 100; _i = _i+1 { // same as above, var is optional before identifier "_i"
// element is available as "unit" here // ...
// _x is still available due to how SQF works! }
foreach _unit => allUnits { // iterates over all units in this case
// element is available as "_unit" AND "_x" here ("_x" is used by SQF's foreach)
} }
switch x { // there is no "break" in SQF switch x { // there is no "break" in SQF
@@ -106,10 +122,10 @@ switch x { // there is no "break" in SQF
// ... // ...
} }
try { try { // handles errors in "catch" block
// ... // errors thrown here...
} catch { } catch {
// ... // ... will be handled here
} }
``` ```
@@ -123,9 +139,7 @@ func add(_a, _b) {
} }
// Call it: // Call it:
var _x = add(1, 2); // result in _x is 3
var _x = add(1, 2);
// result in _x is 3
``` ```
Functions support predefined parameters: Functions support predefined parameters:
@@ -136,16 +150,14 @@ func add(_a = 0, _b = 0) {
} }
// Call it: // Call it:
var _x = add(); // result in _x is 0
var _x = add();
// result in _x is 0
``` ```
When trying to define a function with a name that exists in the build in function set, you'll get an compile error. When trying to define a function with a name that exists in SQF's build in function set, you'll get an compile error. So declaring "func hint()..." won't compile.
### Call build in commands ### Call build in commands
To call SQF build in commands (like hint, getDir, addItem, ...) we have to use a different syntax. To call SQF build in commands (like hint, getDir, addItem, ...) use the same syntax when using functions. An exception are "binary" functions. These are functions which accept parameters on both sides of the function name. Here is an example for "addItem":
``` ```
addItem(someUnit)("NVGoogles"); addItem(someUnit)("NVGoogles");
@@ -154,7 +166,7 @@ addItem(someUnit)("NVGoogles");
someUnit addItem "NVGoogles"; someUnit addItem "NVGoogles";
``` ```
Where the first brackets contain the parameters used in front of SQF command and the second ones behind SQF command. If more than one parameter is passed, it will be converted to an array. This syntax can be used for **all** build in functions (also spawn and so on). Where the first brackets contain the parameters used in front of SQF command and the second ones the parameters behind the SQF command. If more than one parameter is passed, it will be converted to an array. This syntax can be used for **all** build in functions.
``` ```
foo(x, y, z)(1, 2, 3); foo(x, y, z)(1, 2, 3);
@@ -163,7 +175,7 @@ foo(x, y, z)(1, 2, 3);
[x, y, z] foo [1, 2, 3]; [x, y, z] foo [1, 2, 3];
``` ```
If the build in function does not accept parameters or only on one side (unary function), it can be called with a single pair of brackets: If the build in function accepts no parameters (null function) or on one side only (unary function), it can be called with a single pair of brackets:
``` ```
hint("your text"); hint("your text");
@@ -172,9 +184,9 @@ shownWatch();
### Special functions ### Special functions
There are some special functions in SQF, which also require special syntax in ASL. The examples presented here show how they are written in ASL and what the output will look like. Remember that ASL is case sensitive! There are some special functions in SQF, which also require special syntax in ASL. The examples presented here shows how they are written in ASL and what the output will look like. Remember that ASL is case sensitive!
**exitWith** **exitwith**
``` ```
exitwith { // NOT exitWith! exitwith { // NOT exitWith!
@@ -187,7 +199,7 @@ if (true) exitWith {
}; };
``` ```
**waitUntil** **waituntil**
``` ```
waituntil(condition); // NOT waitUntil! waituntil(condition); // NOT waitUntil!
@@ -202,10 +214,9 @@ waitUntil {expression;condition};
**code** **code**
The code function is used to compile inline code. This does **not** replace SQF compile buildin function, but will return the contained ASL code as SQF. The code function is used to compile inline code. This does **not** replace SQF's compile build in function, but will return the contained ASL code as SQF:
``` ```
// input:
var x = code("var y = 5;"); // pass as string var x = code("var y = 5;"); // pass as string
// output: // output:
@@ -215,14 +226,14 @@ x = {y = 5;};
## Preprocessor ## Preprocessor
The preprocessor works like the original one, with some limitations. 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: 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 in SQF. These features are not supported:
* replacing parts of words * replacing parts of words
* multi line preprocessor commands * multi line preprocessor commands
* __EXEC (not used in SQF anyway) * EXEC (not used in SQF anyway)
If you use *__EXEC*, it will be replaced by a function call to it ([] call __EXEC). 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: *LINE* and *FILE* can be used like normal identifiers:
``` ```
if __LINE__ == 22 { if __LINE__ == 22 {
@@ -236,7 +247,7 @@ 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 must not be used as identifiers. Here is a full list of all keywords in ASL. Remember that build in function names must not be used neither, else you'll get an compile error.
| Keyword | | Keyword |
| ------- | | ------- |
@@ -260,18 +271,18 @@ Keywords should not be used as identifiers. Here is a full list of all keywords
## What's missing? ## What's missing?
The following features are not implemented yet, but will be in 1.3.0 or a future version: The following features are not implemented yet, but maybe will be in 1.3.0 or a future version:
* scopes * scopes
* else if * else if
* selector in expression * selector in expression
scopes won't be supported, since they are a stupid concept and can be replaced by functions. scopes won't be supported, since it's a stupid concept and can be replaced by functions.
Selectors in expressions do not work (yet): Selectors in expressions do not work (yet), so this is not possible:
``` ```
var x = ([1, 2, 3]-[1, 2])[0]; // should result in 3, but does not work var x = ([1, 2, 3]-[1, 2])[0]; // should result in 3
``` ```
## Contribute ## Contribute

23
ToDo.md
View File

@@ -1,23 +0,0 @@
# ToDo
* ~~assign to returned values~~
* ~~sqf: ... sqf whitespace~~
* ~~solution for build in commands which do not require left values~~
* ~~pretty/minified printing~~
* ~~usage~~
* ~~recursive compiling~~
* ~~concurrent compiling~~
* ~~inline buildin function call -> foo(a)(bar(x)(y));~~
* ~~negative values e.g. -1, operator !~~
* ~~tokenizer splits commands like "format" -> for, mat~~
* ~~try ... catch~~
* ~~better error reporting~~
- ~~recover panic~~
- ~~line, column~~
* type check for functions
## Special cases
* ~~exitWith...~~
* ~~waitUntil...~~
* ~~!buildInFunc()()...~~

6
build Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/home/marvin/Projekte/asl
go build -ldflags "-s -w" src/main/asl.go

Binary file not shown.

View File

@@ -1,14 +0,0 @@
ASL GUI <img src="https://img.shields.io/badge/version-1.0.0.0-lightgrey.svg" alt="version">
=========
An optional Java interface to make the compile procces of ASL faster and more user-friendly. It's released under the MIT licence just like the core project.
Maintained by yours truly: [654wak654](https://github.com/654wak654/)
**Version 1.0.0.0**
More style changes and bug fixes, marked ready for release.
**Version 0.3.0.0:**
Fixed some possible bugs, did some style fixes and other code adjustments. It's now is readable without getting cataracts. Mostly anyway...

View File

@@ -1,67 +0,0 @@
/*
* The MIT License
*
* Copyright 2015 Ozan Egitmen.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package asl.gui;
public class DlgError extends javax.swing.JDialog {
boolean isAbort = true;
public DlgError(java.awt.Frame parent, boolean modal, String errorMessage) {
super(parent, modal);
initComponents();
lblError.setText(errorMessage);
}
private void initComponents() {
lblError = new javax.swing.JLabel();
lblTitle = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("ERROR");
setIconImage(null);
setMinimumSize(new java.awt.Dimension(380, 150));
setResizable(false);
setType(java.awt.Window.Type.POPUP);
lblError.setFont(new java.awt.Font("Segoe UI Light", 0, 16));
lblError.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lblError.setText("Some error");
lblTitle.setFont(new java.awt.Font("Segoe UI Light", 0, 16));
lblTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lblTitle.setText("asl.exe has encountered an error:");
lblTitle.setToolTipText("");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(lblTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE).addComponent(lblError, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(lblTitle).addGap(18, 18, 18).addComponent(lblError).addGap(27, 27, 27)));
pack();
}
private javax.swing.JLabel lblError;
private javax.swing.JLabel lblTitle;
}

View File

@@ -1,370 +0,0 @@
/*
* The MIT License
*
* Copyright 2015 Ozan Egitmen.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package asl.gui;
import java.awt.Color;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import javax.swing.BorderFactory;
import javax.swing.JFileChooser;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.Border;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.plaf.ColorUIResource;
public class Main extends javax.swing.JFrame {
Preferences prefs = Preferences.userRoot().node(this.getClass().getName());
boolean inputError = false, outputError = false, aslError = false;
public Main() {
initComponents();
getContentPane().setBackground(Color.WHITE);
lblASLError.setText(" ");
lblInputError.setText(" ");
lblOutputError.setText(" ");
txtASLDir.setText(prefs.get("aslDir", ""));
txtInputDir.setText(prefs.get("inputDir", ""));
txtOutputDir.setText(prefs.get("outputDir", ""));
cbCompileAll.setSelected(prefs.getBoolean("compileAll", false));
cbPrettyPrinting.setSelected(prefs.getBoolean("prettyPrinting", false));
}
private String fileChooser(String title, int fileType) {
JFileChooser chooser = new JFileChooser();
if (fileType == 0) {
chooser.setFileFilter(new FileNameExtensionFilter("Executable", "exe"));
chooser.setAcceptAllFileFilterUsed(false);
}
chooser.setFileSelectionMode(fileType);
chooser.setDialogTitle(title);
String selectedPath = "";
if (chooser.showOpenDialog(null) == 0)
selectedPath = chooser.getSelectedFile().toString();
else
chooser.cancelSelection();
return selectedPath;
}
private void setErrorCondition(int i, boolean j) {
if (i == 0) {
lblASLError.setText(j ? "asl.exe isn't in this location! You can click this message to download it." : " ");
aslError = j;
} else if (i == 1) {
lblInputError.setText(j ? "This folder doesn't exist!" : " ");
inputError = j;
} else {
lblOutputError.setText(j ? "Output folder doesn't exsist! Click this message to create it." : " ");
outputError = j;
}
}
private void initComponents() {
lblInput = new javax.swing.JLabel();
txtInputDir = new javax.swing.JTextField();
lblOutput = new javax.swing.JLabel();
txtOutputDir = new javax.swing.JTextField();
btnInput = new javax.swing.JButton();
btnOutput = new javax.swing.JButton();
lblASL = new javax.swing.JLabel();
txtASLDir = new javax.swing.JTextField();
btnASL = new javax.swing.JButton();
jSeparator = new javax.swing.JSeparator();
lblASLSmall = new javax.swing.JLabel();
lblInputSmall = new javax.swing.JLabel();
lblOutputSmall = new javax.swing.JLabel();
cbCompileAll = new javax.swing.JCheckBox();
cbPrettyPrinting = new javax.swing.JCheckBox();
btnCompile = new javax.swing.JButton();
lblASLError = new javax.swing.JLabel();
lblInputError = new javax.swing.JLabel();
lblOutputError = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("ASL GUI");
setResizable(false);
lblInput.setFont(new java.awt.Font("Microsoft JhengHei UI Light", 0, 16));
lblInput.setText("Input Directory:");
lblInput.setOpaque(true);
txtInputDir.setFont(new java.awt.Font("Segoe UI Light", 0, 16));
lblOutput.setFont(new java.awt.Font("Microsoft JhengHei UI Light", 0, 16));
lblOutput.setText("Output Directory:");
lblOutput.setOpaque(true);
txtOutputDir.setFont(new java.awt.Font("Segoe UI Light", 0, 16));
btnInput.setText("...");
btnInput.setToolTipText("Opens a dialog to select input file");
btnInput.setFocusable(false);
btnInput.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btnInputMouseClicked(evt);
}
});
btnOutput.setText("...");
btnOutput.setToolTipText("Opens a dialog to select output directory");
btnOutput.setFocusable(false);
btnOutput.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btnOutputMouseClicked(evt);
}
});
lblASL.setFont(new java.awt.Font("Microsoft JhengHei UI Light", 0, 16));
lblASL.setText("ASL Compiler Directory");
lblASL.setOpaque(true);
txtASLDir.setFont(new java.awt.Font("Segoe UI Light", 0, 16));
btnASL.setText("...");
btnASL.setToolTipText("Opens a dialog to select the compiler location");
btnASL.setFocusable(false);
btnASL.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btnASLMouseClicked(evt);
}
});
jSeparator.setToolTipText("");
lblASLSmall.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10));
lblASLSmall.setText("Location of the asl.exe file.");
lblASLSmall.setOpaque(true);
lblInputSmall.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10));
lblInputSmall.setText("Directory of scripts that will be compiled in to the output directory.");
lblInputSmall.setOpaque(true);
lblOutputSmall.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10));
lblOutputSmall.setText("Directory that the compiled .sqf script(s) will be saved in.");
lblOutputSmall.setOpaque(true);
cbCompileAll.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 11));
cbCompileAll.setText("Compile all scripts in subfolders too.");
cbCompileAll.setFocusable(false);
cbCompileAll.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
cbCompileAllStateChanged(evt);
}
});
cbPrettyPrinting.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 11));
cbPrettyPrinting.setText("Activate pretty printing.");
cbPrettyPrinting.setFocusable(false);
cbPrettyPrinting.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
cbPrettyPrintingStateChanged(evt);
}
});
btnCompile.setFont(new java.awt.Font("Microsoft JhengHei UI Light", 0, 16));
btnCompile.setText("Compile");
btnCompile.setToolTipText("Opens a dialog to select output directory");
btnCompile.setFocusable(false);
btnCompile.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btnCompileMouseClicked(evt);
}
});
lblASLError.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10));
lblASLError.setForeground(java.awt.Color.red);
lblASLError.setText("Some error");
lblASLError.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lblASLErrorMouseClicked(evt);
}
});
lblInputError.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10));
lblInputError.setForeground(java.awt.Color.red);
lblInputError.setText("Some error");
lblOutputError.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10));
lblOutputError.setForeground(java.awt.Color.red);
lblOutputError.setText("Some error");
lblOutputError.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lblOutputErrorMouseClicked(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jSeparator).addGroup(layout.createSequentialGroup().addGap(15, 15, 15).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(lblOutputError, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(lblInputError, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false).addComponent(lblASLError, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(lblASL).addComponent(lblASLSmall).addGroup(layout.createSequentialGroup().addComponent(txtASLDir, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(6, 6, 6).addComponent(btnASL)).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(txtOutputDir, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(lblOutput, javax.swing.GroupLayout.Alignment.LEADING)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(btnOutput)).addComponent(lblOutputSmall).addComponent(lblInput).addGroup(layout.createSequentialGroup().addComponent(txtInputDir, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(btnInput)).addComponent(lblInputSmall).addComponent(cbCompileAll).addComponent(cbPrettyPrinting))).addComponent(btnCompile, javax.swing.GroupLayout.PREFERRED_SIZE, 373, javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(20, 20, 20)));
layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(6, 6, 6).addComponent(lblASL).addGap(3, 3, 3).addComponent(lblASLSmall).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(txtASLDir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(btnASL, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(4, 4, 4).addComponent(lblASLError).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(3, 3, 3).addComponent(lblInput).addGap(3, 3, 3).addComponent(lblInputSmall, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(txtInputDir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(btnInput, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(4, 4, 4).addComponent(lblInputError).addGap(6, 6, 6).addComponent(lblOutput).addGap(3, 3, 3).addComponent(lblOutputSmall, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(6, 6, 6).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(txtOutputDir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(btnOutput, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)).addGap(4, 4, 4).addComponent(lblOutputError).addGap(6, 6, 6).addComponent(cbCompileAll).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(cbPrettyPrinting).addGap(11, 11, 11).addComponent(btnCompile, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(11, 11, 11)));
pack();
setLocationRelativeTo(null);
}
private void btnInputMouseClicked(java.awt.event.MouseEvent evt) {
if (SwingUtilities.isLeftMouseButton(evt)) {
String path = fileChooser("Select input directory", 1);
File inputDir = new File(path);
if (inputDir.exists()) {
prefs.put("inputDir", path);
txtInputDir.setText(path);
if (inputError)
setErrorCondition(1, false);
}
}
}
private void btnOutputMouseClicked(java.awt.event.MouseEvent evt) {
if (SwingUtilities.isLeftMouseButton(evt)) {
String path = fileChooser("Select output directory", 1);
File outputDir = new File(path);
if (outputDir.exists()) {
prefs.put("outputDir", path);
txtOutputDir.setText(path);
if (outputError)
setErrorCondition(2, false);
}
}
}
private void btnASLMouseClicked(java.awt.event.MouseEvent evt) {
if (SwingUtilities.isLeftMouseButton(evt)) {
String path = fileChooser("Select 'asl.exe' location", 0);
File asl = new File(path);
if (asl.exists()) {
prefs.put("aslDir", path);
txtASLDir.setText(path);
if (aslError)
setErrorCondition(0, false);
}
}
}
private void btnCompileMouseClicked(java.awt.event.MouseEvent evt) {
if (SwingUtilities.isLeftMouseButton(evt)) {
JTextField[] dirFields = {txtASLDir, txtInputDir, txtOutputDir};
for (byte i = 0; i < 3; i++) {
File bleh = new File(dirFields[i].getText());
setErrorCondition(i, !bleh.exists());
}
if (aslError || inputError || outputError)
return;
String prettyPrinting = cbPrettyPrinting.isSelected() ? "-pretty" : "", compileAll = cbCompileAll.isSelected() ? "-r" : "", asl = txtASLDir.getText(), input = txtInputDir.getText(), output = txtOutputDir.getText(), error = " ";
try {
Process aslProcess = new ProcessBuilder(asl, compileAll, prettyPrinting, input, output).start();
BufferedReader br = new BufferedReader(new InputStreamReader(aslProcess.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
if (line.toLowerCase().contains("panic")) {
error = line;
}
}
aslProcess.waitFor();
} catch (IOException | InterruptedException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
if (!error.equals(" ")) {
DlgError showError = new DlgError(this, true, error);
showError.setLocationRelativeTo(this);
showError.setVisible(true);
}
}
}
private void cbCompileAllStateChanged(javax.swing.event.ChangeEvent evt) {
prefs.putBoolean("compileAll", cbCompileAll.isSelected());
}
private void cbPrettyPrintingStateChanged(javax.swing.event.ChangeEvent evt) {
prefs.putBoolean("prettyPrinting", cbPrettyPrinting.isSelected());
}
private void lblOutputErrorMouseClicked(java.awt.event.MouseEvent evt) {
if (SwingUtilities.isLeftMouseButton(evt) && outputError) {
new File(txtOutputDir.getText()).mkdirs();
setErrorCondition(2, false);
}
}
private void lblASLErrorMouseClicked(java.awt.event.MouseEvent evt) {
if (SwingUtilities.isLeftMouseButton(evt) && aslError) {
try {
URI github = new URI("https://github.com/DeKugelschieber/asl/releases");
java.awt.Desktop.getDesktop().browse(github);
} catch (URISyntaxException | IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
setErrorCondition(0, false);
}
}
public static void main(String args[]) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
UIManager.put("ToolTip.background", new ColorUIResource(255, 255, 255));
UIManager.put("ToolTip.foreground", new ColorUIResource(87, 87, 87));
Border lineBorder = BorderFactory.createLineBorder(new Color(118, 118, 118));
UIManager.put("ToolTip.border", lineBorder);
Border compoundBorder = BorderFactory.createCompoundBorder(UIManager.getBorder("ToolTip.border"), BorderFactory.createEmptyBorder(0, 2, 2, 3));
UIManager.put("ToolTip.border", compoundBorder);
java.awt.EventQueue.invokeLater(() -> {
new Main().setVisible(true);
});
}
private javax.swing.JButton btnASL;
private javax.swing.JButton btnCompile;
private javax.swing.JButton btnInput;
private javax.swing.JButton btnOutput;
private javax.swing.JCheckBox cbCompileAll;
private javax.swing.JCheckBox cbPrettyPrinting;
private javax.swing.JSeparator jSeparator;
private javax.swing.JLabel lblASL;
private javax.swing.JLabel lblASLError;
private javax.swing.JLabel lblASLSmall;
private javax.swing.JLabel lblInput;
private javax.swing.JLabel lblInputError;
private javax.swing.JLabel lblInputSmall;
private javax.swing.JLabel lblOutput;
private javax.swing.JLabel lblOutputError;
private javax.swing.JLabel lblOutputSmall;
private javax.swing.JTextField txtASLDir;
private javax.swing.JTextField txtInputDir;
private javax.swing.JTextField txtOutputDir;
}

6
run Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/home/marvin/Projekte/asl
go run src/main/asl.go $1 $2

6
run_tests Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/home/marvin/Projekte/asl
go test parser tokenizer types

View File

@@ -12,7 +12,7 @@ import (
) )
const ( const (
version = "1.2.0" version = "1.2.1"
extension = ".asl" extension = ".asl"
sqfextension = ".sqf" sqfextension = ".sqf"
typeinfo = "types" typeinfo = "types"

View File

@@ -131,7 +131,7 @@ func (c *Compiler) parseWhile() {
c.expect("{") c.expect("{")
c.parseBlock() c.parseBlock()
c.expect("}") c.expect("}")
c.appendOut("};", false) c.appendOut("};", true)
} }
func (c *Compiler) parseSwitch() { func (c *Compiler) parseSwitch() {
@@ -372,7 +372,7 @@ func (c *Compiler) parseFunctionCall(out bool, name string) string {
// buildin function // buildin function
buildin := types.GetFunction(name) buildin := types.GetFunction(name)
if buildin != nil { if buildin != nil {
if buildin.Type == types.NULL { if buildin.Type == types.NULL {
output = name output = name
@@ -398,7 +398,7 @@ func (c *Compiler) parseUnaryFunction(name, paramsStr string, paramCount int) st
if paramCount == 1 { if paramCount == 1 {
output = name + " " + paramsStr output = name + " " + paramsStr
} else { } else {
output = "[" + paramsStr + "] call " + name output = name + " [" + paramsStr + "]"
} }
return output return output

View File

@@ -35,7 +35,7 @@ func TestParserIf(t *testing.T) {
func TestParserWhile(t *testing.T) { func TestParserWhile(t *testing.T) {
got := getCompiled(t, "../../test/tokenizer_while.asl") got := getCompiled(t, "../../test/tokenizer_while.asl")
want := "while {true} do {\r\n};" want := "while {true} do {\r\n};\r\n"
equal(t, got, want) equal(t, got, want)
} }
@@ -195,6 +195,14 @@ func TestParserExpressionArray(t *testing.T) {
equal(t, got, want) equal(t, got, want)
} }
// bugfix: unary function parsing (e.g. "format")
func TestBugfixParserUnaryFunction(t *testing.T) {
got := getCompiled(t, "../../test/bugfix_unary_func_format.asl")
want := "format [\"%1 %2\", \"value1\", \"value2\"];\r\n[\"a\", \"b\", \"c\"] call someFunc;\r\n"
equal(t, got, want)
}
func getCompiled(t *testing.T, file string) string { func getCompiled(t *testing.T, file string) string {
code, err := ioutil.ReadFile(file) code, err := ioutil.ReadFile(file)

View File

@@ -0,0 +1,2 @@
format("%1 %2", "value1", "value2"); // must result in format [...];
someFunc("a", "b", "c"); // must result in ... call someFunc;

BIN
tools/ASL GUI.exe Normal file

Binary file not shown.

20
tools/README.md Normal file
View File

@@ -0,0 +1,20 @@
#ASL Tools
A visual tool set to ease the work of asl developers.
Maintained by yours truly: [654wak654](https://github.com/654wak654/)
**Notepad++ Syntax Higligthing**: https://github.com/DeKugelschieber/asl/blob/master/tools/asl.xml
Feel free to contribute with another text editor's syntax higligthing plugin.
##ASL GUI <img src="https://img.shields.io/badge/version-1.1.0.0-orange.svg" alt="version">
An optional Java interface to make the compile procces of ASL faster and more user-friendly. It's released under the MIT licence just like the core project. It also helps with error reporting of asl.
**Version 1.1.0.0**
- New Arma 3-themed look, and error reporting straight from asl.
- Program now depends on asl.exe, they need to be in the same directory.
**Version 1.0.0.0**
- More style changes and bug fixes, marked ready for release.
**Version 0.3.0.0:**
- Fixed some possible bugs, did some style fixes and other code adjustments. It's now is readable without getting cataracts. Mostly anyway...

33
tools/asl.xml Normal file

File diff suppressed because one or more lines are too long