mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 03:50: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. |
|
||||
| -pretty | optional | Enable pretty printing to SQF. |
|
||||
| --help | optional | Show usage. |
|
||||
| <input directory> | required | Directory to read ASL files from. |
|
||||
| <output directory> | required | Directory for SQF output. Can be the same as input directory. |
|
||||
| input directory | required | Directory to read ASL files from. |
|
||||
| output directory | required | Directory for SQF output. Can be the same as input directory. |
|
||||
|
||||
**Example:**
|
||||
|
||||
|
||||
3
ToDo.md
3
ToDo.md
@@ -11,6 +11,9 @@
|
||||
* ~~negative values e.g. -1, operator !~~
|
||||
* ~~tokenizer splits commands like "format" -> for, mat~~
|
||||
* ~~try ... catch~~
|
||||
* better error reporting
|
||||
- recover panic
|
||||
- line, column
|
||||
|
||||
## 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
|
||||
// and writes SQF code into desired location.
|
||||
func Parse(token []Token, prettyPrinting bool) string {
|
||||
initParser(token, prettyPrinting)
|
||||
if !initParser(token, prettyPrinting) {
|
||||
return ""
|
||||
}
|
||||
|
||||
for tokenIndex < len(token) {
|
||||
parseBlock()
|
||||
|
||||
@@ -7,9 +7,9 @@ var offset int
|
||||
var pretty bool
|
||||
|
||||
// Initilizes the parser.
|
||||
func initParser(token []Token, prettyPrinting bool) {
|
||||
func initParser(token []Token, prettyPrinting bool) bool {
|
||||
if len(token) == 0 {
|
||||
panic("No tokens provided")
|
||||
return false
|
||||
}
|
||||
|
||||
tokens = token
|
||||
@@ -17,6 +17,8 @@ func initParser(token []Token, prettyPrinting bool) {
|
||||
out = ""
|
||||
offset = 0
|
||||
pretty = prettyPrinting
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Returns true, if current token matches expected one.
|
||||
|
||||
Reference in New Issue
Block a user