summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/texec/eval.go45
-rw-r--r--src/texec/libtnsl.go18
-rw-r--r--src/texec/world.go2
-rw-r--r--src/tparse/tree-value.go7
4 files changed, 58 insertions, 14 deletions
diff --git a/src/texec/eval.go b/src/texec/eval.go
index 93cbfdb..0542a97 100644
--- a/src/texec/eval.go
+++ b/src/texec/eval.go
@@ -160,6 +160,43 @@ func equateType(a, b TType) bool {
// Generate a TType from a 'type' node
func getType(t tparse.Node) TType {
out := TType{}
+ i := 0
+
+ // Pre
+ for ; i < len(t.Sub); i++ {
+ if t.Sub[i].Data.Type == tparse.DEFWORD || t.Sub[i].Data.Type == tparse.KEYTYPE {
+ break
+ } else {
+ out.Pre = append(out.Pre, t.Sub[i].Data.Data)
+ }
+ }
+
+ // T
+ for ; i < len(t.Sub); i++ {
+ if t.Sub[i].Data.Type == tparse.KEYTYPE {
+ out.T.Name = t.Sub[i].Data.Data
+ i++
+ break
+ } else if t.Sub[i].Data.Type == tparse.DEFWORD {
+ if i < len(t.Sub) - 1 {
+ if t.Sub[i + 1].Data.Type == tparse.DEFWORD {
+ out.T.Path = append(out.T.Path, t.Sub[i].Data.Data)
+ } else {
+ out.T.Name = t.Sub[i].Data.Data
+ break
+ }
+ } else {
+ out.T.Name = t.Sub[i].Data.Data
+ }
+ }
+ }
+
+ // Post
+ if i < len(t.Sub) {
+ if t.Sub[i].Data.Data == "`" {
+ out.Post = "`"
+ }
+ }
return out
}
@@ -167,20 +204,20 @@ func getType(t tparse.Node) TType {
// Value generation
func getStringLiteral(v tparse.Node) []byte {
-
+ return []byte{}
}
func getCharLiteral(v tparse.Node) byte {
-
+ return 0
}
func getIntLiteral(v tparse.Node) int {
-
+ return 0
}
// Get a literal value from nodes. Must specify type of literal to generate.
func getLiteral(v tparse.Node, t TType) interface{} {
-
+ return 0
}
//#################
diff --git a/src/texec/libtnsl.go b/src/texec/libtnsl.go
index 000af7d..b1c1907 100644
--- a/src/texec/libtnsl.go
+++ b/src/texec/libtnsl.go
@@ -43,14 +43,14 @@ import (
// Generic in-built types
var (
- tFile = TType{Pre: []string{}, T: TArtifact{Path: []string{"tnsl", "io"}, Name: "File"}, Post: []string{}}
- tString = TType{Pre: []string{"{}"}, T: TArtifact{Path: []string{}, Name:"charp"}, Post: []string{}}
- tInt = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name:"int"}, Post: []string{}}
- tByte = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name:"uint8"}, Post: []string{}}
- tByteArray = TType{Pre: []string{"{}"}, T: TArtifact{Path: []string{}, Name:"uint8"}, Post: []string{}}
- tFloat = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name:"float"}, Post: []string{}}
- tCharp = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name:"charp"}, Post: []string{}}
- tNull = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name: "null"}, Post: []string{}}
+ tFile = TType{Pre: []string{}, T: TArtifact{Path: []string{"tnsl", "io"}, Name: "File"}, Post: ""}
+ tString = TType{Pre: []string{"{}"}, T: TArtifact{Path: []string{}, Name:"charp"}, Post: ""}
+ tInt = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name:"int"}, Post: ""}
+ tByte = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name:"uint8"}, Post: ""}
+ tByteArray = TType{Pre: []string{"{}"}, T: TArtifact{Path: []string{}, Name:"uint8"}, Post: ""}
+ tFloat = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name:"float"}, Post: ""}
+ tCharp = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name:"charp"}, Post: ""}
+ tNull = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name: "null"}, Post: ""}
)
// tells if the stub supports a function
@@ -150,7 +150,7 @@ func tfile_write(file, in TVariable) {
b := []byte{0}
b[0] = (in.Data).(byte)
(file.Data).(*os.File).Write(b)
- } else if equateType(in.Type, tByteArray) {
+ } else if equateType(in.Type, tByteArray) || equateType(in.Type, tString) {
(file.Data).(*os.File).Write((in.Data).([]byte))
}
} else {
diff --git a/src/texec/world.go b/src/texec/world.go
index b1c6def..d0435a0 100644
--- a/src/texec/world.go
+++ b/src/texec/world.go
@@ -28,7 +28,7 @@ type TArtifact struct {
type TType struct {
Pre []string
T TArtifact
- Post []string
+ Post string
}
// TVariable represents a single variable in the program
diff --git a/src/tparse/tree-value.go b/src/tparse/tree-value.go
index 609e9d7..c44cdb6 100644
--- a/src/tparse/tree-value.go
+++ b/src/tparse/tree-value.go
@@ -410,8 +410,15 @@ func parseType(tokens *[]Token, tok, max int, param bool) (Node, int) {
tmp.Data = t
tok++
}
+
out.Sub = append(out.Sub, tmp)
+ if param && (*tokens)[tok].Data == "`" {
+ tmp = Node{(*tokens)[tok], []Node{}}
+ out.Sub = append(out.Sub, tmp)
+ tok++
+ }
+
return out, tok
case KEYWORD: