summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--base.tnsl5
-rw-r--r--src/tparse/tree.go12
-rw-r--r--src/tparse/type.go2
-rw-r--r--tests/block-test.tnsl20
-rw-r--r--tests/literal-test.tnsl21
6 files changed, 56 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 01f9cb9..a4d6217 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
build/
-.vscode/ \ No newline at end of file
+.vscode/
+
+*-test.tnp \ No newline at end of file
diff --git a/base.tnsl b/base.tnsl
index a74997f..f291cf3 100644
--- a/base.tnsl
+++ b/base.tnsl
@@ -1,2 +1,5 @@
-
+# This
;a.pl()
+
+# Same
+; a . pl () \ No newline at end of file
diff --git a/src/tparse/tree.go b/src/tparse/tree.go
index 41896fc..48c198c 100644
--- a/src/tparse/tree.go
+++ b/src/tparse/tree.go
@@ -10,9 +10,15 @@ type Node struct {
// Directive represents a block or single directive
type Directive struct {
Type string
- ID string
+ Data string
- Data []string
+ Param Paramaters
+}
+
+// Paramaters represents a set of paramaters for a directive
+type Paramaters struct {
+ In []string
+ Out []string
}
func handleCode(tokens *[]Token, start int) (Node, int) {
@@ -30,7 +36,7 @@ func handlePre(tokens *[]Token, start int) (Node, int) {
// CreateTree takes a series of tokens and converts them into an AST
func CreateTree(tokens *[]Token, start int) Node {
out := Node{}
- out.Dir = Directive{Type: "root", ID: "root"}
+ out.Dir = Directive{Type: "root"}
var tmp Node
diff --git a/src/tparse/type.go b/src/tparse/type.go
index dc0df10..735f681 100644
--- a/src/tparse/type.go
+++ b/src/tparse/type.go
@@ -40,6 +40,8 @@ var RESWORD = map[string]int{
"int": KEYTYPE,
"float": KEYTYPE,
+ "string": KEYTYPE,
+
"struct": KEYWORD,
"type": KEYWORD,
diff --git a/tests/block-test.tnsl b/tests/block-test.tnsl
index 14663f3..a05ca60 100644
--- a/tests/block-test.tnsl
+++ b/tests/block-test.tnsl
@@ -2,14 +2,32 @@
/;if (i==0)
;i = 2
-;//;else
+
+;/
+/;else
;i = 0
+
;/
# ;; can be used as a quick block re-definition
/;if (i==0)
;i = 2
+
;;else
;i = 0
+
+;/
+
+/;if
+ ;char ch = '\n'
+
+;;else
+ ;int it = 90
+
+;/
+
+/;main
+ ;
+
;/ \ No newline at end of file
diff --git a/tests/literal-test.tnsl b/tests/literal-test.tnsl
index a7fd81e..b447e57 100644
--- a/tests/literal-test.tnsl
+++ b/tests/literal-test.tnsl
@@ -1,10 +1,27 @@
+# These should all work
;string s = "\""
;string st="\\"
;int i = 0
;int j=1
-;float f = .2
+;float f = 0.2
;float d=3.1415
-;char c = '\'';char ch='\uxxxx'
+;char c = '\'';char ch='\u0000'
+
+# Invalid (some may be weeded out through the verify phase):
+
+;string s ""
+
+;int 0 i
+
+# Invalid ops should also be detected if dealing with literals
+
+;char c ~= 's'
+
+# Debate over weather these are legal
+
+;int k = .1
+
+;int l = 0x01 \ No newline at end of file