did a bunch of renaming and restructuring

This commit is contained in:
Bram Dingelstad 2021-11-20 14:38:46 +01:00
parent 6c565b0865
commit e3bac32178
6 changed files with 343 additions and 402 deletions

View file

@ -1,20 +0,0 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
#This is a test of the keyboard omg is it working i hope so please make sure it works 12345678910
#Do you think that it works. So maybe PPPP

View file

@ -216,15 +216,15 @@ func generate_statement(node,statement):
# print('generating statement') # print('generating statement')
match statement.type: match statement.type:
Constants.StatementTypes.CustomCommand: Constants.StatementTypes.CustomCommand:
generate_custom_command(node,statement.customCommand) generate_custom_command(node,statement.custom_command)
Constants.StatementTypes.ShortcutOptionGroup: Constants.StatementTypes.ShortcutOptionGroup:
generate_shortcut_group(node,statement.shortcutOptionGroup) generate_shortcut_group(node,statement.shortcut_option_group)
Constants.StatementTypes.Block: Constants.StatementTypes.Block:
generate_block(node,statement.block.statements) generate_block(node,statement.block.statements)
Constants.StatementTypes.IfStatement: Constants.StatementTypes.IfStatement:
generate_if(node,statement.ifStatement) generate_if(node,statement.if_statement)
Constants.StatementTypes.OptionStatement: Constants.StatementTypes.OptionStatement:
generate_option(node,statement.optionStatement) generate_option(node,statement.option_statement)
Constants.StatementTypes.AssignmentStatement: Constants.StatementTypes.AssignmentStatement:
generate_assignment(node,statement.assignment) generate_assignment(node,statement.assignment)
Constants.StatementTypes.Line: Constants.StatementTypes.Line:
@ -240,7 +240,7 @@ func generate_custom_command(node,command):
if command.expression != null: if command.expression != null:
generate_expression(node,command.expression) generate_expression(node,command.expression)
else: else:
var commandString = command.clientCommand var commandString = command.client_command
if commandString == 'stop': if commandString == 'stop':
emit(Constants.ByteCode.Stop,node) emit(Constants.ByteCode.Stop,node)
else : else :
@ -313,23 +313,23 @@ func generate_block(node,statements:Array=[]):
#compile if branching instructions #compile if branching instructions
func generate_if(node,ifStatement): func generate_if(node,if_statement):
# print('generating if') # print('generating if')
#jump to label @ end of every clause #jump to label @ end of every clause
var endif : String = register_label('endif') var endif : String = register_label('endif')
for clause in ifStatement.clauses: for clause in if_statement.clauses:
var endClause : String = register_label('skip_clause') var end_clause : String = register_label('skip_clause')
if clause.expression!=null: if clause.expression!=null:
generate_expression(node,clause.expression) generate_expression(node,clause.expression)
emit(Constants.ByteCode.JumpIfFalse,node,[Program.Operand.new(endClause)]) emit(Constants.ByteCode.JumpIfFalse,node,[Program.Operand.new(end_clause)])
generate_block(node,clause.statements) generate_block(node,clause.statements)
emit(Constants.ByteCode.JumpTo,node,[Program.Operand.new(endif)]) emit(Constants.ByteCode.JumpTo,node,[Program.Operand.new(endif)])
if clause.expression!=null: if clause.expression!=null:
emit(Constants.ByteCode.Label,node,[Program.Operand.new(endClause)]) emit(Constants.ByteCode.Label,node,[Program.Operand.new(end_clause)])
if clause.expression!=null: if clause.expression!=null:
emit(Constants.ByteCode.Pop) emit(Constants.ByteCode.Pop)
@ -451,7 +451,6 @@ func emit_error(error : int)->void:
_lastError = error _lastError = error
_errors |= _lastError _errors |= _lastError
static func print_tokens(tokens:Array=[]): static func print_tokens(tokens:Array=[]):
var list : PoolStringArray = [] var list : PoolStringArray = []
list.append('\n') list.append('\n')

File diff suppressed because it is too large Load diff

View file

@ -145,12 +145,10 @@ enum TokenType {
Text # a run of text until we hit other syntax Text # a run of text until we hit other syntax
} }
enum ExpressionType { enum ExpressionType {
Value, FunctionCall Value, FunctionCall
} }
enum StatementTypes { enum StatementTypes {
CustomCommand, CustomCommand,
ShortcutOptionGroup, ShortcutOptionGroup,
@ -169,10 +167,7 @@ enum ValueType {
Nullean Nullean
} }
func defaultValue(type): static func token_type_name(value):
pass
static func token_type_name(value:int)->String:
for key in TokenType.keys(): for key in TokenType.keys():
if TokenType[key] == value: if TokenType[key] == value:
return key return key
@ -182,14 +177,6 @@ static func merge_dir(target, patch):
for key in patch: for key in patch:
target[key] = patch[key] target[key] = patch[key]
func token_name(type)->String:
var string : String = ''
for key in TokenType.keys():
if TokenType[key] == type:
return key
return string
static func bytecode_name(bytecode): static func bytecode_name(bytecode):
return [ return [
'Label', 'Label',

View file

@ -1,5 +1,5 @@
extends Object extends Object
class_name WolProgram class_name Program
const Constants = preload('res://addons/Wol/core/constants.gd') const Constants = preload('res://addons/Wol/core/constants.gd')

View file

@ -14,31 +14,34 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://addons/Wol/core/compiler/compiler.gd" "path": "res://addons/Wol/core/compiler/compiler.gd"
}, { }, {
"base": "Object",
"class": "Constants",
"language": "GDScript",
"path": "res://addons/Wol/core/constants.gd"
}, {
"base": "Object",
"class": "Program",
"language": "GDScript",
"path": "res://addons/Wol/core/program.gd"
}, {
"base": "Node", "base": "Node",
"class": "Wol", "class": "Wol",
"language": "GDScript", "language": "GDScript",
"path": "res://addons/Wol/Wol.gd" "path": "res://addons/Wol/Wol.gd"
}, {
"base": "Object",
"class": "WolProgram",
"language": "GDScript",
"path": "res://addons/Wol/core/program.gd"
} ] } ]
_global_script_class_icons={ _global_script_class_icons={
"Compiler": "", "Compiler": "",
"Wol": "", "Constants": "",
"WolProgram": "" "Program": "",
"Wol": ""
} }
[application] [application]
config/name="YarnSpinner" config/name="YarnSpinner"
run/main_scene="res://Dialogue.tscn"
config/icon="res://icon.png" config/icon="res://icon.png"
[autoload]
WolGlobals="*res://addons/Wol/core/constants.gd"
[editor_plugins] [editor_plugins]
enabled=PoolStringArray( "res://addons/Wol/plugin.cfg" ) enabled=PoolStringArray( "res://addons/Wol/plugin.cfg" )