mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
Removed panic on "no tokens provided".
This commit is contained in:
@@ -28,8 +28,8 @@ asl [-v|-r|-pretty|--help] <input directory> <output directory>
|
|||||||
| -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. |
|
| input directory | required | Directory to read ASL files from. |
|
||||||
| <output directory> | required | Directory for SQF output. Can be the same as input directory. |
|
| output directory | required | Directory for SQF output. Can be the same as input directory. |
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
|
|||||||
3
ToDo.md
3
ToDo.md
@@ -11,6 +11,9 @@
|
|||||||
* ~~negative values e.g. -1, operator !~~
|
* ~~negative values e.g. -1, operator !~~
|
||||||
* ~~tokenizer splits commands like "format" -> for, mat~~
|
* ~~tokenizer splits commands like "format" -> for, mat~~
|
||||||
* ~~try ... catch~~
|
* ~~try ... catch~~
|
||||||
|
* better error reporting
|
||||||
|
- recover panic
|
||||||
|
- line, column
|
||||||
|
|
||||||
## Special cases
|
## Special cases
|
||||||
|
|
||||||
|
|||||||
0
in/sub/empty.asl
Normal file
0
in/sub/empty.asl
Normal file
0
out/sub/empty.sqf
Normal file
0
out/sub/empty.sqf
Normal file
@@ -9,7 +9,9 @@ const TAB = " "
|
|||||||
// Parses tokens, validates code to a specific degree
|
// Parses tokens, validates code to a specific degree
|
||||||
// and writes SQF code into desired location.
|
// and writes SQF code into desired location.
|
||||||
func Parse(token []Token, prettyPrinting bool) string {
|
func Parse(token []Token, prettyPrinting bool) string {
|
||||||
initParser(token, prettyPrinting)
|
if !initParser(token, prettyPrinting) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
for tokenIndex < len(token) {
|
for tokenIndex < len(token) {
|
||||||
parseBlock()
|
parseBlock()
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ var offset int
|
|||||||
var pretty bool
|
var pretty bool
|
||||||
|
|
||||||
// Initilizes the parser.
|
// Initilizes the parser.
|
||||||
func initParser(token []Token, prettyPrinting bool) {
|
func initParser(token []Token, prettyPrinting bool) bool {
|
||||||
if len(token) == 0 {
|
if len(token) == 0 {
|
||||||
panic("No tokens provided")
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
tokens = token
|
tokens = token
|
||||||
@@ -17,6 +17,8 @@ func initParser(token []Token, prettyPrinting bool) {
|
|||||||
out = ""
|
out = ""
|
||||||
offset = 0
|
offset = 0
|
||||||
pretty = prettyPrinting
|
pretty = prettyPrinting
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true, if current token matches expected one.
|
// Returns true, if current token matches expected one.
|
||||||
|
|||||||
Reference in New Issue
Block a user