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:
@@ -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