From 705d62fdf1752e94df2071fdea16b41a124a15e6 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Mon, 1 Nov 2021 02:22:29 -0400 Subject: [EXEC] Initialize + Some initial files for use in the interpreter --- src/texec/libtnsl.go | 23 ++++++++++++++++++++++ src/texec/world.go | 50 +++++++++++++++++++++++++++++++++++++++++++++++ src/texec/worldbuilder.go | 24 +++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 src/texec/libtnsl.go create mode 100644 src/texec/world.go create mode 100644 src/texec/worldbuilder.go (limited to 'src') diff --git a/src/texec/libtnsl.go b/src/texec/libtnsl.go new file mode 100644 index 0000000..c77bd25 --- /dev/null +++ b/src/texec/libtnsl.go @@ -0,0 +1,23 @@ +/* + 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 + +/** + 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. +*/ + diff --git a/src/texec/world.go b/src/texec/world.go new file mode 100644 index 0000000..7f51c13 --- /dev/null +++ b/src/texec/world.go @@ -0,0 +1,50 @@ +/* + 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 + +// TVaraiable represents a single variable in the program +type TVariable struct { + Type string + Data interface{} +} + +// TPath represents a pointer to the current module and file +// that the thread is working in. +type TPath struct { + module []string, + file string +} + +// TContext represents a single thread. +type TContext struct { + CallStack []Node, + VarMap []map[string]TVariable +} + +// TModule represents a collection of files and sub-modules in a program +type Module struct { + Files []Node, + Globals []map[string]TVariable + Sub []TModule +} + +// TWorld represents the full program +type TWorld struct { + Modules []TModule, + MainPath TPath, + MainFunc Node +} \ No newline at end of file diff --git a/src/texec/worldbuilder.go b/src/texec/worldbuilder.go new file mode 100644 index 0000000..37f05db --- /dev/null +++ b/src/texec/worldbuilder.go @@ -0,0 +1,24 @@ +/* + 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 + +import "tparse" + +/** + worldbuilder.go - take in a file name and construct a TWorld based on it. +*/ + -- cgit v1.2.3