mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
Started loading type information.
This commit is contained in:
@@ -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,23 +47,32 @@ 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] != '-' {
|
||||||
if flag == "-v" {
|
return false
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
// 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
32
src/types/loader.go
Normal 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user