Started loading type information.

This commit is contained in:
Marvin Blum
2015-12-17 22:49:56 +01:00
parent ed1d19851e
commit 05e6937201
3 changed files with 2263 additions and 15 deletions

View File

@@ -8,12 +8,14 @@ import (
"path/filepath"
"strings"
"tokenizer"
"types"
)
const (
version = "1.2.0"
extension = ".asl"
sqfextension = ".sqf"
typeinfo = "types"
PathSeparator = string(os.PathSeparator)
)
@@ -45,23 +47,32 @@ func usage() {
func flags(flag string) bool {
flag = strings.ToLower(flag)
if flag[0] == '-' {
if flag == "-v" {
fmt.Println("asl version " + version)
exit = true
} else if flag == "-r" {
recursive = true
} else if flag == "-pretty" {
pretty = true
} else if flag == "--help" {
usage()
exit = true
}
return true
if flag[0] != '-' {
return false
}
return false
if flag == "-v" {
fmt.Println("asl version " + version)
exit = true
} else if flag == "-r" {
recursive = true
} else if flag == "-pretty" {
pretty = true
} else if flag == "--help" {
usage()
exit = true
}
return true
}
// Loads types from types file.
// If none is provided, an error will be printed.
func loadTypes() {
if err := types.LoadTypes(typeinfo); err != nil {
fmt.Println("No 'types' file provided. Please add type information to this file from 'supportInfo' script command output.")
exit = true
}
}
// Creates a list of all ASL files to compile.
@@ -163,6 +174,13 @@ func main() {
return
}
// load type information
loadTypes()
if exit {
return
}
// in/out parameter
out := ""

32
src/types/loader.go Normal file
View File

@@ -0,0 +1,32 @@
package types
import (
"fmt"
"io/ioutil"
"strings"
)
// Loads type information from file.
func LoadTypes(path string) error {
content, err := ioutil.ReadFile(path)
if err != nil {
return err
}
if err := parseTypes(string(content)); err != nil {
return err
}
return nil
}
func parseTypes(content string) error {
lines := strings.Split(content, "\\n")
for _, line := range lines {
fmt.Println(line)
}
return nil
}