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')
match statement.type:
Constants.StatementTypes.CustomCommand:
generate_custom_command(node,statement.customCommand)
generate_custom_command(node,statement.custom_command)
Constants.StatementTypes.ShortcutOptionGroup:
generate_shortcut_group(node,statement.shortcutOptionGroup)
generate_shortcut_group(node,statement.shortcut_option_group)
Constants.StatementTypes.Block:
generate_block(node,statement.block.statements)
Constants.StatementTypes.IfStatement:
generate_if(node,statement.ifStatement)
generate_if(node,statement.if_statement)
Constants.StatementTypes.OptionStatement:
generate_option(node,statement.optionStatement)
generate_option(node,statement.option_statement)
Constants.StatementTypes.AssignmentStatement:
generate_assignment(node,statement.assignment)
Constants.StatementTypes.Line:
@ -240,7 +240,7 @@ func generate_custom_command(node,command):
if command.expression != null:
generate_expression(node,command.expression)
else:
var commandString = command.clientCommand
var commandString = command.client_command
if commandString == 'stop':
emit(Constants.ByteCode.Stop,node)
else :
@ -313,23 +313,23 @@ func generate_block(node,statements:Array=[]):
#compile if branching instructions
func generate_if(node,ifStatement):
func generate_if(node,if_statement):
# print('generating if')
#jump to label @ end of every clause
var endif : String = register_label('endif')
for clause in ifStatement.clauses:
var endClause : String = register_label('skip_clause')
for clause in if_statement.clauses:
var end_clause : String = register_label('skip_clause')
if clause.expression!=null:
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)
emit(Constants.ByteCode.JumpTo,node,[Program.Operand.new(endif)])
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:
emit(Constants.ByteCode.Pop)
@ -451,7 +451,6 @@ func emit_error(error : int)->void:
_lastError = error
_errors |= _lastError
static func print_tokens(tokens:Array=[]):
var list : PoolStringArray = []
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
}
enum ExpressionType {
Value, FunctionCall
}
enum StatementTypes {
CustomCommand,
ShortcutOptionGroup,
@ -169,10 +167,7 @@ enum ValueType {
Nullean
}
func defaultValue(type):
pass
static func token_type_name(value:int)->String:
static func token_type_name(value):
for key in TokenType.keys():
if TokenType[key] == value:
return key
@ -182,14 +177,6 @@ static func merge_dir(target, patch):
for key in patch:
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):
return [
'Label',

View file

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

View file

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