From 1100ac865074effb3a4735c7449779f7193b7d0c Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Fri, 3 Dec 2021 18:25:03 -0500 Subject: General updates + Fill out eval a little and make sure that this builds. ~ CF kinda broken in AST. Gonna have to fix that. Upcoming Parser update. --- src/texec/eval.go | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'src/texec/eval.go') 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 } //################# -- cgit v1.2.3