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" "path/filepath"
"strings" "strings"
"tokenizer" "tokenizer"
"types"
) )
const ( const (
version = "1.2.0" version = "1.2.0"
extension = ".asl" extension = ".asl"
sqfextension = ".sqf" sqfextension = ".sqf"
typeinfo = "types"
PathSeparator = string(os.PathSeparator) PathSeparator = string(os.PathSeparator)
) )
@@ -45,7 +47,10 @@ func usage() {
func flags(flag string) bool { func flags(flag string) bool {
flag = strings.ToLower(flag) flag = strings.ToLower(flag)
if flag[0] == '-' { if flag[0] != '-' {
return false
}
if flag == "-v" { if flag == "-v" {
fmt.Println("asl version " + version) fmt.Println("asl version " + version)
exit = true exit = true
@@ -59,9 +64,15 @@ func flags(flag string) bool {
} }
return true return true
} }
return false // 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. // Creates a list of all ASL files to compile.
@@ -163,6 +174,13 @@ func main() {
return return
} }
// load type information
loadTypes()
if exit {
return
}
// in/out parameter // in/out parameter
out := "" 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
}

2198
types Normal file

File diff suppressed because it is too large Load Diff