mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 03:50:25 +00:00
Started loading type information.
This commit is contained in:
@@ -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,7 +47,10 @@ func usage() {
|
||||
func flags(flag string) bool {
|
||||
flag = strings.ToLower(flag)
|
||||
|
||||
if flag[0] == '-' {
|
||||
if flag[0] != '-' {
|
||||
return false
|
||||
}
|
||||
|
||||
if flag == "-v" {
|
||||
fmt.Println("asl version " + version)
|
||||
exit = true
|
||||
@@ -61,7 +66,13 @@ func flags(flag string) bool {
|
||||
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.
|
||||
@@ -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
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