summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/texec/eval.go17
-rw-r--r--src/texec/libtnsl.go40
-rw-r--r--src/texec/world.go7
-rw-r--r--src/tparse/token.go20
-rw-r--r--src/tparse/type.go7
5 files changed, 73 insertions, 18 deletions
diff --git a/src/texec/eval.go b/src/texec/eval.go
new file mode 100644
index 0000000..8b22f01
--- /dev/null
+++ b/src/texec/eval.go
@@ -0,0 +1,17 @@
+/*
+ Copyright 2020 Kyle Gunger
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package texec
diff --git a/src/texec/libtnsl.go b/src/texec/libtnsl.go
index c77bd25..7bf4848 100644
--- a/src/texec/libtnsl.go
+++ b/src/texec/libtnsl.go
@@ -16,8 +16,44 @@
package texec
+import "fmt"
+
/**
- This file represents the 'tnsl' module and a key few functions.
- These functions should be all that is needed to use the compiler, and no more.
+ libtnsl module stub. Contains only parts of the io sub-module.
+ Parts included:
+ - io.print
+ - io.println
+ - io.open_file
+ - io.File API for file objects
*/
+// tells if the stub supports a function
+func tnslResolve(callPath TPath) bool {
+ l := len(callPath.Module)
+ if l < 2 || l > 3 || callPath.Module[0] != "tnsl" || callPath.Module[1] != "io" {
+ return false
+ }
+ if l > 2 && callPath.Module[2] != "File" {
+ return false
+ }
+
+ if l > 2 {
+ if callPath.Artifact == "write" || callPath.Artifact == "read" || callPath.Artifact == "close" {
+ return true;
+ }
+ } else {
+ if callPath.Artifact == "print" || callPath.Artifact == "println" || callPath.Artifact == "open_file" {
+ return true;
+ }
+ }
+
+ return false
+}
+
+// evaluate a function call.
+// out is the variable out (if any)
+// in is the variable in (if any)
+// callPath is the function being called.
+func tnslEval(out, in *TVaraiable, callPath TPath) {
+
+} \ No newline at end of file
diff --git a/src/texec/world.go b/src/texec/world.go
index 7f51c13..6fa6327 100644
--- a/src/texec/world.go
+++ b/src/texec/world.go
@@ -25,13 +25,14 @@ type TVariable struct {
// TPath represents a pointer to the current module and file
// that the thread is working in.
type TPath struct {
- module []string,
- file string
+ Module []string,
+ Artifact string
}
// TContext represents a single thread.
type TContext struct {
CallStack []Node,
+ CallEnv []TPath,
VarMap []map[string]TVariable
}
@@ -47,4 +48,4 @@ type TWorld struct {
Modules []TModule,
MainPath TPath,
MainFunc Node
-} \ No newline at end of file
+}
diff --git a/src/tparse/token.go b/src/tparse/token.go
index 6c84c72..b358568 100644
--- a/src/tparse/token.go
+++ b/src/tparse/token.go
@@ -1,17 +1,17 @@
/*
- Copyright 2020 Kyle Gunger
+ Copyright 2020 Kyle Gunger
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package tparse
diff --git a/src/tparse/type.go b/src/tparse/type.go
index 8a38527..329aec3 100644
--- a/src/tparse/type.go
+++ b/src/tparse/type.go
@@ -71,9 +71,10 @@ func checkPreWord(s string) int {
// RESWORD represents all the reserved words and what type of tokens they are.
var RESWORD = map[string]int{
- "bool": KEYTYPE,
- "char": KEYTYPE,
- "charp": KEYTYPE,
+ "bool": KEYTYPE,
+ "char": KEYTYPE,
+ "charp": KEYTYPE,
+ "string": KEYTYPE,
"int": KEYTYPE,
"int8": KEYTYPE,