removed uncapitalized ghost files

This commit is contained in:
Bram Dingelstad 2021-12-06 17:50:47 +01:00
parent 4251e63cc9
commit 369b01cd47
4 changed files with 0 additions and 522 deletions

View file

@ -1,214 +0,0 @@
extends Object
enum ExecutionState {
Stopped,
Running,
WaitingForOption,
Suspended
}
enum HandlerState {
PauseExecution,
ContinueExecution
}
#Compile Status return
enum CompileStatus {
Succeeded, SucceededUntaggedStrings,
}
enum ByteCode {
# opA = string: label name
Label,
# opA = string: label name
JumpTo,
# peek string from stack and jump to that label
Jump,
# opA = int: string number
RunLine,
# opA = string: command text
RunCommand,
# opA = int: string number for option to add
AddOption,
# present the current list of options, then clear the list; most recently
# selected option will be on the top of the stack
ShowOptions,
# opA = int: string number in table; push string to stack
PushString,
# opA = float: number to push to stack
PushNumber,
# opA = int (0 or 1): bool to push to stack
PushBool,
# pushes a null value onto the stack
PushNull,
# opA = string: label name if top of stack is not null, zero or false, jumps
# to that label
JumpIfFalse,
# discard top of stack
Pop,
# opA = string; looks up function, pops as many arguments as needed, result is
# pushed to stack
CallFunc,
# opA = name of variable to get value of and push to stack
PushVariable,
# opA = name of variable to store top of stack in
StoreVariable,
# stops execution
Stop,
# run the node whose name is at the top of the stack
RunNode
}
enum TokenType {
#0 Special tokens
Whitespace, Indent, Dedent, EndOfLine, EndOfInput,
#5 Numbers. Everybody loves a number
Number,
#6 Strings. Everybody also loves a string
Str,
#7 '#'
TagMarker,
#8 Command syntax ('<<foo>>')
BeginCommand, EndCommand,
ExpressionFunctionStart, # {
ExpressionFunctionEnd, # }
FormatFunctionStart, # [
FormatFunctionEnd, # ]
#10 Variables ('$foo')
Variable,
#11 Shortcut syntax ('->')
ShortcutOption,
#12 Option syntax ('[[Let's go here|Destination]]')
OptionStart, # [[
OptionDelimit, # |
OptionEnd, # ]]
#15 Command types (specially recognised command word)
IfToken, ElseIf, ElseToken, EndIf, Set,
#20 Boolean values
TrueToken, FalseToken,
#22 The null value
NullToken,
#23 Parentheses
LeftParen, RightParen,
#25 Parameter delimiters
Comma,
#26 Operators
EqualTo, # ==, eq, is
GreaterThan, # >, gt
GreaterThanOrEqualTo, # >=, gte
LessThan, # <, lt
LessThanOrEqualTo, # <=, lte
NotEqualTo, # !=, neq
#32 Logical operators
Or, # ||, or
And, # &&, and
Xor, # ^, xor
Not, # !, not
# this guy's special because '=' can mean either 'equal to'
#36 or 'becomes' depending on context
EqualToOrAssign, # =, to
#37
UnaryMinus, # -; this is differentiated from Minus
# when parsing expressions
#38
Add, # +
Minus, # -
Multiply, # *
Divide, # /
Modulo, # %
#43
AddAssign, # +=
MinusAssign, # -=
MultiplyAssign, # *=
DivideAssign, # /=
Comment, # a run of text that we ignore
Identifier, # a single word (used for functions)
Text # a run of text until we hit other syntax
}
enum ExpressionType {
Value,
FunctionCall
}
enum StatementTypes {
CustomCommand,
ShortcutOptionGroup,
Block,
IfStatement,
OptionStatement,
AssignmentStatement,
Line,
InlineExpression
}
enum ValueType {
Number,
Str,
Boolean,
Variable,
Nullean
}
static func token_type_name(value):
for key in TokenType.keys():
if TokenType[key] == value:
return key
return 'NOTVALID'
static func merge_dir(target, patch):
for key in patch:
target[key] = patch[key]
static func bytecode_name(bytecode):
return [
'Label',
'JumpTo',
'Jump',
'RunLine',
'RunCommand',
'AddOption',
'ShowOptions',
'PushString',
'PushNumber',
'PushBool',
'PushNull',
'JumpIfFalse',
'Pop',
'CallFunc',
'PushVariable',
'StoreVariable',
'Stop',
'RunNode'
][bytecode]
static func token_name(type):
for key in TokenType.keys():
if TokenType[key] == type:
return key
return ''

View file

@ -1,25 +0,0 @@
extends Object
const FunctionInfo = preload('res://addons/Wol/core/FunctionInfo.gd')
const Constants = preload('res://addons/Wol/core/Constants.gd')
var functions = {}
var virtual_machine
func get_function(name):
if functions.has(name):
return functions[name]
else :
printerr('Invalid Function: %s'% name)
return
func import_library(other):
Constants.merge_dir(functions, other.functions)
other.virtual_machine = virtual_machine
func register_function(name, parameter_count, function, returns_value):
var functionInfo = FunctionInfo.new(name, parameter_count, function, returns_value)
functions[name] = functionInfo
func deregister_function(name):
functions.erase(name)

View file

@ -1,146 +0,0 @@
extends Object
const Constants = preload('res://addons/Wol/core/Constants.gd')
var name = ''
var filename = ''
var strings = {}
var nodes = {}
class Line:
var text = ''
var node_name = ''
var line_number = -1
var file_name = ''
var implicit = false
var substitutions = []
var meta = []
func _init(_text, _node_name, _line_number, _file_name, _implicit, _meta):
text = _text
node_name = _node_name
file_name = _file_name
implicit = _implicit
meta = _meta
func clone():
return get_script().new(text, node_name, line_number, file_name, implicit, meta)
func _to_string():
return '%s:%d: "%s"' % [file_name.get_file(), line_number, text]
class Option:
var line
var id = -1
var destination = ''
func _init(_line, _id, _destination):
line = _line
id = _id
destination = _destination
func clone():
return get_script().new(self)
class Command:
var command = ''
func _init(_command):
command = _command
class WolNode:
var name = ''
var instructions = []
var labels = {}
var tags = []
var source_id = ''
func _init(other = null):
if other != null and other.get_script() == self.get_script():
name = other.name
instructions += other.instructions
for key in other.labels.keys():
labels[key] = other.labels[key]
tags += other.tags
source_id = other.source_id
func equals(other):
if other.get_script() != get_script():
return false
if other.name != name:
return false
if other.instructions != instructions:
return false
if other.labels != labels:
return false
if other.source_id != source_id:
return false
return true
func _to_string():
return "WolNode[%s:%s]" % [name, source_id]
# TODO: Make this make sense
class Operand:
enum ValueType {
None,
StringValue,
BooleanValue,
FloatValue
}
var value
var type
func _init(_value):
if typeof(_value) == TYPE_OBJECT and _value.get_script() == get_script():
set_value(_value.value)
else:
set_value(_value)
func set_value(_value):
match typeof(_value):
TYPE_REAL,TYPE_INT:
set_number(_value)
TYPE_BOOL:
set_boolean(_value)
TYPE_STRING:
set_string(_value)
func set_boolean(_value):
value = _value
type = ValueType.BooleanValue
return self
func set_string(_value):
value = _value
type = ValueType.StringValue
return self
func set_number(_value):
value = _value
type = ValueType.FloatValue
return self
func clear_value():
type = ValueType.None
value = null
func clone():
return get_script().new(self)
func _to_string():
return "Operand[%s:%s]" % [type, value]
class Instruction:
var operation = -1
var operands = []
func _init(other = null):
if other != null and other.get_script() == self.get_script():
self.operation = other.operation
self.operands += other.operands
func _to_string():
return Constants.bytecode_name(operation) + ':' + operands as String

View file

@ -1,137 +0,0 @@
extends Object
const Constants = preload('res://addons/Wol/core/Constants.gd')
const NANI = 'NaN'
var type = Constants.ValueType.Nullean
var number = 0
var string = ''
var variable = ''
var boolean = false
func _init(value = NANI):
if typeof(value) == TYPE_OBJECT and value.get_script() == get_script():
if value.type == Constants.ValueType.Variable:
type = value.type
variable = value.variable
else:
set_value(value)
func value():
match type:
Constants.ValueType.Number:
return number
Constants.ValueType.Str:
return string
Constants.ValueType.Boolean:
return boolean
Constants.ValueType.Variable:
return variable
return null
func as_bool():
match type:
Constants.ValueType.Number:
return number != 0
Constants.ValueType.Str:
return !string.empty()
Constants.ValueType.Boolean:
return boolean
return false
func as_string():
return '%s' % value()
func as_number():
match type:
Constants.ValueType.Number:
return number
Constants.ValueType.Str:
return float(string)
Constants.ValueType.Boolean:
return 0.0 if !boolean else 1.0
return .0
func set_value(value):
if value == null or (typeof(value) == TYPE_STRING and value == NANI):
type = Constants.ValueType.Nullean
return
match typeof(value):
TYPE_INT, TYPE_REAL:
type = Constants.ValueType.Number
number = value
TYPE_STRING:
type = Constants.ValueType.Str
string = value
TYPE_BOOL:
type = Constants.ValueType.Boolean
boolean = value
func add(other):
if type == Constants.ValueType.Str or other.type == Constants.ValueType.Str:
return get_script().new('%s%s' % [value(), other.value()])
if type == Constants.ValueType.Number and other.type == Constants.ValueType.Number:
return get_script().new(number + other.number)
return null
func equals(other):
if other.get_script() != get_script():
return false
if other.value() != value():
return false
# TODO: Add more equality cases
return true
func sub(other):
if type == Constants.ValueType.Str or other.type == Constants.ValueType.Str:
return get_script().new(str(value()).replace(str(other.value()),''))
if type == Constants.ValueType.Number and other.type == Constants.ValueType.Number:
return get_script().new(number - other.number)
return null
func mult(other):
if type == Constants.ValueType.Number and other.type == Constants.ValueType.Number:
return get_script().new(number * other.number)
return null
func div(other):
if type == Constants.ValueType.Number and other.type == Constants.ValueType.Number:
return get_script().new(number / other.number)
return null
func mod(other):
if type == Constants.ValueType.Number and other.type == Constants.ValueType.Number:
return get_script().new(number % other.number)
return null
func negative():
if type == Constants.ValueType.Number:
return get_script().new(-number)
return null
func greater(other):
if type == Constants.ValueType.Number and other.type == Constants.ValueType.Number:
return number > other.number
return false
func less(other):
if type == Constants.ValueType.Number and other.type == Constants.ValueType.Number:
return number < other.number
return false
func geq(other):
if type == Constants.ValueType.Number and other.type == Constants.ValueType.Number:
return number > other.number or equals(other)
return false
func leq(other):
if type == Constants.ValueType.Number and other.type == Constants.ValueType.Number:
return number < other.number or equals(other)
return false
func _to_string():
return 'value(type[%s]: %s)' % [type,value()]