changed some names from (Y|y)arn to (W|w)ol
This commit is contained in:
parent
7238986fa1
commit
aeb74a2d43
|
@ -10,10 +10,10 @@ signal node_completed(node)
|
||||||
signal running
|
signal running
|
||||||
signal finished
|
signal finished
|
||||||
|
|
||||||
const YarnCompiler = preload("res://addons/Wol/core/compiler/compiler.gd")
|
const WolCompiler = preload("res://addons/Wol/core/compiler/compiler.gd")
|
||||||
const YarnDialogue = preload("res://addons/Wol/core/dialogue.gd")
|
const WolDialogue = preload("res://addons/Wol/core/dialogue.gd")
|
||||||
|
|
||||||
export(String, FILE, "*.yarn") var path setget set_path
|
export(String, FILE, "*.wol") var path setget set_path
|
||||||
export(String) var start_node = "Start"
|
export(String) var start_node = "Start"
|
||||||
export(bool) var auto_start = false
|
export(bool) var auto_start = false
|
||||||
export(NodePath) var variable_storage_path
|
export(NodePath) var variable_storage_path
|
||||||
|
@ -44,7 +44,7 @@ func init_dialogue():
|
||||||
if dialogue != null:
|
if dialogue != null:
|
||||||
existing_state = dialogue._visitedNodeCount
|
existing_state = dialogue._visitedNodeCount
|
||||||
|
|
||||||
dialogue = YarnDialogue.new(variable_storage)
|
dialogue = WolDialogue.new(variable_storage)
|
||||||
|
|
||||||
# FIXME: Remove these lines
|
# FIXME: Remove these lines
|
||||||
if existing_state:
|
if existing_state:
|
||||||
|
@ -64,20 +64,20 @@ func set_path(_path):
|
||||||
file.open(_path, File.READ)
|
file.open(_path, File.READ)
|
||||||
var source = file.get_as_text()
|
var source = file.get_as_text()
|
||||||
file.close()
|
file.close()
|
||||||
program = YarnCompiler.compile_string(source, _path)
|
program = WolCompiler.compile_string(source, _path)
|
||||||
path = _path
|
path = _path
|
||||||
|
|
||||||
func _handle_line(line):
|
func _handle_line(line):
|
||||||
call_deferred('emit_signal', 'line', line)
|
call_deferred('emit_signal', 'line', line)
|
||||||
return YarnGlobals.HandlerState.PauseExecution
|
return WolGlobals.HandlerState.PauseExecution
|
||||||
|
|
||||||
func _handle_command(command):
|
func _handle_command(command):
|
||||||
call_deferred('emit_signal', 'command', command)
|
call_deferred('emit_signal', 'command', command)
|
||||||
return YarnGlobals.HandlerState.PauseExecution
|
return WolGlobals.HandlerState.PauseExecution
|
||||||
|
|
||||||
func _handle_options(options):
|
func _handle_options(options):
|
||||||
emit_signal('options', options)
|
emit_signal('options', options)
|
||||||
return YarnGlobals.HandlerState.PauseExecution
|
return WolGlobals.HandlerState.PauseExecution
|
||||||
|
|
||||||
func _handle_dialogue_complete():
|
func _handle_dialogue_complete():
|
||||||
emit_signal('finished')
|
emit_signal('finished')
|
||||||
|
@ -98,7 +98,7 @@ func _handle_node_start(node):
|
||||||
func _handle_node_complete(node):
|
func _handle_node_complete(node):
|
||||||
emit_signal('node_completed', node)
|
emit_signal('node_completed', node)
|
||||||
running = false
|
running = false
|
||||||
return YarnGlobals.HandlerState.ContinueExecution
|
return WolGlobals.HandlerState.ContinueExecution
|
||||||
|
|
||||||
func select_option(id):
|
func select_option(id):
|
||||||
dialogue.get_vm().set_selected_option(id)
|
dialogue.get_vm().set_selected_option(id)
|
|
@ -75,16 +75,16 @@ enum TokenType {
|
||||||
#7 '#'
|
#7 '#'
|
||||||
TagMarker,
|
TagMarker,
|
||||||
|
|
||||||
#8 Command syntax ("<<foo>>")
|
#8 Command syntax ('<<foo>>')
|
||||||
BeginCommand, EndCommand,
|
BeginCommand, EndCommand,
|
||||||
|
|
||||||
#10 Variables ("$foo")
|
#10 Variables ('$foo')
|
||||||
Variable,
|
Variable,
|
||||||
|
|
||||||
#11 Shortcut syntax ("->")
|
#11 Shortcut syntax ('->')
|
||||||
ShortcutOption,
|
ShortcutOption,
|
||||||
|
|
||||||
#12 Option syntax ("[[Let's go here|Destination]]")
|
#12 Option syntax ('[[Let's go here|Destination]]')
|
||||||
OptionStart, # [[
|
OptionStart, # [[
|
||||||
OptionDelimit, # |
|
OptionDelimit, # |
|
||||||
OptionEnd, # ]]
|
OptionEnd, # ]]
|
||||||
|
@ -152,7 +152,7 @@ enum ExpressionType{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum StatementTypes{
|
enum StatementTypes j{
|
||||||
CustomCommand,
|
CustomCommand,
|
||||||
ShortcutOptionGroup,
|
ShortcutOptionGroup,
|
||||||
Block,
|
Block,
|
||||||
|
@ -167,7 +167,7 @@ enum ValueType{
|
||||||
Str,
|
Str,
|
||||||
Boolean,
|
Boolean,
|
||||||
Variable,
|
Variable,
|
||||||
Nullean#null lel
|
Nullean
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultValue(type):
|
func defaultValue(type):
|
||||||
|
@ -177,16 +177,14 @@ 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
|
||||||
return "NOTVALID"
|
return 'NOTVALID'
|
||||||
|
|
||||||
static func merge_dir(target, patch):
|
static func merge_dir(target, patch):
|
||||||
for key in patch:
|
for key in patch:
|
||||||
target[key] = patch[key]
|
target[key] = patch[key]
|
||||||
|
|
||||||
|
|
||||||
#same as top one woops
|
|
||||||
func token_name(type)->String:
|
func token_name(type)->String:
|
||||||
var string : String = ""
|
var string : String = ''
|
||||||
|
|
||||||
for key in TokenType.keys():
|
for key in TokenType.keys():
|
||||||
if TokenType[key] == type:
|
if TokenType[key] == type:
|
||||||
|
@ -195,40 +193,40 @@ func token_name(type)->String:
|
||||||
|
|
||||||
func bytecode_name(bytecode):
|
func bytecode_name(bytecode):
|
||||||
return [
|
return [
|
||||||
"Label",
|
'Label',
|
||||||
"JumpTo",
|
'JumpTo',
|
||||||
"Jump",
|
'Jump',
|
||||||
"RunLine",
|
'RunLine',
|
||||||
"RunCommand",
|
'RunCommand',
|
||||||
"AddOption",
|
'AddOption',
|
||||||
"ShowOptions",
|
'ShowOptions',
|
||||||
"PushString",
|
'PushString',
|
||||||
"PushNumber",
|
'PushNumber',
|
||||||
"PushBool",
|
'PushBool',
|
||||||
"PushNull",
|
'PushNull',
|
||||||
"JumpIfFalse",
|
'JumpIfFalse',
|
||||||
"Pop",
|
'Pop',
|
||||||
"CallFunc",
|
'CallFunc',
|
||||||
"PushVariable",
|
'PushVariable',
|
||||||
"StoreVariable",
|
'StoreVariable',
|
||||||
"Stop",
|
'Stop',
|
||||||
"RunNode"
|
'RunNode'
|
||||||
][bytecode]
|
][bytecode]
|
||||||
|
|
||||||
#combine all the programs in the provided array
|
#combine all the programs in the provided array
|
||||||
static func combine_programs(programs : Array = []):
|
static func combine_programs(programs = []):
|
||||||
var YarnProgram = load("res://addons/Wol/core/program/program.gd")
|
var WolProgram = load('res://addons/Wol/core/program/program.gd')
|
||||||
if programs.size() == 0:
|
if programs.size() == 0:
|
||||||
printerr("no programs to combine - you failure")
|
printerr('no programs to combine - you failure')
|
||||||
return
|
return
|
||||||
var p = YarnProgram.new()
|
var p = WolProgram.new()
|
||||||
|
|
||||||
for program in programs:
|
for program in programs:
|
||||||
for nodeKey in program.yarnNodes.keys():
|
for nodeKey in program.wolNodes.keys():
|
||||||
if p.yarnNodes.has(nodeKey):
|
if p.wolNodes.has(nodeKey):
|
||||||
printerr("Program with duplicate node names %s "% nodeKey)
|
printerr('Program with duplicate node names %s '% nodeKey)
|
||||||
return
|
return
|
||||||
p.yarnNodes[nodeKey] = program.yarnNodes[nodeKey]
|
p.wolNodes[nodeKey] = program.wolNodes[nodeKey]
|
||||||
|
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
extends Object
|
extends Object
|
||||||
|
|
||||||
const Lexer = preload("res://addons/Wol/core/compiler/lexer.gd")
|
const Lexer = preload("res://addons/Wol/core/compiler/lexer.gd")
|
||||||
const LineInfo = preload("res://addons/Wol/core/program/yarn_line.gd")
|
const LineInfo = preload("res://addons/Wol/core/program/wol_line.gd")
|
||||||
const YarnNode = preload("res://addons/Wol/core/program/yarn_node.gd")
|
const WolNode = preload("res://addons/Wol/core/program/wol_node.gd")
|
||||||
const Instruction = preload("res://addons/Wol/core/program/instruction.gd")
|
const Instruction = preload("res://addons/Wol/core/program/instruction.gd")
|
||||||
const YarnProgram = preload("res://addons/Wol/core/program/program.gd")
|
const WolProgram = preload("res://addons/Wol/core/program/program.gd")
|
||||||
const Operand = preload("res://addons/Wol/core/program/operand.gd")
|
const Operand = preload("res://addons/Wol/core/program/operand.gd")
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ var _errors : int
|
||||||
var _lastError : int
|
var _lastError : int
|
||||||
|
|
||||||
#-----Class vars
|
#-----Class vars
|
||||||
var _currentNode : YarnNode
|
var _currentNode : WolNode
|
||||||
var _rawText : bool
|
var _rawText : bool
|
||||||
var _fileName : String
|
var _fileName : String
|
||||||
var _containsImplicitStringTags : bool
|
var _containsImplicitStringTags : bool
|
||||||
|
@ -32,10 +32,10 @@ var _labelCount : int = 0
|
||||||
#<String, LineInfo>
|
#<String, LineInfo>
|
||||||
var _stringTable : Dictionary = {}
|
var _stringTable : Dictionary = {}
|
||||||
var _stringCount : int = 0
|
var _stringCount : int = 0
|
||||||
#<int, YarnGlobals.TokenType>
|
#<int, WolGlobals.TokenType>
|
||||||
var _tokens : Dictionary = {}
|
var _tokens : Dictionary = {}
|
||||||
|
|
||||||
static func compile_string(source: String, filename: String) -> YarnProgram:
|
static func compile_string(source: String, filename: String) -> WolProgram:
|
||||||
var Parser = load("res://addons/Wol/core/compiler/parser.gd")
|
var Parser = load("res://addons/Wol/core/compiler/parser.gd")
|
||||||
var Compiler = load("res://addons/Wol/core/compiler/compiler.gd")
|
var Compiler = load("res://addons/Wol/core/compiler/compiler.gd")
|
||||||
|
|
||||||
|
@ -107,23 +107,23 @@ static func compile_string(source: String, filename: String) -> YarnProgram:
|
||||||
|
|
||||||
#--- End parsing nodes---
|
#--- End parsing nodes---
|
||||||
|
|
||||||
var program = YarnProgram.new()
|
var program = WolProgram.new()
|
||||||
|
|
||||||
#compile nodes
|
#compile nodes
|
||||||
for node in parsedNodes:
|
for node in parsedNodes:
|
||||||
compiler.compile_node(program, node)
|
compiler.compile_node(program, node)
|
||||||
|
|
||||||
for key in compiler._stringTable:
|
for key in compiler._stringTable:
|
||||||
program.yarnStrings[key] = compiler._stringTable[key]
|
program.wolStrings[key] = compiler._stringTable[key]
|
||||||
|
|
||||||
return program
|
return program
|
||||||
|
|
||||||
func compile_node(program:YarnProgram,parsedNode)->void:
|
func compile_node(program:WolProgram,parsedNode)->void:
|
||||||
if program.yarnNodes.has(parsedNode.name):
|
if program.wolNodes.has(parsedNode.name):
|
||||||
emit_error(DUPLICATE_NODES_IN_PROGRAM)
|
emit_error(DUPLICATE_NODES_IN_PROGRAM)
|
||||||
printerr("Duplicate node in program: %s" % parsedNode.name)
|
printerr("Duplicate node in program: %s" % parsedNode.name)
|
||||||
else:
|
else:
|
||||||
var nodeCompiled : YarnNode = YarnNode.new()
|
var nodeCompiled : WolNode = WolNode.new()
|
||||||
|
|
||||||
nodeCompiled.nodeName = parsedNode.name
|
nodeCompiled.nodeName = parsedNode.name
|
||||||
nodeCompiled.tags = parsedNode.tags
|
nodeCompiled.tags = parsedNode.tags
|
||||||
|
@ -135,7 +135,7 @@ func compile_node(program:YarnProgram,parsedNode)->void:
|
||||||
else:
|
else:
|
||||||
#compile node
|
#compile node
|
||||||
var startLabel : String = register_label()
|
var startLabel : String = register_label()
|
||||||
emit(YarnGlobals.ByteCode.Label,nodeCompiled,[Operand.new(startLabel)])
|
emit(WolGlobals.ByteCode.Label,nodeCompiled,[Operand.new(startLabel)])
|
||||||
|
|
||||||
for statement in parsedNode.statements:
|
for statement in parsedNode.statements:
|
||||||
generate_statement(nodeCompiled,statement)
|
generate_statement(nodeCompiled,statement)
|
||||||
|
@ -146,19 +146,19 @@ func compile_node(program:YarnProgram,parsedNode)->void:
|
||||||
|
|
||||||
var danglingOptions = false
|
var danglingOptions = false
|
||||||
for instruction in nodeCompiled.instructions :
|
for instruction in nodeCompiled.instructions :
|
||||||
if instruction.operation == YarnGlobals.ByteCode.AddOption:
|
if instruction.operation == WolGlobals.ByteCode.AddOption:
|
||||||
danglingOptions = true
|
danglingOptions = true
|
||||||
if instruction.operation == YarnGlobals.ByteCode.ShowOptions:
|
if instruction.operation == WolGlobals.ByteCode.ShowOptions:
|
||||||
danglingOptions = false
|
danglingOptions = false
|
||||||
|
|
||||||
if danglingOptions:
|
if danglingOptions:
|
||||||
emit(YarnGlobals.ByteCode.ShowOptions, nodeCompiled)
|
emit(WolGlobals.ByteCode.ShowOptions, nodeCompiled)
|
||||||
emit(YarnGlobals.ByteCode.RunNode, nodeCompiled)
|
emit(WolGlobals.ByteCode.RunNode, nodeCompiled)
|
||||||
else:
|
else:
|
||||||
emit(YarnGlobals.ByteCode.Stop, nodeCompiled)
|
emit(WolGlobals.ByteCode.Stop, nodeCompiled)
|
||||||
|
|
||||||
|
|
||||||
program.yarnNodes[nodeCompiled.nodeName] = nodeCompiled
|
program.wolNodes[nodeCompiled.nodeName] = nodeCompiled
|
||||||
|
|
||||||
func register_string(text:String,nodeName:String,id:String="",lineNumber:int=-1,tags:Array=[])->String:
|
func register_string(text:String,nodeName:String,id:String="",lineNumber:int=-1,tags:Array=[])->String:
|
||||||
var lineIdUsed : String
|
var lineIdUsed : String
|
||||||
|
@ -189,7 +189,7 @@ func register_label(comment:String="")->String:
|
||||||
_labelCount+=1
|
_labelCount+=1
|
||||||
return "L%s%s" %[ _labelCount , comment]
|
return "L%s%s" %[ _labelCount , comment]
|
||||||
|
|
||||||
func emit(bytecode,node:YarnNode=_currentNode,operands:Array=[]):
|
func emit(bytecode,node:WolNode=_currentNode,operands:Array=[]):
|
||||||
var instruction : Instruction = Instruction.new(null)
|
var instruction : Instruction = Instruction.new(null)
|
||||||
instruction.operation = bytecode
|
instruction.operation = bytecode
|
||||||
instruction.operands = operands
|
instruction.operands = operands
|
||||||
|
@ -199,7 +199,7 @@ func emit(bytecode,node:YarnNode=_currentNode,operands:Array=[]):
|
||||||
printerr("trying to emit to null node with byteCode: %s" % bytecode)
|
printerr("trying to emit to null node with byteCode: %s" % bytecode)
|
||||||
return;
|
return;
|
||||||
node.instructions.append(instruction)
|
node.instructions.append(instruction)
|
||||||
if bytecode == YarnGlobals.ByteCode.Label :
|
if bytecode == WolGlobals.ByteCode.Label :
|
||||||
#add to label table
|
#add to label table
|
||||||
node.labels[instruction.operands[0].value] = node.instructions.size()-1
|
node.labels[instruction.operands[0].value] = node.instructions.size()-1
|
||||||
|
|
||||||
|
@ -217,19 +217,19 @@ func generate_header():
|
||||||
func generate_statement(node,statement):
|
func generate_statement(node,statement):
|
||||||
# print("generating statement")
|
# print("generating statement")
|
||||||
match statement.type:
|
match statement.type:
|
||||||
YarnGlobals.StatementTypes.CustomCommand:
|
WolGlobals.StatementTypes.CustomCommand:
|
||||||
generate_custom_command(node,statement.customCommand)
|
generate_custom_command(node,statement.customCommand)
|
||||||
YarnGlobals.StatementTypes.ShortcutOptionGroup:
|
WolGlobals.StatementTypes.ShortcutOptionGroup:
|
||||||
generate_shortcut_group(node,statement.shortcutOptionGroup)
|
generate_shortcut_group(node,statement.shortcutOptionGroup)
|
||||||
YarnGlobals.StatementTypes.Block:
|
WolGlobals.StatementTypes.Block:
|
||||||
generate_block(node,statement.block.statements)
|
generate_block(node,statement.block.statements)
|
||||||
YarnGlobals.StatementTypes.IfStatement:
|
WolGlobals.StatementTypes.IfStatement:
|
||||||
generate_if(node,statement.ifStatement)
|
generate_if(node,statement.ifStatement)
|
||||||
YarnGlobals.StatementTypes.OptionStatement:
|
WolGlobals.StatementTypes.OptionStatement:
|
||||||
generate_option(node,statement.optionStatement)
|
generate_option(node,statement.optionStatement)
|
||||||
YarnGlobals.StatementTypes.AssignmentStatement:
|
WolGlobals.StatementTypes.AssignmentStatement:
|
||||||
generate_assignment(node,statement.assignment)
|
generate_assignment(node,statement.assignment)
|
||||||
YarnGlobals.StatementTypes.Line:
|
WolGlobals.StatementTypes.Line:
|
||||||
generate_line(node,statement,statement.line)
|
generate_line(node,statement,statement.line)
|
||||||
_:
|
_:
|
||||||
emit_error(ERR_COMPILATION_FAILED)
|
emit_error(ERR_COMPILATION_FAILED)
|
||||||
|
@ -244,15 +244,15 @@ func generate_custom_command(node,command):
|
||||||
else:
|
else:
|
||||||
var commandString = command.clientCommand
|
var commandString = command.clientCommand
|
||||||
if commandString == "stop":
|
if commandString == "stop":
|
||||||
emit(YarnGlobals.ByteCode.Stop,node)
|
emit(WolGlobals.ByteCode.Stop,node)
|
||||||
else :
|
else :
|
||||||
emit(YarnGlobals.ByteCode.RunCommand,node,[Operand.new(commandString)])
|
emit(WolGlobals.ByteCode.RunCommand,node,[Operand.new(commandString)])
|
||||||
|
|
||||||
#compile instructions for linetags and use them
|
#compile instructions for linetags and use them
|
||||||
# \#line:number
|
# \#line:number
|
||||||
func generate_line(node,statement,line:String):
|
func generate_line(node,statement,line:String):
|
||||||
var num : String = register_string(line,node.nodeName,"",statement.lineNumber,[]);
|
var num : String = register_string(line,node.nodeName,"",statement.lineNumber,[]);
|
||||||
emit(YarnGlobals.ByteCode.RunLine,node,[Operand.new(num)])
|
emit(WolGlobals.ByteCode.RunLine,node,[Operand.new(num)])
|
||||||
|
|
||||||
func generate_shortcut_group(node,shortcutGroup):
|
func generate_shortcut_group(node,shortcutGroup):
|
||||||
# print("generating shortcutoptopn group")
|
# print("generating shortcutoptopn group")
|
||||||
|
@ -271,37 +271,37 @@ func generate_shortcut_group(node,shortcutGroup):
|
||||||
if option.condition != null :
|
if option.condition != null :
|
||||||
endofClause = register_label("conditional_%s"%optionCount)
|
endofClause = register_label("conditional_%s"%optionCount)
|
||||||
generate_expression(node,option.condition)
|
generate_expression(node,option.condition)
|
||||||
emit(YarnGlobals.ByteCode.JumpIfFalse,node,[Operand.new(endofClause)])
|
emit(WolGlobals.ByteCode.JumpIfFalse,node,[Operand.new(endofClause)])
|
||||||
|
|
||||||
var labelLineId : String = ""#no tag TODO: ADD TAG SUPPORT
|
var labelLineId : String = ""#no tag TODO: ADD TAG SUPPORT
|
||||||
var labelStringId : String = register_string(option.label,node.nodeName,
|
var labelStringId : String = register_string(option.label,node.nodeName,
|
||||||
labelLineId,option.lineNumber,[])
|
labelLineId,option.lineNumber,[])
|
||||||
|
|
||||||
emit(YarnGlobals.ByteCode.AddOption,node,[Operand.new(labelStringId),Operand.new(opDestination)])
|
emit(WolGlobals.ByteCode.AddOption,node,[Operand.new(labelStringId),Operand.new(opDestination)])
|
||||||
|
|
||||||
if option.condition != null :
|
if option.condition != null :
|
||||||
emit(YarnGlobals.ByteCode.Label,node,[Operand.new(endofClause)])
|
emit(WolGlobals.ByteCode.Label,node,[Operand.new(endofClause)])
|
||||||
emit(YarnGlobals.ByteCode.Pop,node)
|
emit(WolGlobals.ByteCode.Pop,node)
|
||||||
|
|
||||||
optionCount+=1
|
optionCount+=1
|
||||||
|
|
||||||
emit(YarnGlobals.ByteCode.ShowOptions,node)
|
emit(WolGlobals.ByteCode.ShowOptions,node)
|
||||||
emit(YarnGlobals.ByteCode.Jump,node)
|
emit(WolGlobals.ByteCode.Jump,node)
|
||||||
|
|
||||||
optionCount = 0
|
optionCount = 0
|
||||||
|
|
||||||
for option in shortcutGroup.options:
|
for option in shortcutGroup.options:
|
||||||
emit(YarnGlobals.ByteCode.Label,node,[Operand.new(labels[optionCount])])
|
emit(WolGlobals.ByteCode.Label,node,[Operand.new(labels[optionCount])])
|
||||||
|
|
||||||
if option.node != null :
|
if option.node != null :
|
||||||
generate_block(node,option.node.statements)
|
generate_block(node,option.node.statements)
|
||||||
emit(YarnGlobals.ByteCode.JumpTo,node,[Operand.new(end)])
|
emit(WolGlobals.ByteCode.JumpTo,node,[Operand.new(end)])
|
||||||
optionCount+=1
|
optionCount+=1
|
||||||
|
|
||||||
#end of option group
|
#end of option group
|
||||||
emit(YarnGlobals.ByteCode.Label,node,[Operand.new(end)])
|
emit(WolGlobals.ByteCode.Label,node,[Operand.new(end)])
|
||||||
#clean up
|
#clean up
|
||||||
emit(YarnGlobals.ByteCode.Pop,node)
|
emit(WolGlobals.ByteCode.Pop,node)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -325,19 +325,19 @@ func generate_if(node,ifStatement):
|
||||||
|
|
||||||
if clause.expression!=null:
|
if clause.expression!=null:
|
||||||
generate_expression(node,clause.expression)
|
generate_expression(node,clause.expression)
|
||||||
emit(YarnGlobals.ByteCode.JumpIfFalse,node,[Operand.new(endClause)])
|
emit(WolGlobals.ByteCode.JumpIfFalse,node,[Operand.new(endClause)])
|
||||||
|
|
||||||
generate_block(node,clause.statements)
|
generate_block(node,clause.statements)
|
||||||
emit(YarnGlobals.ByteCode.JumpTo,node,[Operand.new(endif)])
|
emit(WolGlobals.ByteCode.JumpTo,node,[Operand.new(endif)])
|
||||||
|
|
||||||
if clause.expression!=null:
|
if clause.expression!=null:
|
||||||
emit(YarnGlobals.ByteCode.Label,node,[Operand.new(endClause)])
|
emit(WolGlobals.ByteCode.Label,node,[Operand.new(endClause)])
|
||||||
|
|
||||||
if clause.expression!=null:
|
if clause.expression!=null:
|
||||||
emit(YarnGlobals.ByteCode.Pop)
|
emit(WolGlobals.ByteCode.Pop)
|
||||||
|
|
||||||
|
|
||||||
emit(YarnGlobals.ByteCode.Label,node,[Operand.new(endif)])
|
emit(WolGlobals.ByteCode.Label,node,[Operand.new(endif)])
|
||||||
|
|
||||||
|
|
||||||
#compile instructions for options
|
#compile instructions for options
|
||||||
|
@ -347,25 +347,25 @@ func generate_option(node,option):
|
||||||
|
|
||||||
if option.label == null || option.label.empty():
|
if option.label == null || option.label.empty():
|
||||||
#jump to another node
|
#jump to another node
|
||||||
emit(YarnGlobals.ByteCode.RunNode,node,[Operand.new(destination)])
|
emit(WolGlobals.ByteCode.RunNode,node,[Operand.new(destination)])
|
||||||
else :
|
else :
|
||||||
var lineID : String = ""#tags not supported TODO: ADD TAG SUPPORT
|
var lineID : String = ""#tags not supported TODO: ADD TAG SUPPORT
|
||||||
var stringID = register_string(option.label,node.nodeName,lineID,option.lineNumber,[])
|
var stringID = register_string(option.label,node.nodeName,lineID,option.lineNumber,[])
|
||||||
|
|
||||||
emit(YarnGlobals.ByteCode.AddOption,node,[Operand.new(stringID),Operand.new(destination)])
|
emit(WolGlobals.ByteCode.AddOption,node,[Operand.new(stringID),Operand.new(destination)])
|
||||||
|
|
||||||
|
|
||||||
#compile instructions for assigning values
|
#compile instructions for assigning values
|
||||||
func generate_assignment(node,assignment):
|
func generate_assignment(node,assignment):
|
||||||
# print("generating assign")
|
# print("generating assign")
|
||||||
#assignment
|
#assignment
|
||||||
if assignment.operation == YarnGlobals.TokenType.EqualToOrAssign:
|
if assignment.operation == WolGlobals.TokenType.EqualToOrAssign:
|
||||||
#evaluate the expression to a value for the stack
|
#evaluate the expression to a value for the stack
|
||||||
generate_expression(node,assignment.value)
|
generate_expression(node,assignment.value)
|
||||||
else :
|
else :
|
||||||
#this is combined op
|
#this is combined op
|
||||||
#get value of var
|
#get value of var
|
||||||
emit(YarnGlobals.ByteCode.PushVariable,node,[assignment.destination])
|
emit(WolGlobals.ByteCode.PushVariable,node,[assignment.destination])
|
||||||
|
|
||||||
#evaluate the expression and push value to stack
|
#evaluate the expression and push value to stack
|
||||||
generate_expression(node,assignment.value)
|
generate_expression(node,assignment.value)
|
||||||
|
@ -373,27 +373,27 @@ func generate_assignment(node,assignment):
|
||||||
#stack contains oldvalue and result
|
#stack contains oldvalue and result
|
||||||
|
|
||||||
match assignment.operation:
|
match assignment.operation:
|
||||||
YarnGlobals.TokenType.AddAssign:
|
WolGlobals.TokenType.AddAssign:
|
||||||
emit(YarnGlobals.ByteCode.CallFunc,node,
|
emit(WolGlobals.ByteCode.CallFunc,node,
|
||||||
[Operand.new(YarnGlobals.token_type_name(YarnGlobals.TokenType.Add))])
|
[Operand.new(WolGlobals.token_type_name(WolGlobals.TokenType.Add))])
|
||||||
YarnGlobals.TokenType.MinusAssign:
|
WolGlobals.TokenType.MinusAssign:
|
||||||
emit(YarnGlobals.ByteCode.CallFunc,node,
|
emit(WolGlobals.ByteCode.CallFunc,node,
|
||||||
[Operand.new(YarnGlobals.token_type_name(YarnGlobals.TokenType.Minus))])
|
[Operand.new(WolGlobals.token_type_name(WolGlobals.TokenType.Minus))])
|
||||||
YarnGlobals.TokenType.MultiplyAssign:
|
WolGlobals.TokenType.MultiplyAssign:
|
||||||
emit(YarnGlobals.ByteCode.CallFunc,node,
|
emit(WolGlobals.ByteCode.CallFunc,node,
|
||||||
[Operand.new(YarnGlobals.token_type_name(YarnGlobals.TokenType.MultiplyAssign))])
|
[Operand.new(WolGlobals.token_type_name(WolGlobals.TokenType.MultiplyAssign))])
|
||||||
YarnGlobals.TokenType.DivideAssign:
|
WolGlobals.TokenType.DivideAssign:
|
||||||
emit(YarnGlobals.ByteCode.CallFunc,node,
|
emit(WolGlobals.ByteCode.CallFunc,node,
|
||||||
[Operand.new(YarnGlobals.token_type_name(YarnGlobals.TokenType.DivideAssign))])
|
[Operand.new(WolGlobals.token_type_name(WolGlobals.TokenType.DivideAssign))])
|
||||||
_:
|
_:
|
||||||
printerr("Unable to generate assignment")
|
printerr("Unable to generate assignment")
|
||||||
|
|
||||||
#stack contains destination value
|
#stack contains destination value
|
||||||
#store the top of the stack in variable
|
#store the top of the stack in variable
|
||||||
emit(YarnGlobals.ByteCode.StoreVariable,node,[Operand.new(assignment.destination)])
|
emit(WolGlobals.ByteCode.StoreVariable,node,[Operand.new(assignment.destination)])
|
||||||
|
|
||||||
#clean stack
|
#clean stack
|
||||||
emit(YarnGlobals.ByteCode.Pop,node)
|
emit(WolGlobals.ByteCode.Pop,node)
|
||||||
|
|
||||||
|
|
||||||
#compile expression instructions
|
#compile expression instructions
|
||||||
|
@ -401,18 +401,18 @@ func generate_expression(node,expression):
|
||||||
# print("generating expression")
|
# print("generating expression")
|
||||||
#expression = value || func call
|
#expression = value || func call
|
||||||
match expression.type:
|
match expression.type:
|
||||||
YarnGlobals.ExpressionType.Value:
|
WolGlobals.ExpressionType.Value:
|
||||||
generate_value(node,expression.value)
|
generate_value(node,expression.value)
|
||||||
YarnGlobals.ExpressionType.FunctionCall:
|
WolGlobals.ExpressionType.FunctionCall:
|
||||||
#eval all parameters
|
#eval all parameters
|
||||||
for param in expression.params:
|
for param in expression.params:
|
||||||
generate_expression(node,param)
|
generate_expression(node,param)
|
||||||
|
|
||||||
#put the num of of params to stack
|
#put the num of of params to stack
|
||||||
emit(YarnGlobals.ByteCode.PushNumber,node,[Operand.new(expression.params.size())])
|
emit(WolGlobals.ByteCode.PushNumber,node,[Operand.new(expression.params.size())])
|
||||||
|
|
||||||
#call function
|
#call function
|
||||||
emit(YarnGlobals.ByteCode.CallFunc,node,[Operand.new(expression.function)])
|
emit(WolGlobals.ByteCode.CallFunc,node,[Operand.new(expression.function)])
|
||||||
_:
|
_:
|
||||||
printerr("no expression")
|
printerr("no expression")
|
||||||
|
|
||||||
|
@ -421,18 +421,18 @@ func generate_value(node,value):
|
||||||
# print("generating value")
|
# print("generating value")
|
||||||
#push value to stack
|
#push value to stack
|
||||||
match value.value.type:
|
match value.value.type:
|
||||||
YarnGlobals.ValueType.Number:
|
WolGlobals.ValueType.Number:
|
||||||
emit(YarnGlobals.ByteCode.PushNumber,node,[Operand.new(value.value.as_number())])
|
emit(WolGlobals.ByteCode.PushNumber,node,[Operand.new(value.value.as_number())])
|
||||||
YarnGlobals.ValueType.Str:
|
WolGlobals.ValueType.Str:
|
||||||
var id : String = register_string(value.value.as_string(),
|
var id : String = register_string(value.value.as_string(),
|
||||||
node.nodeName,"",value.lineNumber,[])
|
node.nodeName,"",value.lineNumber,[])
|
||||||
emit(YarnGlobals.ByteCode.PushString,node,[Operand.new(id)])
|
emit(WolGlobals.ByteCode.PushString,node,[Operand.new(id)])
|
||||||
YarnGlobals.ValueType.Boolean:
|
WolGlobals.ValueType.Boolean:
|
||||||
emit(YarnGlobals.ByteCode.PushBool,node,[Operand.new(value.value.as_bool())])
|
emit(WolGlobals.ByteCode.PushBool,node,[Operand.new(value.value.as_bool())])
|
||||||
YarnGlobals.ValueType.Variable:
|
WolGlobals.ValueType.Variable:
|
||||||
emit(YarnGlobals.ByteCode.PushVariable,node,[Operand.new(value.value.variable)])
|
emit(WolGlobals.ByteCode.PushVariable,node,[Operand.new(value.value.variable)])
|
||||||
YarnGlobals.ValueType.Nullean:
|
WolGlobals.ValueType.Nullean:
|
||||||
emit(YarnGlobals.ByteCode.PushNull,node)
|
emit(WolGlobals.ByteCode.PushNull,node)
|
||||||
_:
|
_:
|
||||||
printerr("Unrecognized valuenode type: %s" % value.value.type)
|
printerr("Unrecognized valuenode type: %s" % value.value.type)
|
||||||
|
|
||||||
|
@ -458,6 +458,6 @@ static func print_tokens(tokens:Array=[]):
|
||||||
var list : PoolStringArray = []
|
var list : PoolStringArray = []
|
||||||
list.append("\n")
|
list.append("\n")
|
||||||
for token in tokens:
|
for token in tokens:
|
||||||
list.append("%s (%s line %s)\n"%[YarnGlobals.token_type_name(token.type),token.value,token.lineNumber])
|
list.append("%s (%s line %s)\n"%[WolGlobals.token_type_name(token.type),token.value,token.lineNumber])
|
||||||
print("TOKENS:")
|
print("TOKENS:")
|
||||||
print(list.join(""))
|
print(list.join(""))
|
||||||
|
|
|
@ -33,50 +33,50 @@ func _init():
|
||||||
|
|
||||||
func create_states():
|
func create_states():
|
||||||
var patterns : Dictionary = {}
|
var patterns : Dictionary = {}
|
||||||
patterns[YarnGlobals.TokenType.Text] = ".*"
|
patterns[WolGlobals.TokenType.Text] = ".*"
|
||||||
|
|
||||||
patterns[YarnGlobals.TokenType.Number] = "\\-?[0-9]+(\\.[0-9+])?"
|
patterns[WolGlobals.TokenType.Number] = "\\-?[0-9]+(\\.[0-9+])?"
|
||||||
patterns[YarnGlobals.TokenType.Str] = "\"([^\"\\\\]*(?:\\.[^\"\\\\]*)*)\""
|
patterns[WolGlobals.TokenType.Str] = "\"([^\"\\\\]*(?:\\.[^\"\\\\]*)*)\""
|
||||||
patterns[YarnGlobals.TokenType.TagMarker] = "\\#"
|
patterns[WolGlobals.TokenType.TagMarker] = "\\#"
|
||||||
patterns[YarnGlobals.TokenType.LeftParen] = "\\("
|
patterns[WolGlobals.TokenType.LeftParen] = "\\("
|
||||||
patterns[YarnGlobals.TokenType.RightParen] = "\\)"
|
patterns[WolGlobals.TokenType.RightParen] = "\\)"
|
||||||
patterns[YarnGlobals.TokenType.EqualTo] = "(==|is(?!\\w)|eq(?!\\w))"
|
patterns[WolGlobals.TokenType.EqualTo] = "(==|is(?!\\w)|eq(?!\\w))"
|
||||||
patterns[YarnGlobals.TokenType.EqualToOrAssign] = "(=|to(?!\\w))"
|
patterns[WolGlobals.TokenType.EqualToOrAssign] = "(=|to(?!\\w))"
|
||||||
patterns[YarnGlobals.TokenType.NotEqualTo] = "(\\!=|neq(?!\\w))"
|
patterns[WolGlobals.TokenType.NotEqualTo] = "(\\!=|neq(?!\\w))"
|
||||||
patterns[YarnGlobals.TokenType.GreaterThanOrEqualTo] = "(\\>=|gte(?!\\w))"
|
patterns[WolGlobals.TokenType.GreaterThanOrEqualTo] = "(\\>=|gte(?!\\w))"
|
||||||
patterns[YarnGlobals.TokenType.GreaterThan] = "(\\>|gt(?!\\w))"
|
patterns[WolGlobals.TokenType.GreaterThan] = "(\\>|gt(?!\\w))"
|
||||||
patterns[YarnGlobals.TokenType.LessThanOrEqualTo] = "(\\<=|lte(?!\\w))"
|
patterns[WolGlobals.TokenType.LessThanOrEqualTo] = "(\\<=|lte(?!\\w))"
|
||||||
patterns[YarnGlobals.TokenType.LessThan] = "(\\<|lt(?!\\w))"
|
patterns[WolGlobals.TokenType.LessThan] = "(\\<|lt(?!\\w))"
|
||||||
patterns[YarnGlobals.TokenType.AddAssign] = "\\+="
|
patterns[WolGlobals.TokenType.AddAssign] = "\\+="
|
||||||
patterns[YarnGlobals.TokenType.MinusAssign] = "\\-="
|
patterns[WolGlobals.TokenType.MinusAssign] = "\\-="
|
||||||
patterns[YarnGlobals.TokenType.MultiplyAssign] = "\\*="
|
patterns[WolGlobals.TokenType.MultiplyAssign] = "\\*="
|
||||||
patterns[YarnGlobals.TokenType.DivideAssign] = "\\/="
|
patterns[WolGlobals.TokenType.DivideAssign] = "\\/="
|
||||||
patterns[YarnGlobals.TokenType.Add] = "\\+"
|
patterns[WolGlobals.TokenType.Add] = "\\+"
|
||||||
patterns[YarnGlobals.TokenType.Minus] = "\\-"
|
patterns[WolGlobals.TokenType.Minus] = "\\-"
|
||||||
patterns[YarnGlobals.TokenType.Multiply] = "\\*"
|
patterns[WolGlobals.TokenType.Multiply] = "\\*"
|
||||||
patterns[YarnGlobals.TokenType.Divide] = "\\/"
|
patterns[WolGlobals.TokenType.Divide] = "\\/"
|
||||||
patterns[YarnGlobals.TokenType.Modulo] = "\\%"
|
patterns[WolGlobals.TokenType.Modulo] = "\\%"
|
||||||
patterns[YarnGlobals.TokenType.And] = "(\\&\\&|and(?!\\w))"
|
patterns[WolGlobals.TokenType.And] = "(\\&\\&|and(?!\\w))"
|
||||||
patterns[YarnGlobals.TokenType.Or] = "(\\|\\||or(?!\\w))"
|
patterns[WolGlobals.TokenType.Or] = "(\\|\\||or(?!\\w))"
|
||||||
patterns[YarnGlobals.TokenType.Xor] = "(\\^|xor(?!\\w))"
|
patterns[WolGlobals.TokenType.Xor] = "(\\^|xor(?!\\w))"
|
||||||
patterns[YarnGlobals.TokenType.Not] = "(\\!|not(?!\\w))"
|
patterns[WolGlobals.TokenType.Not] = "(\\!|not(?!\\w))"
|
||||||
patterns[YarnGlobals.TokenType.Variable] = "\\$([A-Za-z0-9_\\.])+"
|
patterns[WolGlobals.TokenType.Variable] = "\\$([A-Za-z0-9_\\.])+"
|
||||||
patterns[YarnGlobals.TokenType.Comma] = "\\,"
|
patterns[WolGlobals.TokenType.Comma] = "\\,"
|
||||||
patterns[YarnGlobals.TokenType.TrueToken] = "true(?!\\w)"
|
patterns[WolGlobals.TokenType.TrueToken] = "true(?!\\w)"
|
||||||
patterns[YarnGlobals.TokenType.FalseToken] = "false(?!\\w)"
|
patterns[WolGlobals.TokenType.FalseToken] = "false(?!\\w)"
|
||||||
patterns[YarnGlobals.TokenType.NullToken] = "null(?!\\w)"
|
patterns[WolGlobals.TokenType.NullToken] = "null(?!\\w)"
|
||||||
patterns[YarnGlobals.TokenType.BeginCommand] = "\\<\\<"
|
patterns[WolGlobals.TokenType.BeginCommand] = "\\<\\<"
|
||||||
patterns[YarnGlobals.TokenType.EndCommand] = "\\>\\>"
|
patterns[WolGlobals.TokenType.EndCommand] = "\\>\\>"
|
||||||
patterns[YarnGlobals.TokenType.OptionStart] = "\\[\\["
|
patterns[WolGlobals.TokenType.OptionStart] = "\\[\\["
|
||||||
patterns[YarnGlobals.TokenType.OptionEnd] = "\\]\\]"
|
patterns[WolGlobals.TokenType.OptionEnd] = "\\]\\]"
|
||||||
patterns[YarnGlobals.TokenType.OptionDelimit] = "\\|"
|
patterns[WolGlobals.TokenType.OptionDelimit] = "\\|"
|
||||||
patterns[YarnGlobals.TokenType.Identifier] = "[a-zA-Z0-9_:\\.]+"
|
patterns[WolGlobals.TokenType.Identifier] = "[a-zA-Z0-9_:\\.]+"
|
||||||
patterns[YarnGlobals.TokenType.IfToken] = "if(?!\\w)"
|
patterns[WolGlobals.TokenType.IfToken] = "if(?!\\w)"
|
||||||
patterns[YarnGlobals.TokenType.ElseToken] = "else(?!\\w)"
|
patterns[WolGlobals.TokenType.ElseToken] = "else(?!\\w)"
|
||||||
patterns[YarnGlobals.TokenType.ElseIf] = "elseif(?!\\w)"
|
patterns[WolGlobals.TokenType.ElseIf] = "elseif(?!\\w)"
|
||||||
patterns[YarnGlobals.TokenType.EndIf] = "endif(?!\\w)"
|
patterns[WolGlobals.TokenType.EndIf] = "endif(?!\\w)"
|
||||||
patterns[YarnGlobals.TokenType.Set] = "set(?!\\w)"
|
patterns[WolGlobals.TokenType.Set] = "set(?!\\w)"
|
||||||
patterns[YarnGlobals.TokenType.ShortcutOption] = "\\-\\>\\s*"
|
patterns[WolGlobals.TokenType.ShortcutOption] = "\\-\\>\\s*"
|
||||||
|
|
||||||
#compound states
|
#compound states
|
||||||
var shortcut_option : String= SHORTCUT + DASH + OPTION
|
var shortcut_option : String= SHORTCUT + DASH + OPTION
|
||||||
|
@ -87,84 +87,84 @@ func create_states():
|
||||||
_states = {}
|
_states = {}
|
||||||
|
|
||||||
_states[BASE] = LexerState.new(patterns)
|
_states[BASE] = LexerState.new(patterns)
|
||||||
_states[BASE].add_transition(YarnGlobals.TokenType.BeginCommand,COMMAND,true)
|
_states[BASE].add_transition(WolGlobals.TokenType.BeginCommand,COMMAND,true)
|
||||||
_states[BASE].add_transition(YarnGlobals.TokenType.OptionStart,LINK,true)
|
_states[BASE].add_transition(WolGlobals.TokenType.OptionStart,LINK,true)
|
||||||
_states[BASE].add_transition(YarnGlobals.TokenType.ShortcutOption,shortcut_option)
|
_states[BASE].add_transition(WolGlobals.TokenType.ShortcutOption,shortcut_option)
|
||||||
_states[BASE].add_transition(YarnGlobals.TokenType.TagMarker,TAG,true)
|
_states[BASE].add_transition(WolGlobals.TokenType.TagMarker,TAG,true)
|
||||||
_states[BASE].add_text_rule(YarnGlobals.TokenType.Text)
|
_states[BASE].add_text_rule(WolGlobals.TokenType.Text)
|
||||||
|
|
||||||
_states[TAG] = LexerState.new(patterns)
|
_states[TAG] = LexerState.new(patterns)
|
||||||
_states[TAG].add_transition(YarnGlobals.TokenType.Identifier,BASE)
|
_states[TAG].add_transition(WolGlobals.TokenType.Identifier,BASE)
|
||||||
|
|
||||||
_states[shortcut_option] = LexerState.new(patterns)
|
_states[shortcut_option] = LexerState.new(patterns)
|
||||||
_states[shortcut_option].track_indent = true
|
_states[shortcut_option].track_indent = true
|
||||||
_states[shortcut_option].add_transition(YarnGlobals.TokenType.BeginCommand,EXPRESSION,true)
|
_states[shortcut_option].add_transition(WolGlobals.TokenType.BeginCommand,EXPRESSION,true)
|
||||||
_states[shortcut_option].add_transition(YarnGlobals.TokenType.TagMarker,shortcut_option_tag,true)
|
_states[shortcut_option].add_transition(WolGlobals.TokenType.TagMarker,shortcut_option_tag,true)
|
||||||
_states[shortcut_option].add_text_rule(YarnGlobals.TokenType.Text,BASE)
|
_states[shortcut_option].add_text_rule(WolGlobals.TokenType.Text,BASE)
|
||||||
|
|
||||||
_states[shortcut_option_tag] = LexerState.new(patterns)
|
_states[shortcut_option_tag] = LexerState.new(patterns)
|
||||||
_states[shortcut_option_tag].add_transition(YarnGlobals.TokenType.Identifier,shortcut_option)
|
_states[shortcut_option_tag].add_transition(WolGlobals.TokenType.Identifier,shortcut_option)
|
||||||
|
|
||||||
_states[COMMAND] = LexerState.new(patterns)
|
_states[COMMAND] = LexerState.new(patterns)
|
||||||
_states[COMMAND].add_transition(YarnGlobals.TokenType.IfToken,EXPRESSION)
|
_states[COMMAND].add_transition(WolGlobals.TokenType.IfToken,EXPRESSION)
|
||||||
_states[COMMAND].add_transition(YarnGlobals.TokenType.ElseToken)
|
_states[COMMAND].add_transition(WolGlobals.TokenType.ElseToken)
|
||||||
_states[COMMAND].add_transition(YarnGlobals.TokenType.ElseIf,EXPRESSION)
|
_states[COMMAND].add_transition(WolGlobals.TokenType.ElseIf,EXPRESSION)
|
||||||
_states[COMMAND].add_transition(YarnGlobals.TokenType.EndIf)
|
_states[COMMAND].add_transition(WolGlobals.TokenType.EndIf)
|
||||||
_states[COMMAND].add_transition(YarnGlobals.TokenType.Set,ASSIGNMENT)
|
_states[COMMAND].add_transition(WolGlobals.TokenType.Set,ASSIGNMENT)
|
||||||
_states[COMMAND].add_transition(YarnGlobals.TokenType.EndCommand,BASE,true)
|
_states[COMMAND].add_transition(WolGlobals.TokenType.EndCommand,BASE,true)
|
||||||
_states[COMMAND].add_transition(YarnGlobals.TokenType.Identifier,command_or_expression)
|
_states[COMMAND].add_transition(WolGlobals.TokenType.Identifier,command_or_expression)
|
||||||
_states[COMMAND].add_text_rule(YarnGlobals.TokenType.Text)
|
_states[COMMAND].add_text_rule(WolGlobals.TokenType.Text)
|
||||||
|
|
||||||
_states[command_or_expression] = LexerState.new(patterns)
|
_states[command_or_expression] = LexerState.new(patterns)
|
||||||
_states[command_or_expression].add_transition(YarnGlobals.TokenType.LeftParen,EXPRESSION)
|
_states[command_or_expression].add_transition(WolGlobals.TokenType.LeftParen,EXPRESSION)
|
||||||
_states[command_or_expression].add_transition(YarnGlobals.TokenType.EndCommand,BASE,true)
|
_states[command_or_expression].add_transition(WolGlobals.TokenType.EndCommand,BASE,true)
|
||||||
_states[command_or_expression].add_text_rule(YarnGlobals.TokenType.Text)
|
_states[command_or_expression].add_text_rule(WolGlobals.TokenType.Text)
|
||||||
|
|
||||||
_states[ASSIGNMENT] = LexerState.new(patterns)
|
_states[ASSIGNMENT] = LexerState.new(patterns)
|
||||||
_states[ASSIGNMENT].add_transition(YarnGlobals.TokenType.Variable)
|
_states[ASSIGNMENT].add_transition(WolGlobals.TokenType.Variable)
|
||||||
_states[ASSIGNMENT].add_transition(YarnGlobals.TokenType.EqualToOrAssign, EXPRESSION)
|
_states[ASSIGNMENT].add_transition(WolGlobals.TokenType.EqualToOrAssign, EXPRESSION)
|
||||||
_states[ASSIGNMENT].add_transition(YarnGlobals.TokenType.AddAssign, EXPRESSION)
|
_states[ASSIGNMENT].add_transition(WolGlobals.TokenType.AddAssign, EXPRESSION)
|
||||||
_states[ASSIGNMENT].add_transition(YarnGlobals.TokenType.MinusAssign, EXPRESSION)
|
_states[ASSIGNMENT].add_transition(WolGlobals.TokenType.MinusAssign, EXPRESSION)
|
||||||
_states[ASSIGNMENT].add_transition(YarnGlobals.TokenType.MultiplyAssign, EXPRESSION)
|
_states[ASSIGNMENT].add_transition(WolGlobals.TokenType.MultiplyAssign, EXPRESSION)
|
||||||
_states[ASSIGNMENT].add_transition(YarnGlobals.TokenType.DivideAssign, EXPRESSION)
|
_states[ASSIGNMENT].add_transition(WolGlobals.TokenType.DivideAssign, EXPRESSION)
|
||||||
|
|
||||||
_states[EXPRESSION] = LexerState.new(patterns)
|
_states[EXPRESSION] = LexerState.new(patterns)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.EndCommand, BASE)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.EndCommand, BASE)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.Number)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.Number)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.Str)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.Str)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.LeftParen)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.LeftParen)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.RightParen)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.RightParen)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.EqualTo)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.EqualTo)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.EqualToOrAssign)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.EqualToOrAssign)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.NotEqualTo)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.NotEqualTo)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.GreaterThanOrEqualTo)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.GreaterThanOrEqualTo)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.GreaterThan)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.GreaterThan)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.LessThanOrEqualTo)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.LessThanOrEqualTo)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.LessThan)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.LessThan)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.Add)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.Add)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.Minus)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.Minus)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.Multiply)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.Multiply)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.Divide)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.Divide)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.Modulo)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.Modulo)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.And)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.And)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.Or)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.Or)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.Xor)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.Xor)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.Not)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.Not)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.Variable)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.Variable)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.Comma)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.Comma)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.TrueToken)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.TrueToken)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.FalseToken)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.FalseToken)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.NullToken)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.NullToken)
|
||||||
_states[EXPRESSION].add_transition(YarnGlobals.TokenType.Identifier)
|
_states[EXPRESSION].add_transition(WolGlobals.TokenType.Identifier)
|
||||||
|
|
||||||
_states[LINK] = LexerState.new(patterns)
|
_states[LINK] = LexerState.new(patterns)
|
||||||
_states[LINK].add_transition(YarnGlobals.TokenType.OptionEnd, BASE, true)
|
_states[LINK].add_transition(WolGlobals.TokenType.OptionEnd, BASE, true)
|
||||||
_states[LINK].add_transition(YarnGlobals.TokenType.OptionDelimit, link_destination, true)
|
_states[LINK].add_transition(WolGlobals.TokenType.OptionDelimit, link_destination, true)
|
||||||
_states[LINK].add_text_rule(YarnGlobals.TokenType.Text)
|
_states[LINK].add_text_rule(WolGlobals.TokenType.Text)
|
||||||
|
|
||||||
_states[link_destination] = LexerState.new(patterns)
|
_states[link_destination] = LexerState.new(patterns)
|
||||||
_states[link_destination].add_transition(YarnGlobals.TokenType.Identifier)
|
_states[link_destination].add_transition(WolGlobals.TokenType.Identifier)
|
||||||
_states[link_destination].add_transition(YarnGlobals.TokenType.OptionEnd, BASE)
|
_states[link_destination].add_transition(WolGlobals.TokenType.OptionEnd, BASE)
|
||||||
|
|
||||||
_defaultState = _states[BASE]
|
_defaultState = _states[BASE]
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ func tokenize(text:String)->Array:
|
||||||
tokens+=tokenize_line(line,lineNumber)
|
tokens+=tokenize_line(line,lineNumber)
|
||||||
lineNumber+=1
|
lineNumber+=1
|
||||||
|
|
||||||
var endOfInput : Token = Token.new(YarnGlobals.TokenType.EndOfInput,_currentState,lineNumber,0)
|
var endOfInput : Token = Token.new(WolGlobals.TokenType.EndOfInput,_currentState,lineNumber,0)
|
||||||
tokens.append(endOfInput)
|
tokens.append(endOfInput)
|
||||||
|
|
||||||
# print(tokens)
|
# print(tokens)
|
||||||
|
@ -212,7 +212,7 @@ func tokenize_line(line:String, lineNumber : int)->Array:
|
||||||
#we add an indenation token to record indent level
|
#we add an indenation token to record indent level
|
||||||
_indentStack.push_front(IntBoolPair.new(indentation,true))
|
_indentStack.push_front(IntBoolPair.new(indentation,true))
|
||||||
|
|
||||||
var indent : Token = Token.new(YarnGlobals.TokenType.Indent,_currentState,lineNumber,prevIndentation.key)
|
var indent : Token = Token.new(WolGlobals.TokenType.Indent,_currentState,lineNumber,prevIndentation.key)
|
||||||
indent.value = "%*s" % [indentation - prevIndentation.key,""]
|
indent.value = "%*s" % [indentation - prevIndentation.key,""]
|
||||||
|
|
||||||
_shouldTrackIndent = false
|
_shouldTrackIndent = false
|
||||||
|
@ -224,7 +224,7 @@ func tokenize_line(line:String, lineNumber : int)->Array:
|
||||||
while indentation < _indentStack.front().key:
|
while indentation < _indentStack.front().key:
|
||||||
var top : IntBoolPair = _indentStack.pop_front()
|
var top : IntBoolPair = _indentStack.pop_front()
|
||||||
if top.value:
|
if top.value:
|
||||||
var deIndent : Token = Token.new(YarnGlobals.TokenType.Dedent,_currentState,lineNumber,0)
|
var deIndent : Token = Token.new(WolGlobals.TokenType.Dedent,_currentState,lineNumber,0)
|
||||||
tokenStack.push_front(deIndent)
|
tokenStack.push_front(deIndent)
|
||||||
|
|
||||||
|
|
||||||
|
@ -251,22 +251,22 @@ func tokenize_line(line:String, lineNumber : int)->Array:
|
||||||
|
|
||||||
var tokenText : String
|
var tokenText : String
|
||||||
|
|
||||||
if rule.tokenType == YarnGlobals.TokenType.Text:
|
if rule.tokenType == WolGlobals.TokenType.Text:
|
||||||
#if this is text then we back up to the most recent
|
#if this is text then we back up to the most recent
|
||||||
#delimiting token and treat everything from there as text.
|
#delimiting token and treat everything from there as text.
|
||||||
|
|
||||||
var startIndex : int = indentation
|
var startIndex : int = indentation
|
||||||
|
|
||||||
if tokenStack.size() > 0 :
|
if tokenStack.size() > 0 :
|
||||||
while tokenStack.front().type == YarnGlobals.TokenType.Identifier:
|
while tokenStack.front().type == WolGlobals.TokenType.Identifier:
|
||||||
tokenStack.pop_front()
|
tokenStack.pop_front()
|
||||||
|
|
||||||
var startDelimitToken : Token = tokenStack.front()
|
var startDelimitToken : Token = tokenStack.front()
|
||||||
startIndex = startDelimitToken.column
|
startIndex = startDelimitToken.column
|
||||||
|
|
||||||
if startDelimitToken.type == YarnGlobals.TokenType.Indent:
|
if startDelimitToken.type == WolGlobals.TokenType.Indent:
|
||||||
startIndex += startDelimitToken.value.length()
|
startIndex += startDelimitToken.value.length()
|
||||||
if startDelimitToken.type == YarnGlobals.TokenType.Dedent:
|
if startDelimitToken.type == WolGlobals.TokenType.Dedent:
|
||||||
startIndex = indentation
|
startIndex = indentation
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ func tokenize_line(line:String, lineNumber : int)->Array:
|
||||||
column += tokenText.length()
|
column += tokenText.length()
|
||||||
|
|
||||||
#pre-proccess string
|
#pre-proccess string
|
||||||
if rule.tokenType == YarnGlobals.TokenType.Str:
|
if rule.tokenType == WolGlobals.TokenType.Str:
|
||||||
tokenText = tokenText.substr(1,tokenText.length() - 2)
|
tokenText = tokenText.substr(1,tokenText.length() - 2)
|
||||||
tokenText = tokenText.replace("\\\\", "\\")
|
tokenText = tokenText.replace("\\\\", "\\")
|
||||||
tokenText = tokenText.replace("\\\"","\"")
|
tokenText = tokenText.replace("\\\"","\"")
|
||||||
|
@ -356,7 +356,7 @@ class Token:
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
func _to_string():
|
func _to_string():
|
||||||
return "%s (%s) at %s:%s (state: %s)" % [YarnGlobals.token_type_name(type),value,lineNumber,column,lexerState]
|
return "%s (%s) at %s:%s (state: %s)" % [WolGlobals.token_type_name(type),value,lineNumber,column,lexerState]
|
||||||
|
|
||||||
|
|
||||||
class LexerState:
|
class LexerState:
|
||||||
|
@ -416,7 +416,7 @@ class Rule:
|
||||||
self.delimitsText = delimitsText
|
self.delimitsText = delimitsText
|
||||||
|
|
||||||
func _to_string():
|
func _to_string():
|
||||||
return "[Rule : %s - %s]" % [YarnGlobals.token_type_name(tokenType),regex]
|
return "[Rule : %s - %s]" % [WolGlobals.token_type_name(tokenType),regex]
|
||||||
|
|
||||||
class IntBoolPair:
|
class IntBoolPair:
|
||||||
var key : int
|
var key : int
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
extends Object
|
extends Object
|
||||||
|
|
||||||
const YarnGlobals = preload("res://addons/Wol/autoloads/execution_states.gd")
|
const WolGlobals = preload("res://addons/Wol/autoloads/execution_states.gd")
|
||||||
const Lexer = preload("res://addons/Wol/core/compiler/lexer.gd")
|
const Lexer = preload("res://addons/Wol/core/compiler/lexer.gd")
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ enum Associativity {
|
||||||
Left,Right,None
|
Left,Right,None
|
||||||
}
|
}
|
||||||
|
|
||||||
func parse_node()->YarnNode:
|
func parse_node()->WolNode:
|
||||||
return YarnNode.new("Start",null,self)
|
return WolNode.new("Start",null,self)
|
||||||
|
|
||||||
func next_symbol_is(validTypes:Array)->bool:
|
func next_symbol_is(validTypes:Array)->bool:
|
||||||
var type = self._tokens.front().type
|
var type = self._tokens.front().type
|
||||||
|
@ -37,7 +37,7 @@ func expect_symbol(tokenTypes:Array = [])->Lexer.Token:
|
||||||
var size = tokenTypes.size()
|
var size = tokenTypes.size()
|
||||||
|
|
||||||
if size == 0:
|
if size == 0:
|
||||||
if t.type == YarnGlobals.TokenType.EndOfInput:
|
if t.type == WolGlobals.TokenType.EndOfInput:
|
||||||
printerr("unexpected end of input")
|
printerr("unexpected end of input")
|
||||||
return null
|
return null
|
||||||
return t
|
return t
|
||||||
|
@ -75,11 +75,11 @@ class ParseNode:
|
||||||
func tags_to_string(indentLevel : int)->String:
|
func tags_to_string(indentLevel : int)->String:
|
||||||
return "%s" % "TAGS<tags_to_string>NOTIMPLEMENTED"
|
return "%s" % "TAGS<tags_to_string>NOTIMPLEMENTED"
|
||||||
|
|
||||||
func get_node_parent()->YarnNode:
|
func get_node_parent()->WolNode:
|
||||||
var node = self
|
var node = self
|
||||||
while node != null:
|
while node != null:
|
||||||
if node.has_method("yarn_node"):
|
if node.has_method("wol_node"):
|
||||||
return node as YarnNode
|
return node as WolNode
|
||||||
node = node.parent
|
node = node.parent
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
@ -90,8 +90,8 @@ class ParseNode:
|
||||||
func set_parent(parent):
|
func set_parent(parent):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
|
||||||
#this is a Yarn Node - contains all the text
|
#this is a Wol Node - contains all the text
|
||||||
class YarnNode extends ParseNode:
|
class WolNode extends ParseNode:
|
||||||
|
|
||||||
var name : String
|
var name : String
|
||||||
var source : String
|
var source : String
|
||||||
|
@ -103,11 +103,11 @@ class YarnNode extends ParseNode:
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
while (parser.tokens().size() > 0 &&
|
while (parser.tokens().size() > 0 &&
|
||||||
!parser.next_symbol_is([YarnGlobals.TokenType.Dedent,YarnGlobals.TokenType.EndOfInput])):
|
!parser.next_symbol_is([WolGlobals.TokenType.Dedent,WolGlobals.TokenType.EndOfInput])):
|
||||||
statements.append(Statement.new(self,parser))
|
statements.append(Statement.new(self,parser))
|
||||||
#print(statements.size())
|
#print(statements.size())
|
||||||
|
|
||||||
func yarn_node():
|
func wol_node():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func tree_string(indentLevel : int)->String:
|
func tree_string(indentLevel : int)->String:
|
||||||
|
@ -127,7 +127,7 @@ class Header extends ParseNode:
|
||||||
|
|
||||||
|
|
||||||
class Statement extends ParseNode:
|
class Statement extends ParseNode:
|
||||||
var Type = YarnGlobals.StatementTypes
|
var Type = WolGlobals.StatementTypes
|
||||||
|
|
||||||
var type : int
|
var type : int
|
||||||
var block : Block
|
var block : Block
|
||||||
|
@ -158,8 +158,8 @@ class Statement extends ParseNode:
|
||||||
elif CustomCommand.can_parse(parser):
|
elif CustomCommand.can_parse(parser):
|
||||||
customCommand = CustomCommand.new(self,parser)
|
customCommand = CustomCommand.new(self,parser)
|
||||||
type = Type.CustomCommand
|
type = Type.CustomCommand
|
||||||
elif parser.next_symbol_is([YarnGlobals.TokenType.Text]):
|
elif parser.next_symbol_is([WolGlobals.TokenType.Text]):
|
||||||
line = parser.expect_symbol([YarnGlobals.TokenType.Text]).value
|
line = parser.expect_symbol([WolGlobals.TokenType.Text]).value
|
||||||
type = Type.Line
|
type = Type.Line
|
||||||
else:
|
else:
|
||||||
printerr("expected a statement but got %s instead. (probably an inbalanced if statement)" % parser.tokens().front()._to_string())
|
printerr("expected a statement but got %s instead. (probably an inbalanced if statement)" % parser.tokens().front()._to_string())
|
||||||
|
@ -167,9 +167,9 @@ class Statement extends ParseNode:
|
||||||
|
|
||||||
var tags : Array = []
|
var tags : Array = []
|
||||||
|
|
||||||
while parser.next_symbol_is([YarnGlobals.TokenType.TagMarker]):
|
while parser.next_symbol_is([WolGlobals.TokenType.TagMarker]):
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.TagMarker])
|
parser.expect_symbol([WolGlobals.TokenType.TagMarker])
|
||||||
var tag : String = parser.expect_symbol([YarnGlobals.TokenType.Identifier]).value
|
var tag : String = parser.expect_symbol([WolGlobals.TokenType.Identifier]).value
|
||||||
tags.append(tag)
|
tags.append(tag)
|
||||||
|
|
||||||
if(tags.size()>0):
|
if(tags.size()>0):
|
||||||
|
@ -213,20 +213,20 @@ class CustomCommand extends ParseNode:
|
||||||
var clientCommand : String
|
var clientCommand : String
|
||||||
|
|
||||||
func _init(parent:ParseNode,parser).(parent,parser):
|
func _init(parent:ParseNode,parser).(parent,parser):
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.BeginCommand])
|
parser.expect_symbol([WolGlobals.TokenType.BeginCommand])
|
||||||
|
|
||||||
var commandTokens = []
|
var commandTokens = []
|
||||||
commandTokens.append(parser.expect_symbol())
|
commandTokens.append(parser.expect_symbol())
|
||||||
|
|
||||||
while !parser.next_symbol_is([YarnGlobals.TokenType.EndCommand]):
|
while !parser.next_symbol_is([WolGlobals.TokenType.EndCommand]):
|
||||||
commandTokens.append(parser.expect_symbol())
|
commandTokens.append(parser.expect_symbol())
|
||||||
|
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.EndCommand])
|
parser.expect_symbol([WolGlobals.TokenType.EndCommand])
|
||||||
|
|
||||||
#if first token is identifier and second is leftt parenthesis
|
#if first token is identifier and second is leftt parenthesis
|
||||||
#evaluate as function
|
#evaluate as function
|
||||||
if (commandTokens.size() > 1 && commandTokens[0].type == YarnGlobals.TokenType.Identifier
|
if (commandTokens.size() > 1 && commandTokens[0].type == WolGlobals.TokenType.Identifier
|
||||||
&& commandTokens[1].type == YarnGlobals.TokenType.LeftParen):
|
&& commandTokens[1].type == WolGlobals.TokenType.LeftParen):
|
||||||
var p = get_script().new(commandTokens,parser.library)
|
var p = get_script().new(commandTokens,parser.library)
|
||||||
var expression : ExpressionNode = ExpressionNode.parse(self,p)
|
var expression : ExpressionNode = ExpressionNode.parse(self,p)
|
||||||
type = Type.Expression
|
type = Type.Expression
|
||||||
|
@ -245,8 +245,8 @@ class CustomCommand extends ParseNode:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
static func can_parse(parser)->bool:
|
static func can_parse(parser)->bool:
|
||||||
return (parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand,YarnGlobals.TokenType.Text])
|
return (parser.next_symbols_are([WolGlobals.TokenType.BeginCommand,WolGlobals.TokenType.Text])
|
||||||
|| parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand,YarnGlobals.TokenType.Identifier]))
|
|| parser.next_symbols_are([WolGlobals.TokenType.BeginCommand,WolGlobals.TokenType.Identifier]))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ class ShortcutOptionGroup extends ParseNode:
|
||||||
var sIndex : int = 1
|
var sIndex : int = 1
|
||||||
options.append(ShortCutOption.new(sIndex, self, parser))
|
options.append(ShortCutOption.new(sIndex, self, parser))
|
||||||
sIndex+=1
|
sIndex+=1
|
||||||
while parser.next_symbol_is([YarnGlobals.TokenType.ShortcutOption]):
|
while parser.next_symbol_is([WolGlobals.TokenType.ShortcutOption]):
|
||||||
options.append(ShortCutOption.new(sIndex, self, parser))
|
options.append(ShortCutOption.new(sIndex, self, parser))
|
||||||
sIndex+=1
|
sIndex+=1
|
||||||
|
|
||||||
|
@ -282,43 +282,43 @@ class ShortcutOptionGroup extends ParseNode:
|
||||||
return info.join("")
|
return info.join("")
|
||||||
|
|
||||||
static func can_parse(parser)->bool:
|
static func can_parse(parser)->bool:
|
||||||
return parser.next_symbol_is([YarnGlobals.TokenType.ShortcutOption])
|
return parser.next_symbol_is([WolGlobals.TokenType.ShortcutOption])
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class ShortCutOption extends ParseNode:
|
class ShortCutOption extends ParseNode:
|
||||||
|
|
||||||
var label : String
|
var label : String
|
||||||
var condition : ExpressionNode
|
var condition : ExpressionNode
|
||||||
var node : YarnNode
|
var node : WolNode
|
||||||
|
|
||||||
func _init(index:int, parent:ParseNode, parser).(parent,parser):
|
func _init(index:int, parent:ParseNode, parser).(parent,parser):
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.ShortcutOption])
|
parser.expect_symbol([WolGlobals.TokenType.ShortcutOption])
|
||||||
label = parser.expect_symbol([YarnGlobals.TokenType.Text]).value
|
label = parser.expect_symbol([WolGlobals.TokenType.Text]).value
|
||||||
|
|
||||||
# parse the conditional << if $x >> when it exists
|
# parse the conditional << if $x >> when it exists
|
||||||
|
|
||||||
var tags : Array = []#string
|
var tags : Array = []#string
|
||||||
while( parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand,YarnGlobals.TokenType.IfToken])
|
while( parser.next_symbols_are([WolGlobals.TokenType.BeginCommand,WolGlobals.TokenType.IfToken])
|
||||||
|| parser.next_symbol_is([YarnGlobals.TokenType.TagMarker])):
|
|| parser.next_symbol_is([WolGlobals.TokenType.TagMarker])):
|
||||||
|
|
||||||
if parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand, YarnGlobals.TokenType.IfToken]):
|
if parser.next_symbols_are([WolGlobals.TokenType.BeginCommand, WolGlobals.TokenType.IfToken]):
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.BeginCommand])
|
parser.expect_symbol([WolGlobals.TokenType.BeginCommand])
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.IfToken])
|
parser.expect_symbol([WolGlobals.TokenType.IfToken])
|
||||||
condition = ExpressionNode.parse(self,parser)
|
condition = ExpressionNode.parse(self,parser)
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.EndCommand])
|
parser.expect_symbol([WolGlobals.TokenType.EndCommand])
|
||||||
elif parser.next_symbol_is([YarnGlobals.TokenType.TagMarker]):
|
elif parser.next_symbol_is([WolGlobals.TokenType.TagMarker]):
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.TagMarker])
|
parser.expect_symbol([WolGlobals.TokenType.TagMarker])
|
||||||
var tag : String = parser.expect_symbol([YarnGlobals.TokenType.Identifier]).value;
|
var tag : String = parser.expect_symbol([WolGlobals.TokenType.Identifier]).value;
|
||||||
tags.append(tag)
|
tags.append(tag)
|
||||||
|
|
||||||
|
|
||||||
self.tags = tags
|
self.tags = tags
|
||||||
# parse remaining statements
|
# parse remaining statements
|
||||||
|
|
||||||
if parser.next_symbol_is([YarnGlobals.TokenType.Indent]):
|
if parser.next_symbol_is([WolGlobals.TokenType.Indent]):
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.Indent])
|
parser.expect_symbol([WolGlobals.TokenType.Indent])
|
||||||
node = YarnNode.new("%s.%s" %[self.get_node_parent().name ,index], self,parser)
|
node = WolNode.new("%s.%s" %[self.get_node_parent().name ,index], self,parser)
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.Dedent])
|
parser.expect_symbol([WolGlobals.TokenType.Dedent])
|
||||||
|
|
||||||
|
|
||||||
func tree_string(indentLevel : int)->String:
|
func tree_string(indentLevel : int)->String:
|
||||||
|
@ -346,15 +346,15 @@ class Block extends ParseNode:
|
||||||
|
|
||||||
func _init(parent:ParseNode, parser).(parent,parser):
|
func _init(parent:ParseNode, parser).(parent,parser):
|
||||||
#read indent
|
#read indent
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.Indent])
|
parser.expect_symbol([WolGlobals.TokenType.Indent])
|
||||||
|
|
||||||
#keep reading statements until we hit a dedent
|
#keep reading statements until we hit a dedent
|
||||||
while !parser.next_symbol_is([YarnGlobals.TokenType.Dedent]):
|
while !parser.next_symbol_is([WolGlobals.TokenType.Dedent]):
|
||||||
#parse all statements including nested blocks
|
#parse all statements including nested blocks
|
||||||
statements.append(Statement.new(self,parser))
|
statements.append(Statement.new(self,parser))
|
||||||
|
|
||||||
#clean up dedent
|
#clean up dedent
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.Dedent])
|
parser.expect_symbol([WolGlobals.TokenType.Dedent])
|
||||||
|
|
||||||
|
|
||||||
func tree_string(indentLevel : int)->String:
|
func tree_string(indentLevel : int)->String:
|
||||||
|
@ -370,7 +370,7 @@ class Block extends ParseNode:
|
||||||
return info.join("")
|
return info.join("")
|
||||||
|
|
||||||
static func can_parse(parser)->bool:
|
static func can_parse(parser)->bool:
|
||||||
return parser.next_symbol_is([YarnGlobals.TokenType.Indent])
|
return parser.next_symbol_is([WolGlobals.TokenType.Indent])
|
||||||
|
|
||||||
#Option Statements are links to other nodes
|
#Option Statements are links to other nodes
|
||||||
class OptionStatement extends ParseNode:
|
class OptionStatement extends ParseNode:
|
||||||
|
@ -383,20 +383,20 @@ class OptionStatement extends ParseNode:
|
||||||
var strings : Array = []#string
|
var strings : Array = []#string
|
||||||
|
|
||||||
#parse [[LABEL
|
#parse [[LABEL
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.OptionStart])
|
parser.expect_symbol([WolGlobals.TokenType.OptionStart])
|
||||||
strings.append(parser.expect_symbol([YarnGlobals.TokenType.Text]).value)
|
strings.append(parser.expect_symbol([WolGlobals.TokenType.Text]).value)
|
||||||
|
|
||||||
#if there is a | get the next string
|
#if there is a | get the next string
|
||||||
if parser.next_symbol_is([YarnGlobals.TokenType.OptionDelimit]):
|
if parser.next_symbol_is([WolGlobals.TokenType.OptionDelimit]):
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.OptionDelimit])
|
parser.expect_symbol([WolGlobals.TokenType.OptionDelimit])
|
||||||
var t = parser.expect_symbol([YarnGlobals.TokenType.Text,YarnGlobals.TokenType.Identifier])
|
var t = parser.expect_symbol([WolGlobals.TokenType.Text,WolGlobals.TokenType.Identifier])
|
||||||
#print("Token %s"%t.value)
|
#print("Token %s"%t.value)
|
||||||
strings.append(t.value as String)
|
strings.append(t.value as String)
|
||||||
|
|
||||||
label = strings[0] if strings.size() > 1 else ""
|
label = strings[0] if strings.size() > 1 else ""
|
||||||
destination = strings[1] if strings.size() > 1 else strings[0]
|
destination = strings[1] if strings.size() > 1 else strings[0]
|
||||||
|
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.OptionEnd])
|
parser.expect_symbol([WolGlobals.TokenType.OptionEnd])
|
||||||
|
|
||||||
func tree_string(indentLevel : int)->String:
|
func tree_string(indentLevel : int)->String:
|
||||||
if label != null:
|
if label != null:
|
||||||
|
@ -405,7 +405,7 @@ class OptionStatement extends ParseNode:
|
||||||
return tab(indentLevel,"Option: -> %s"%destination)
|
return tab(indentLevel,"Option: -> %s"%destination)
|
||||||
|
|
||||||
static func can_parse(parser)->bool:
|
static func can_parse(parser)->bool:
|
||||||
return parser.next_symbol_is([YarnGlobals.TokenType.OptionStart])
|
return parser.next_symbol_is([WolGlobals.TokenType.OptionStart])
|
||||||
|
|
||||||
class IfStatement extends ParseNode:
|
class IfStatement extends ParseNode:
|
||||||
|
|
||||||
|
@ -416,80 +416,80 @@ class IfStatement extends ParseNode:
|
||||||
#<<if Expression>>
|
#<<if Expression>>
|
||||||
var prime : Clause = Clause.new()
|
var prime : Clause = Clause.new()
|
||||||
|
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.BeginCommand])
|
parser.expect_symbol([WolGlobals.TokenType.BeginCommand])
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.IfToken])
|
parser.expect_symbol([WolGlobals.TokenType.IfToken])
|
||||||
prime.expression = ExpressionNode.parse(self,parser)
|
prime.expression = ExpressionNode.parse(self,parser)
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.EndCommand])
|
parser.expect_symbol([WolGlobals.TokenType.EndCommand])
|
||||||
|
|
||||||
#read statements until 'endif' or 'else' or 'else if'
|
#read statements until 'endif' or 'else' or 'else if'
|
||||||
var statements : Array = []#statement
|
var statements : Array = []#statement
|
||||||
while (!parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand, YarnGlobals.TokenType.EndIf])
|
while (!parser.next_symbols_are([WolGlobals.TokenType.BeginCommand, WolGlobals.TokenType.EndIf])
|
||||||
&& !parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand, YarnGlobals.TokenType.ElseToken])
|
&& !parser.next_symbols_are([WolGlobals.TokenType.BeginCommand, WolGlobals.TokenType.ElseToken])
|
||||||
&& !parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand, YarnGlobals.TokenType.ElseIf])):
|
&& !parser.next_symbols_are([WolGlobals.TokenType.BeginCommand, WolGlobals.TokenType.ElseIf])):
|
||||||
|
|
||||||
statements.append(Statement.new(self,parser))
|
statements.append(Statement.new(self,parser))
|
||||||
|
|
||||||
#ignore dedent
|
#ignore dedent
|
||||||
while parser.next_symbol_is([YarnGlobals.TokenType.Dedent]):
|
while parser.next_symbol_is([WolGlobals.TokenType.Dedent]):
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.Dedent])
|
parser.expect_symbol([WolGlobals.TokenType.Dedent])
|
||||||
|
|
||||||
|
|
||||||
prime.statements = statements
|
prime.statements = statements
|
||||||
clauses.append(prime)
|
clauses.append(prime)
|
||||||
|
|
||||||
#handle all else if
|
#handle all else if
|
||||||
while parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand,YarnGlobals.TokenType.ElseIf]):
|
while parser.next_symbols_are([WolGlobals.TokenType.BeginCommand,WolGlobals.TokenType.ElseIf]):
|
||||||
var clauseElif : Clause = Clause.new()
|
var clauseElif : Clause = Clause.new()
|
||||||
|
|
||||||
#parse condition syntax
|
#parse condition syntax
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.BeginCommand])
|
parser.expect_symbol([WolGlobals.TokenType.BeginCommand])
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.ElseIf])
|
parser.expect_symbol([WolGlobals.TokenType.ElseIf])
|
||||||
clauseElif.expression = ExpressionNode.parse(self,parser)
|
clauseElif.expression = ExpressionNode.parse(self,parser)
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.EndCommand])
|
parser.expect_symbol([WolGlobals.TokenType.EndCommand])
|
||||||
|
|
||||||
|
|
||||||
var elifStatements : Array = []#statement
|
var elifStatements : Array = []#statement
|
||||||
while (!parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand, YarnGlobals.TokenType.EndIf])
|
while (!parser.next_symbols_are([WolGlobals.TokenType.BeginCommand, WolGlobals.TokenType.EndIf])
|
||||||
&& !parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand, YarnGlobals.TokenType.ElseToken])
|
&& !parser.next_symbols_are([WolGlobals.TokenType.BeginCommand, WolGlobals.TokenType.ElseToken])
|
||||||
&& !parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand, YarnGlobals.TokenType.ElseIf])):
|
&& !parser.next_symbols_are([WolGlobals.TokenType.BeginCommand, WolGlobals.TokenType.ElseIf])):
|
||||||
|
|
||||||
elifStatements.append(Statement.new(self,parser))
|
elifStatements.append(Statement.new(self,parser))
|
||||||
|
|
||||||
#ignore dedent
|
#ignore dedent
|
||||||
while parser.next_symbol_is([YarnGlobals.TokenType.Dedent]):
|
while parser.next_symbol_is([WolGlobals.TokenType.Dedent]):
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.Dedent])
|
parser.expect_symbol([WolGlobals.TokenType.Dedent])
|
||||||
|
|
||||||
|
|
||||||
clauseElif.statements = statements
|
clauseElif.statements = statements
|
||||||
clauses.append(clauseElif)
|
clauses.append(clauseElif)
|
||||||
|
|
||||||
#handle else if exists
|
#handle else if exists
|
||||||
if (parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand,
|
if (parser.next_symbols_are([WolGlobals.TokenType.BeginCommand,
|
||||||
YarnGlobals.TokenType.ElseToken,YarnGlobals.TokenType.EndCommand])):
|
WolGlobals.TokenType.ElseToken,WolGlobals.TokenType.EndCommand])):
|
||||||
|
|
||||||
#expect no expression - just <<else>>
|
#expect no expression - just <<else>>
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.BeginCommand])
|
parser.expect_symbol([WolGlobals.TokenType.BeginCommand])
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.ElseToken])
|
parser.expect_symbol([WolGlobals.TokenType.ElseToken])
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.EndCommand])
|
parser.expect_symbol([WolGlobals.TokenType.EndCommand])
|
||||||
|
|
||||||
#parse until hit endif
|
#parse until hit endif
|
||||||
var clauseElse : Clause = Clause.new()
|
var clauseElse : Clause = Clause.new()
|
||||||
var elStatements : Array = []#statement
|
var elStatements : Array = []#statement
|
||||||
while !parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand,YarnGlobals.TokenType.EndIf]):
|
while !parser.next_symbols_are([WolGlobals.TokenType.BeginCommand,WolGlobals.TokenType.EndIf]):
|
||||||
elStatements.append(Statement.new(self,parser))
|
elStatements.append(Statement.new(self,parser))
|
||||||
|
|
||||||
clauseElse.statements = elStatements
|
clauseElse.statements = elStatements
|
||||||
clauses.append(clauseElse)
|
clauses.append(clauseElse)
|
||||||
|
|
||||||
#ignore dedent
|
#ignore dedent
|
||||||
while parser.next_symbol_is([YarnGlobals.TokenType.Dedent]):
|
while parser.next_symbol_is([WolGlobals.TokenType.Dedent]):
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.Dedent])
|
parser.expect_symbol([WolGlobals.TokenType.Dedent])
|
||||||
|
|
||||||
|
|
||||||
#finish
|
#finish
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.BeginCommand])
|
parser.expect_symbol([WolGlobals.TokenType.BeginCommand])
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.EndIf])
|
parser.expect_symbol([WolGlobals.TokenType.EndIf])
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.EndCommand])
|
parser.expect_symbol([WolGlobals.TokenType.EndCommand])
|
||||||
|
|
||||||
|
|
||||||
func tree_string(indentLevel : int)->String:
|
func tree_string(indentLevel : int)->String:
|
||||||
|
@ -509,7 +509,7 @@ class IfStatement extends ParseNode:
|
||||||
return info.join("")
|
return info.join("")
|
||||||
|
|
||||||
static func can_parse(parser)->bool:
|
static func can_parse(parser)->bool:
|
||||||
return parser.next_symbols_are([YarnGlobals.TokenType.BeginCommand,YarnGlobals.TokenType.IfToken])
|
return parser.next_symbols_are([WolGlobals.TokenType.BeginCommand,WolGlobals.TokenType.IfToken])
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class ValueNode extends ParseNode:
|
class ValueNode extends ParseNode:
|
||||||
|
@ -521,26 +521,26 @@ class ValueNode extends ParseNode:
|
||||||
|
|
||||||
var t : Lexer.Token = token
|
var t : Lexer.Token = token
|
||||||
if t == null :
|
if t == null :
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.Number,
|
parser.expect_symbol([WolGlobals.TokenType.Number,
|
||||||
YarnGlobals.TokenType.Variable,YarnGlobals.TokenType.Str])
|
WolGlobals.TokenType.Variable,WolGlobals.TokenType.Str])
|
||||||
use_token(t)
|
use_token(t)
|
||||||
|
|
||||||
#store value depending on type
|
#store value depending on type
|
||||||
func use_token(t:Lexer.Token):
|
func use_token(t:Lexer.Token):
|
||||||
match t.type:
|
match t.type:
|
||||||
YarnGlobals.TokenType.Number:
|
WolGlobals.TokenType.Number:
|
||||||
value = Value.new(float(t.value))
|
value = Value.new(float(t.value))
|
||||||
YarnGlobals.TokenType.Str:
|
WolGlobals.TokenType.Str:
|
||||||
value = Value.new(t.value)
|
value = Value.new(t.value)
|
||||||
YarnGlobals.TokenType.FalseToken:
|
WolGlobals.TokenType.FalseToken:
|
||||||
value = Value.new(false)
|
value = Value.new(false)
|
||||||
YarnGlobals.TokenType.TrueToken:
|
WolGlobals.TokenType.TrueToken:
|
||||||
value = Value.new(true)
|
value = Value.new(true)
|
||||||
YarnGlobals.TokenType.Variable:
|
WolGlobals.TokenType.Variable:
|
||||||
value = Value.new(null)
|
value = Value.new(null)
|
||||||
value.type = YarnGlobals.ValueType.Variable
|
value.type = WolGlobals.ValueType.Variable
|
||||||
value.variable = t.value
|
value.variable = t.value
|
||||||
YarnGlobals.TokenType.NullToken:
|
WolGlobals.TokenType.NullToken:
|
||||||
value = Value.new(null)
|
value = Value.new(null)
|
||||||
_:
|
_:
|
||||||
printerr("%s, Invalid token type" % t.name)
|
printerr("%s, Invalid token type" % t.name)
|
||||||
|
@ -564,20 +564,20 @@ class ExpressionNode extends ParseNode:
|
||||||
|
|
||||||
#no function - means value
|
#no function - means value
|
||||||
if value!=null:
|
if value!=null:
|
||||||
self.type = YarnGlobals.ExpressionType.Value
|
self.type = WolGlobals.ExpressionType.Value
|
||||||
self.value = value
|
self.value = value
|
||||||
else:#function
|
else:#function
|
||||||
|
|
||||||
self.type = YarnGlobals.ExpressionType.FunctionCall
|
self.type = WolGlobals.ExpressionType.FunctionCall
|
||||||
self.function = function
|
self.function = function
|
||||||
self.params = params
|
self.params = params
|
||||||
|
|
||||||
func tree_string(indentLevel : int)->String:
|
func tree_string(indentLevel : int)->String:
|
||||||
var info : PoolStringArray = []
|
var info : PoolStringArray = []
|
||||||
match type:
|
match type:
|
||||||
YarnGlobals.ExpressionType.Value:
|
WolGlobals.ExpressionType.Value:
|
||||||
return value.tree_string(indentLevel)
|
return value.tree_string(indentLevel)
|
||||||
YarnGlobals.ExpressionType.FunctionCall:
|
WolGlobals.ExpressionType.FunctionCall:
|
||||||
info.append(tab(indentLevel,"Func[%s - params(%s)]:{"%[function,params.size()]))
|
info.append(tab(indentLevel,"Func[%s - params(%s)]:{"%[function,params.size()]))
|
||||||
for param in params:
|
for param in params:
|
||||||
#print("----> %s paramSize:%s"%[(function) , params.size()])
|
#print("----> %s paramSize:%s"%[(function) , params.size()])
|
||||||
|
@ -599,16 +599,16 @@ class ExpressionNode extends ParseNode:
|
||||||
var funcStack : Array = []#token
|
var funcStack : Array = []#token
|
||||||
|
|
||||||
var validTypes : Array = [
|
var validTypes : Array = [
|
||||||
YarnGlobals.TokenType.Number,
|
WolGlobals.TokenType.Number,
|
||||||
YarnGlobals.TokenType.Variable,
|
WolGlobals.TokenType.Variable,
|
||||||
YarnGlobals.TokenType.Str,
|
WolGlobals.TokenType.Str,
|
||||||
YarnGlobals.TokenType.LeftParen,
|
WolGlobals.TokenType.LeftParen,
|
||||||
YarnGlobals.TokenType.RightParen,
|
WolGlobals.TokenType.RightParen,
|
||||||
YarnGlobals.TokenType.Identifier,
|
WolGlobals.TokenType.Identifier,
|
||||||
YarnGlobals.TokenType.Comma,
|
WolGlobals.TokenType.Comma,
|
||||||
YarnGlobals.TokenType.TrueToken,
|
WolGlobals.TokenType.TrueToken,
|
||||||
YarnGlobals.TokenType.FalseToken,
|
WolGlobals.TokenType.FalseToken,
|
||||||
YarnGlobals.TokenType.NullToken
|
WolGlobals.TokenType.NullToken
|
||||||
]
|
]
|
||||||
validTypes+=Operator.op_types()
|
validTypes+=Operator.op_types()
|
||||||
validTypes.invert()
|
validTypes.invert()
|
||||||
|
@ -619,26 +619,26 @@ class ExpressionNode extends ParseNode:
|
||||||
while parser.tokens().size() > 0 && parser.next_symbol_is(validTypes):
|
while parser.tokens().size() > 0 && parser.next_symbol_is(validTypes):
|
||||||
var next = parser.expect_symbol(validTypes) #lexer.Token
|
var next = parser.expect_symbol(validTypes) #lexer.Token
|
||||||
|
|
||||||
if( next.type == YarnGlobals.TokenType.Variable ||
|
if( next.type == WolGlobals.TokenType.Variable ||
|
||||||
next.type == YarnGlobals.TokenType.Number ||
|
next.type == WolGlobals.TokenType.Number ||
|
||||||
next.type == YarnGlobals.TokenType.Str ||
|
next.type == WolGlobals.TokenType.Str ||
|
||||||
next.type == YarnGlobals.TokenType.TrueToken ||
|
next.type == WolGlobals.TokenType.TrueToken ||
|
||||||
next.type == YarnGlobals.TokenType.FalseToken ||
|
next.type == WolGlobals.TokenType.FalseToken ||
|
||||||
next.type == YarnGlobals.TokenType.NullToken ):
|
next.type == WolGlobals.TokenType.NullToken ):
|
||||||
|
|
||||||
#output primitives
|
#output primitives
|
||||||
rpn.append(next)
|
rpn.append(next)
|
||||||
elif next.type == YarnGlobals.TokenType.Identifier:
|
elif next.type == WolGlobals.TokenType.Identifier:
|
||||||
opStack.push_back(next)
|
opStack.push_back(next)
|
||||||
funcStack.push_back(next)
|
funcStack.push_back(next)
|
||||||
|
|
||||||
#next token is parent - left
|
#next token is parent - left
|
||||||
next = parser.expect_symbol([YarnGlobals.TokenType.LeftParen])
|
next = parser.expect_symbol([WolGlobals.TokenType.LeftParen])
|
||||||
opStack.push_back(next)
|
opStack.push_back(next)
|
||||||
elif next.type == YarnGlobals.TokenType.Comma:
|
elif next.type == WolGlobals.TokenType.Comma:
|
||||||
|
|
||||||
#resolve sub expression before moving on
|
#resolve sub expression before moving on
|
||||||
while opStack.back().type != YarnGlobals.TokenType.LeftParen:
|
while opStack.back().type != WolGlobals.TokenType.LeftParen:
|
||||||
var p = opStack.pop_back()
|
var p = opStack.pop_back()
|
||||||
if p == null:
|
if p == null:
|
||||||
printerr("unbalanced parenthesis %s " % next.name)
|
printerr("unbalanced parenthesis %s " % next.name)
|
||||||
|
@ -648,8 +648,8 @@ class ExpressionNode extends ParseNode:
|
||||||
|
|
||||||
#next token in opStack left paren
|
#next token in opStack left paren
|
||||||
# next parser token not allowed to be right paren or comma
|
# next parser token not allowed to be right paren or comma
|
||||||
if parser.next_symbol_is([YarnGlobals.TokenType.RightParen,
|
if parser.next_symbol_is([WolGlobals.TokenType.RightParen,
|
||||||
YarnGlobals.TokenType.Comma]):
|
WolGlobals.TokenType.Comma]):
|
||||||
printerr("Expected Expression : %s" % parser.tokens().front().name)
|
printerr("Expected Expression : %s" % parser.tokens().front().name)
|
||||||
|
|
||||||
#find the closest function on stack
|
#find the closest function on stack
|
||||||
|
@ -668,17 +668,17 @@ class ExpressionNode extends ParseNode:
|
||||||
#is only unary when the last token was a left paren,
|
#is only unary when the last token was a left paren,
|
||||||
#an operator, or its the first token.
|
#an operator, or its the first token.
|
||||||
|
|
||||||
if (next.type == YarnGlobals.TokenType.Minus):
|
if (next.type == WolGlobals.TokenType.Minus):
|
||||||
if (last == null ||
|
if (last == null ||
|
||||||
last.type == YarnGlobals.TokenType.LeftParen ||
|
last.type == WolGlobals.TokenType.LeftParen ||
|
||||||
Operator.is_op(last.type)):
|
Operator.is_op(last.type)):
|
||||||
#unary minus
|
#unary minus
|
||||||
next.type = YarnGlobals.TokenType.UnaryMinus
|
next.type = WolGlobals.TokenType.UnaryMinus
|
||||||
|
|
||||||
#cannot assign inside expression
|
#cannot assign inside expression
|
||||||
# x = a is the same as x == a
|
# x = a is the same as x == a
|
||||||
if next.type == YarnGlobals.TokenType.EqualToOrAssign:
|
if next.type == WolGlobals.TokenType.EqualToOrAssign:
|
||||||
next.type = YarnGlobals.TokenType.EqualTo
|
next.type = WolGlobals.TokenType.EqualTo
|
||||||
|
|
||||||
|
|
||||||
#operator precedence
|
#operator precedence
|
||||||
|
@ -688,25 +688,25 @@ class ExpressionNode extends ParseNode:
|
||||||
|
|
||||||
opStack.push_back(next)
|
opStack.push_back(next)
|
||||||
|
|
||||||
elif next.type == YarnGlobals.TokenType.LeftParen:
|
elif next.type == WolGlobals.TokenType.LeftParen:
|
||||||
#entered parenthesis sub expression
|
#entered parenthesis sub expression
|
||||||
opStack.push_back(next)
|
opStack.push_back(next)
|
||||||
elif next.type == YarnGlobals.TokenType.RightParen:
|
elif next.type == WolGlobals.TokenType.RightParen:
|
||||||
#leaving sub expression
|
#leaving sub expression
|
||||||
# resolve order of operations
|
# resolve order of operations
|
||||||
while opStack.back().type != YarnGlobals.TokenType.LeftParen:
|
while opStack.back().type != WolGlobals.TokenType.LeftParen:
|
||||||
rpn.append(opStack.pop_back())
|
rpn.append(opStack.pop_back())
|
||||||
if opStack.back() == null:
|
if opStack.back() == null:
|
||||||
printerr("Unbalanced parenthasis #RightParen. Parser.ExpressionNode")
|
printerr("Unbalanced parenthasis #RightParen. Parser.ExpressionNode")
|
||||||
|
|
||||||
|
|
||||||
opStack.pop_back()
|
opStack.pop_back()
|
||||||
if opStack.back().type == YarnGlobals.TokenType.Identifier:
|
if opStack.back().type == WolGlobals.TokenType.Identifier:
|
||||||
#function call
|
#function call
|
||||||
#last token == left paren this == no params
|
#last token == left paren this == no params
|
||||||
#else
|
#else
|
||||||
#we have more than 1 param
|
#we have more than 1 param
|
||||||
if last.type != YarnGlobals.TokenType.LeftParen:
|
if last.type != WolGlobals.TokenType.LeftParen:
|
||||||
funcStack.back().paramCount+=1
|
funcStack.back().paramCount+=1
|
||||||
|
|
||||||
rpn.append(opStack.pop_back())
|
rpn.append(opStack.pop_back())
|
||||||
|
@ -735,7 +735,7 @@ class ExpressionNode extends ParseNode:
|
||||||
var info : OperatorInfo = Operator.op_info(next.type)
|
var info : OperatorInfo = Operator.op_info(next.type)
|
||||||
|
|
||||||
if evalStack.size() < info.arguments:
|
if evalStack.size() < info.arguments:
|
||||||
printerr("Error parsing : Not enough arguments for %s [ got %s expected - was %s]"%[YarnGlobals.token_type_name(next.type),evalStack.size(),info.arguments])
|
printerr("Error parsing : Not enough arguments for %s [ got %s expected - was %s]"%[WolGlobals.token_type_name(next.type),evalStack.size(),info.arguments])
|
||||||
|
|
||||||
var params : Array = []#ExpressionNode
|
var params : Array = []#ExpressionNode
|
||||||
for i in range(info.arguments):
|
for i in range(info.arguments):
|
||||||
|
@ -749,7 +749,7 @@ class ExpressionNode extends ParseNode:
|
||||||
|
|
||||||
evalStack.append(expression)
|
evalStack.append(expression)
|
||||||
|
|
||||||
elif next.type == YarnGlobals.TokenType.Identifier:
|
elif next.type == WolGlobals.TokenType.Identifier:
|
||||||
#function call
|
#function call
|
||||||
|
|
||||||
var function : String = next.value
|
var function : String = next.value
|
||||||
|
@ -785,8 +785,8 @@ class ExpressionNode extends ParseNode:
|
||||||
static func get_func_name(type)->String:
|
static func get_func_name(type)->String:
|
||||||
var string : String = ""
|
var string : String = ""
|
||||||
|
|
||||||
for key in YarnGlobals.TokenType.keys():
|
for key in WolGlobals.TokenType.keys():
|
||||||
if YarnGlobals.TokenType[key] == type:
|
if WolGlobals.TokenType[key] == type:
|
||||||
return key
|
return key
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
@ -822,35 +822,35 @@ class Assignment extends ParseNode:
|
||||||
var operation
|
var operation
|
||||||
|
|
||||||
func _init(parent:ParseNode,parser).(parent,parser):
|
func _init(parent:ParseNode,parser).(parent,parser):
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.BeginCommand])
|
parser.expect_symbol([WolGlobals.TokenType.BeginCommand])
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.Set])
|
parser.expect_symbol([WolGlobals.TokenType.Set])
|
||||||
destination = parser.expect_symbol([YarnGlobals.TokenType.Variable]).value
|
destination = parser.expect_symbol([WolGlobals.TokenType.Variable]).value
|
||||||
operation = parser.expect_symbol(Assignment.valid_ops()).type
|
operation = parser.expect_symbol(Assignment.valid_ops()).type
|
||||||
value = ExpressionNode.parse(self,parser)
|
value = ExpressionNode.parse(self,parser)
|
||||||
parser.expect_symbol([YarnGlobals.TokenType.EndCommand])
|
parser.expect_symbol([WolGlobals.TokenType.EndCommand])
|
||||||
|
|
||||||
func tree_string(indentLevel : int)->String:
|
func tree_string(indentLevel : int)->String:
|
||||||
var info : PoolStringArray = []
|
var info : PoolStringArray = []
|
||||||
info.append(tab(indentLevel,"set:"))
|
info.append(tab(indentLevel,"set:"))
|
||||||
info.append(tab(indentLevel+1,destination))
|
info.append(tab(indentLevel+1,destination))
|
||||||
info.append(tab(indentLevel+1,YarnGlobals.token_type_name(operation)))
|
info.append(tab(indentLevel+1,WolGlobals.token_type_name(operation)))
|
||||||
info.append(value.tree_string(indentLevel+1))
|
info.append(value.tree_string(indentLevel+1))
|
||||||
return info.join("")
|
return info.join("")
|
||||||
|
|
||||||
|
|
||||||
static func can_parse(parser)->bool:
|
static func can_parse(parser)->bool:
|
||||||
return parser.next_symbols_are([
|
return parser.next_symbols_are([
|
||||||
YarnGlobals.TokenType.BeginCommand,
|
WolGlobals.TokenType.BeginCommand,
|
||||||
YarnGlobals.TokenType.Set
|
WolGlobals.TokenType.Set
|
||||||
])
|
])
|
||||||
|
|
||||||
static func valid_ops()->Array:
|
static func valid_ops()->Array:
|
||||||
return [
|
return [
|
||||||
YarnGlobals.TokenType.EqualToOrAssign,
|
WolGlobals.TokenType.EqualToOrAssign,
|
||||||
YarnGlobals.TokenType.AddAssign,
|
WolGlobals.TokenType.AddAssign,
|
||||||
YarnGlobals.TokenType.MinusAssign,
|
WolGlobals.TokenType.MinusAssign,
|
||||||
YarnGlobals.TokenType.DivideAssign,
|
WolGlobals.TokenType.DivideAssign,
|
||||||
YarnGlobals.TokenType.MultiplyAssign
|
WolGlobals.TokenType.MultiplyAssign
|
||||||
]
|
]
|
||||||
|
|
||||||
class Operator extends ParseNode:
|
class Operator extends ParseNode:
|
||||||
|
@ -875,7 +875,7 @@ class Operator extends ParseNode:
|
||||||
|
|
||||||
#determine associativity and operands
|
#determine associativity and operands
|
||||||
# each operand has
|
# each operand has
|
||||||
var TokenType = YarnGlobals.TokenType
|
var TokenType = WolGlobals.TokenType
|
||||||
|
|
||||||
match op:
|
match op:
|
||||||
TokenType.Not, TokenType.UnaryMinus:
|
TokenType.Not, TokenType.UnaryMinus:
|
||||||
|
@ -903,27 +903,27 @@ class Operator extends ParseNode:
|
||||||
|
|
||||||
static func op_types()->Array:
|
static func op_types()->Array:
|
||||||
return [
|
return [
|
||||||
YarnGlobals.TokenType.Not,
|
WolGlobals.TokenType.Not,
|
||||||
YarnGlobals.TokenType.UnaryMinus,
|
WolGlobals.TokenType.UnaryMinus,
|
||||||
|
|
||||||
YarnGlobals.TokenType.Add,
|
WolGlobals.TokenType.Add,
|
||||||
YarnGlobals.TokenType.Minus,
|
WolGlobals.TokenType.Minus,
|
||||||
YarnGlobals.TokenType.Divide,
|
WolGlobals.TokenType.Divide,
|
||||||
YarnGlobals.TokenType.Multiply,
|
WolGlobals.TokenType.Multiply,
|
||||||
YarnGlobals.TokenType.Modulo,
|
WolGlobals.TokenType.Modulo,
|
||||||
|
|
||||||
YarnGlobals.TokenType.EqualToOrAssign,
|
WolGlobals.TokenType.EqualToOrAssign,
|
||||||
YarnGlobals.TokenType.EqualTo,
|
WolGlobals.TokenType.EqualTo,
|
||||||
YarnGlobals.TokenType.GreaterThan,
|
WolGlobals.TokenType.GreaterThan,
|
||||||
YarnGlobals.TokenType.GreaterThanOrEqualTo,
|
WolGlobals.TokenType.GreaterThanOrEqualTo,
|
||||||
YarnGlobals.TokenType.LessThan,
|
WolGlobals.TokenType.LessThan,
|
||||||
YarnGlobals.TokenType.LessThanOrEqualTo,
|
WolGlobals.TokenType.LessThanOrEqualTo,
|
||||||
YarnGlobals.TokenType.NotEqualTo,
|
WolGlobals.TokenType.NotEqualTo,
|
||||||
|
|
||||||
YarnGlobals.TokenType.And,
|
WolGlobals.TokenType.And,
|
||||||
YarnGlobals.TokenType.Or,
|
WolGlobals.TokenType.Or,
|
||||||
|
|
||||||
YarnGlobals.TokenType.Xor
|
WolGlobals.TokenType.Xor
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ const FMF_PLACEHOLDE = "<VALUE PLACEHOLDER>"
|
||||||
|
|
||||||
const StandardLibrary = preload("res://addons/Wol/core/libraries/standard.gd")
|
const StandardLibrary = preload("res://addons/Wol/core/libraries/standard.gd")
|
||||||
const VirtualMachine = preload("res://addons/Wol/core/virtual_machine.gd")
|
const VirtualMachine = preload("res://addons/Wol/core/virtual_machine.gd")
|
||||||
const YarnLibrary = preload("res://addons/Wol/core/library.gd")
|
const WolLibrary = preload("res://addons/Wol/core/library.gd")
|
||||||
const Value = preload("res://addons/Wol/core/value.gd")
|
const Value = preload("res://addons/Wol/core/value.gd")
|
||||||
const YarnProgram = preload("res://addons/Wol/core/program/program.gd")
|
const WolProgram = preload("res://addons/Wol/core/program/program.gd")
|
||||||
|
|
||||||
var _variableStorage
|
var _variableStorage
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ var executionComplete : bool
|
||||||
func _init(variableStorage):
|
func _init(variableStorage):
|
||||||
_variableStorage = variableStorage
|
_variableStorage = variableStorage
|
||||||
_vm = VirtualMachine.new(self)
|
_vm = VirtualMachine.new(self)
|
||||||
library = YarnLibrary.new()
|
library = WolLibrary.new()
|
||||||
_debugLog = funcref(self, "dlog")
|
_debugLog = funcref(self, "dlog")
|
||||||
_errLog = funcref(self, "elog")
|
_errLog = funcref(self, "elog")
|
||||||
executionComplete = false
|
executionComplete = false
|
||||||
|
@ -49,7 +49,7 @@ func elog(message:String):
|
||||||
print("YARN_ERROR : %s" % message)
|
print("YARN_ERROR : %s" % message)
|
||||||
|
|
||||||
func is_active():
|
func is_active():
|
||||||
return get_exec_state() != YarnGlobals.ExecutionState.Stopped
|
return get_exec_state() != WolGlobals.ExecutionState.Stopped
|
||||||
|
|
||||||
#gets the current execution state of the virtual machine
|
#gets the current execution state of the virtual machine
|
||||||
func get_exec_state():
|
func get_exec_state():
|
||||||
|
@ -62,7 +62,7 @@ func set_node(name:String = DEFAULT_START):
|
||||||
_vm.set_node(name)
|
_vm.set_node(name)
|
||||||
|
|
||||||
func resume():
|
func resume():
|
||||||
if _vm.executionState == YarnGlobals.ExecutionState.Running:
|
if _vm.executionState == WolGlobals.ExecutionState.Running:
|
||||||
print('BLOCKED')
|
print('BLOCKED')
|
||||||
return
|
return
|
||||||
_vm.resume()
|
_vm.resume()
|
||||||
|
@ -74,7 +74,7 @@ func stop():
|
||||||
_vm.stop()
|
_vm.stop()
|
||||||
|
|
||||||
func get_all_nodes():
|
func get_all_nodes():
|
||||||
return _program.yarnNodes.keys()
|
return _program.wolNodes.keys()
|
||||||
|
|
||||||
func current_node():
|
func current_node():
|
||||||
return _vm.get_current()
|
return _vm.get_current()
|
||||||
|
@ -116,7 +116,7 @@ func is_node_visited(node = _vm.current_node_name()):
|
||||||
|
|
||||||
func node_visit_count(node = _vm.current_node_name()):
|
func node_visit_count(node = _vm.current_node_name()):
|
||||||
if node is Value:
|
if node is Value:
|
||||||
node = _program.yarnStrings[node.value()].text
|
node = _program.wolStrings[node.value()].text
|
||||||
|
|
||||||
var visitCount : int = 0
|
var visitCount : int = 0
|
||||||
if _visitedNodeCount.has(node):
|
if _visitedNodeCount.has(node):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
extends Object
|
extends Object
|
||||||
|
|
||||||
const LineInfo = preload("res://addons/Wol/core/program/yarn_line.gd")
|
const LineInfo = preload("res://addons/Wol/core/program/wol_line.gd")
|
||||||
|
|
||||||
var id : String
|
var id : String
|
||||||
var substitutions : Array = []#String
|
var substitutions : Array = []#String
|
||||||
|
|
|
@ -12,7 +12,7 @@ func get_function(name:String)->FunctionInfo:
|
||||||
return null
|
return null
|
||||||
|
|
||||||
func import_library(other)->void:
|
func import_library(other)->void:
|
||||||
YarnGlobals.merge_dir(functions,other.functions)
|
WolGlobals.merge_dir(functions,other.functions)
|
||||||
|
|
||||||
func register_function(name: String, paramCount: int, function: FuncRef, returnsValue: bool):
|
func register_function(name: String, paramCount: int, function: FuncRef, returnsValue: bool):
|
||||||
var functionInfo: FunctionInfo = FunctionInfo.new(name, paramCount, function, returnsValue)
|
var functionInfo: FunctionInfo = FunctionInfo.new(name, paramCount, function, returnsValue)
|
||||||
|
|
|
@ -14,4 +14,4 @@ func dump(program,library)->String:
|
||||||
return "InstructionInformation:NotImplemented"
|
return "InstructionInformation:NotImplemented"
|
||||||
|
|
||||||
func _to_string():
|
func _to_string():
|
||||||
return YarnGlobals.bytecode_name(operation) + ':' + operands as String
|
return WolGlobals.bytecode_name(operation) + ':' + operands as String
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var programName : String
|
var programName : String
|
||||||
var yarnStrings : Dictionary = {}
|
var wolStrings : Dictionary = {}
|
||||||
var yarnNodes : Dictionary = {}
|
var wolNodes : Dictionary = {}
|
||||||
|
|
||||||
func get_node_tags(name:String)->Array:
|
func get_node_tags(name:String)->Array:
|
||||||
return yarnNodes[name].tags
|
return wolNodes[name].tags
|
||||||
|
|
||||||
func get_yarn_string(key:String)->String:
|
func get_wol_string(key:String)->String:
|
||||||
return yarnStrings[key]
|
return wolStrings[key]
|
||||||
|
|
||||||
func get_node_text(name:String)->String:
|
func get_node_text(name:String)->String:
|
||||||
var key = yarnNodes[name].sourceId
|
var key = wolNodes[name].sourceId
|
||||||
return get_yarn_string(key)
|
return get_wol_string(key)
|
||||||
|
|
||||||
#possible support for line tags
|
#possible support for line tags
|
||||||
func get_untagged_strings()->Dictionary:
|
func get_untagged_strings()->Dictionary:
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
extends Object
|
extends Object
|
||||||
|
|
||||||
const YarnGlobals = preload("res://addons/Wol/autoloads/execution_states.gd")
|
const WolGlobals = preload("res://addons/Wol/autoloads/execution_states.gd")
|
||||||
|
|
||||||
const NULL_STRING : String = "null"
|
const NULL_STRING : String = "null"
|
||||||
const FALSE_STRING : String= "false"
|
const FALSE_STRING : String= "false"
|
||||||
const TRUE_STRING : String = "true"
|
const TRUE_STRING : String = "true"
|
||||||
const NANI : String = "NaN"
|
const NANI : String = "NaN"
|
||||||
|
|
||||||
var type : int = YarnGlobals.ValueType.Nullean
|
var type : int = WolGlobals.ValueType.Nullean
|
||||||
var number : float = 0
|
var number : float = 0
|
||||||
var string : String = ""
|
var string : String = ""
|
||||||
var variable : String = ""
|
var variable : String = ""
|
||||||
|
@ -16,7 +16,7 @@ var boolean : bool = false
|
||||||
|
|
||||||
func _init(value = NANI):
|
func _init(value = NANI):
|
||||||
if typeof(value) == TYPE_OBJECT && value.get_script() == self.get_script():
|
if typeof(value) == TYPE_OBJECT && value.get_script() == self.get_script():
|
||||||
if value.type == YarnGlobals.ValueType.Variable:
|
if value.type == WolGlobals.ValueType.Variable:
|
||||||
self.type = value.type
|
self.type = value.type
|
||||||
self.variable = value.variable
|
self.variable = value.variable
|
||||||
else:
|
else:
|
||||||
|
@ -24,23 +24,23 @@ func _init(value = NANI):
|
||||||
|
|
||||||
func value():
|
func value():
|
||||||
match type:
|
match type:
|
||||||
YarnGlobals.ValueType.Number:
|
WolGlobals.ValueType.Number:
|
||||||
return number
|
return number
|
||||||
YarnGlobals.ValueType.Str:
|
WolGlobals.ValueType.Str:
|
||||||
return string
|
return string
|
||||||
YarnGlobals.ValueType.Boolean:
|
WolGlobals.ValueType.Boolean:
|
||||||
return boolean
|
return boolean
|
||||||
YarnGlobals.ValueType.Variable:
|
WolGlobals.ValueType.Variable:
|
||||||
return variable
|
return variable
|
||||||
return null
|
return null
|
||||||
|
|
||||||
func as_bool():
|
func as_bool():
|
||||||
match type:
|
match type:
|
||||||
YarnGlobals.ValueType.Number:
|
WolGlobals.ValueType.Number:
|
||||||
return number != 0
|
return number != 0
|
||||||
YarnGlobals.ValueType.Str:
|
WolGlobals.ValueType.Str:
|
||||||
return !string.empty()
|
return !string.empty()
|
||||||
YarnGlobals.ValueType.Boolean:
|
WolGlobals.ValueType.Boolean:
|
||||||
return boolean
|
return boolean
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
@ -49,37 +49,37 @@ func as_string():
|
||||||
|
|
||||||
func as_number():
|
func as_number():
|
||||||
match type:
|
match type:
|
||||||
YarnGlobals.ValueType.Number:
|
WolGlobals.ValueType.Number:
|
||||||
return number
|
return number
|
||||||
YarnGlobals.ValueType.Str:
|
WolGlobals.ValueType.Str:
|
||||||
return float(string)
|
return float(string)
|
||||||
YarnGlobals.ValueType.Boolean:
|
WolGlobals.ValueType.Boolean:
|
||||||
return 0.0 if !boolean else 1.0
|
return 0.0 if !boolean else 1.0
|
||||||
return .0
|
return .0
|
||||||
|
|
||||||
func set_value(value):
|
func set_value(value):
|
||||||
if value == null || (typeof(value) == TYPE_STRING && value == NANI):
|
if value == null || (typeof(value) == TYPE_STRING && value == NANI):
|
||||||
type = YarnGlobals.ValueType.Nullean
|
type = WolGlobals.ValueType.Nullean
|
||||||
return
|
return
|
||||||
|
|
||||||
match typeof(value):
|
match typeof(value):
|
||||||
TYPE_INT,TYPE_REAL:
|
TYPE_INT,TYPE_REAL:
|
||||||
type = YarnGlobals.ValueType.Number
|
type = WolGlobals.ValueType.Number
|
||||||
number = value
|
number = value
|
||||||
TYPE_STRING:
|
TYPE_STRING:
|
||||||
type = YarnGlobals.ValueType.Str
|
type = WolGlobals.ValueType.Str
|
||||||
string = value
|
string = value
|
||||||
TYPE_BOOL:
|
TYPE_BOOL:
|
||||||
type = YarnGlobals.ValueType.Boolean
|
type = WolGlobals.ValueType.Boolean
|
||||||
boolean = value
|
boolean = value
|
||||||
|
|
||||||
#operations >>
|
#operations >>
|
||||||
|
|
||||||
#addition
|
#addition
|
||||||
func add(other):
|
func add(other):
|
||||||
if self.type == YarnGlobals.ValueType.Str || other.type == YarnGlobals.ValueType.Str:
|
if self.type == WolGlobals.ValueType.Str || other.type == WolGlobals.ValueType.Str:
|
||||||
return get_script().new("%s%s"%[self.value(),other.value()])
|
return get_script().new("%s%s"%[self.value(),other.value()])
|
||||||
if self.type == YarnGlobals.ValueType.Number && other.type == YarnGlobals.ValueType.Number:
|
if self.type == WolGlobals.ValueType.Number && other.type == WolGlobals.ValueType.Number:
|
||||||
return get_script().new(self.number + other.number)
|
return get_script().new(self.number + other.number)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
@ -92,56 +92,56 @@ func equals(other)->bool:
|
||||||
|
|
||||||
#subtract
|
#subtract
|
||||||
func sub(other):
|
func sub(other):
|
||||||
if self.type == YarnGlobals.ValueType.Str || other.type == YarnGlobals.ValueType.Str:
|
if self.type == WolGlobals.ValueType.Str || other.type == WolGlobals.ValueType.Str:
|
||||||
return get_script().new(str(value()).replace(str(other.value()),""))
|
return get_script().new(str(value()).replace(str(other.value()),""))
|
||||||
if self.type == YarnGlobals.ValueType.Number && other.type == YarnGlobals.ValueType.Number:
|
if self.type == WolGlobals.ValueType.Number && other.type == WolGlobals.ValueType.Number:
|
||||||
return get_script().new(self.number - other.number)
|
return get_script().new(self.number - other.number)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
#multiply
|
#multiply
|
||||||
func mult(other):
|
func mult(other):
|
||||||
if self.type == YarnGlobals.ValueType.Number && other.type == YarnGlobals.ValueType.Number:
|
if self.type == WolGlobals.ValueType.Number && other.type == WolGlobals.ValueType.Number:
|
||||||
return get_script().new(self.number * other.number)
|
return get_script().new(self.number * other.number)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
#division
|
#division
|
||||||
func div(other):
|
func div(other):
|
||||||
if self.type == YarnGlobals.ValueType.Number && other.type == YarnGlobals.ValueType.Number:
|
if self.type == WolGlobals.ValueType.Number && other.type == WolGlobals.ValueType.Number:
|
||||||
return get_script().new(self.number / other.number)
|
return get_script().new(self.number / other.number)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
#modulus
|
#modulus
|
||||||
func mod(other):
|
func mod(other):
|
||||||
if self.type == YarnGlobals.ValueType.Number && other.type == YarnGlobals.ValueType.Number:
|
if self.type == WolGlobals.ValueType.Number && other.type == WolGlobals.ValueType.Number:
|
||||||
return get_script().new(self.number % other.number)
|
return get_script().new(self.number % other.number)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
func negative():
|
func negative():
|
||||||
if self.type == YarnGlobals.ValueType.Number:
|
if self.type == WolGlobals.ValueType.Number:
|
||||||
return get_script().new(-self.number)
|
return get_script().new(-self.number)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
#greater than other
|
#greater than other
|
||||||
func greater(other)->bool:
|
func greater(other)->bool:
|
||||||
if self.type == YarnGlobals.ValueType.Number && other.type == YarnGlobals.ValueType.Number:
|
if self.type == WolGlobals.ValueType.Number && other.type == WolGlobals.ValueType.Number:
|
||||||
return self.number > other.number
|
return self.number > other.number
|
||||||
return false
|
return false
|
||||||
|
|
||||||
#less than other
|
#less than other
|
||||||
func less(other)->bool:
|
func less(other)->bool:
|
||||||
if self.type == YarnGlobals.ValueType.Number && other.type == YarnGlobals.ValueType.Number:
|
if self.type == WolGlobals.ValueType.Number && other.type == WolGlobals.ValueType.Number:
|
||||||
return self.number < other.number
|
return self.number < other.number
|
||||||
return false
|
return false
|
||||||
|
|
||||||
#greater than or equal to other
|
#greater than or equal to other
|
||||||
func geq(other)->bool:
|
func geq(other)->bool:
|
||||||
if self.type == YarnGlobals.ValueType.Number && other.type == YarnGlobals.ValueType.Number:
|
if self.type == WolGlobals.ValueType.Number && other.type == WolGlobals.ValueType.Number:
|
||||||
return self.number > other.number || self.equals(other)
|
return self.number > other.number || self.equals(other)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
#lesser than or equal to other
|
#lesser than or equal to other
|
||||||
func leq(other)->bool:
|
func leq(other)->bool:
|
||||||
if self.type == YarnGlobals.ValueType.Number && other.type == YarnGlobals.ValueType.Number:
|
if self.type == WolGlobals.ValueType.Number && other.type == WolGlobals.ValueType.Number:
|
||||||
return self.number < other.number || self.equals(other)
|
return self.number < other.number || self.equals(other)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
extends Node
|
extends Node
|
||||||
var YarnGlobals = load("res://addons/Wol/autoloads/execution_states.gd")
|
var WolGlobals = load("res://addons/Wol/autoloads/execution_states.gd")
|
||||||
|
|
||||||
var FunctionInfo = load("res://addons/Wol/core/function_info.gd")
|
var FunctionInfo = load("res://addons/Wol/core/function_info.gd")
|
||||||
var Value = load("res://addons/Wol/core/value.gd")
|
var Value = load("res://addons/Wol/core/value.gd")
|
||||||
var YarnProgram = load("res://addons/Wol/core/program/program.gd")
|
var WolProgram = load("res://addons/Wol/core/program/program.gd")
|
||||||
var YarnNode = load("res://addons/Wol/core/program/yarn_node.gd")
|
var WolNode = load("res://addons/Wol/core/program/wol_node.gd")
|
||||||
var Instruction = load("res://addons/Wol/core/program/instruction.gd")
|
var Instruction = load("res://addons/Wol/core/program/instruction.gd")
|
||||||
var Line = load("res://addons/Wol/core/dialogue/line.gd")
|
var Line = load("res://addons/Wol/core/dialogue/line.gd")
|
||||||
var Command = load("res://addons/Wol/core/dialogue/command.gd")
|
var Command = load("res://addons/Wol/core/dialogue/command.gd")
|
||||||
|
@ -28,7 +28,7 @@ var _state
|
||||||
|
|
||||||
var _currentNode
|
var _currentNode
|
||||||
|
|
||||||
var executionState = YarnGlobals.ExecutionState.Stopped
|
var executionState = WolGlobals.ExecutionState.Stopped
|
||||||
|
|
||||||
var string_table = {}
|
var string_table = {}
|
||||||
|
|
||||||
|
@ -44,19 +44,19 @@ func set_program(program):
|
||||||
#return true if successeful false if no node
|
#return true if successeful false if no node
|
||||||
#of that name found
|
#of that name found
|
||||||
func set_node(name:String)->bool:
|
func set_node(name:String)->bool:
|
||||||
if _program == null || _program.yarnNodes.size() == 0:
|
if _program == null || _program.wolNodes.size() == 0:
|
||||||
printerr("Could not load %s : no nodes loaded" % name)
|
printerr("Could not load %s : no nodes loaded" % name)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if !_program.yarnNodes.has(name):
|
if !_program.wolNodes.has(name):
|
||||||
executionState = YarnGlobals.ExecutionState.Stopped
|
executionState = WolGlobals.ExecutionState.Stopped
|
||||||
reset()
|
reset()
|
||||||
printerr("No node named %s has been loaded" % name)
|
printerr("No node named %s has been loaded" % name)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
_dialogue.dlog("Running node %s" % name)
|
_dialogue.dlog("Running node %s" % name)
|
||||||
|
|
||||||
_currentNode = _program.yarnNodes[name]
|
_currentNode = _program.wolNodes[name]
|
||||||
reset()
|
reset()
|
||||||
_state.currentNodeName = name
|
_state.currentNodeName = name
|
||||||
nodeStartHandler.call_func(name)
|
nodeStartHandler.call_func(name)
|
||||||
|
@ -70,11 +70,11 @@ func current_node():
|
||||||
return _currentNode
|
return _currentNode
|
||||||
|
|
||||||
func pause():
|
func pause():
|
||||||
executionState = YarnGlobals.ExecutionState.Suspended
|
executionState = WolGlobals.ExecutionState.Suspended
|
||||||
|
|
||||||
#stop exectuion
|
#stop exectuion
|
||||||
func stop():
|
func stop():
|
||||||
executionState = YarnGlobals.ExecutionState.Stopped
|
executionState = WolGlobals.ExecutionState.Stopped
|
||||||
reset()
|
reset()
|
||||||
_currentNode = null
|
_currentNode = null
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ func stop():
|
||||||
#resume execution if waiting for result
|
#resume execution if waiting for result
|
||||||
#return false if error
|
#return false if error
|
||||||
func set_selected_option(id):
|
func set_selected_option(id):
|
||||||
if executionState != YarnGlobals.ExecutionState.WaitingForOption:
|
if executionState != WolGlobals.ExecutionState.WaitingForOption:
|
||||||
printerr("Unable to select option when dialogue not waiting for option")
|
printerr("Unable to select option when dialogue not waiting for option")
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ func set_selected_option(id):
|
||||||
_state.currentOptions.clear()
|
_state.currentOptions.clear()
|
||||||
|
|
||||||
#no longer waiting for option
|
#no longer waiting for option
|
||||||
executionState = YarnGlobals.ExecutionState.Suspended
|
executionState = WolGlobals.ExecutionState.Suspended
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ func resume()->bool:
|
||||||
if _currentNode == null :
|
if _currentNode == null :
|
||||||
printerr("Cannot run dialogue with no node selected")
|
printerr("Cannot run dialogue with no node selected")
|
||||||
return false
|
return false
|
||||||
if executionState == YarnGlobals.ExecutionState.WaitingForOption:
|
if executionState == WolGlobals.ExecutionState.WaitingForOption:
|
||||||
printerr("Cannot run while waiting for option")
|
printerr("Cannot run while waiting for option")
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
@ -133,10 +133,10 @@ func resume()->bool:
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
||||||
executionState = YarnGlobals.ExecutionState.Running
|
executionState = WolGlobals.ExecutionState.Running
|
||||||
|
|
||||||
#execute instruction until something cool happens
|
#execute instruction until something cool happens
|
||||||
while executionState == YarnGlobals.ExecutionState.Running:
|
while executionState == WolGlobals.ExecutionState.Running:
|
||||||
var currentInstruction = _currentNode.instructions[_state.programCounter]
|
var currentInstruction = _currentNode.instructions[_state.programCounter]
|
||||||
|
|
||||||
run_instruction(currentInstruction)
|
run_instruction(currentInstruction)
|
||||||
|
@ -144,7 +144,7 @@ func resume()->bool:
|
||||||
|
|
||||||
if _state.programCounter >= _currentNode.instructions.size():
|
if _state.programCounter >= _currentNode.instructions.size():
|
||||||
nodeCompleteHandler.call_func(_currentNode.nodeName)
|
nodeCompleteHandler.call_func(_currentNode.nodeName)
|
||||||
executionState = YarnGlobals.ExecutionState.Stopped
|
executionState = WolGlobals.ExecutionState.Stopped
|
||||||
reset()
|
reset()
|
||||||
dialogueCompleteHandler.call_func()
|
dialogueCompleteHandler.call_func()
|
||||||
_dialogue.dlog("Run Complete")
|
_dialogue.dlog("Run Complete")
|
||||||
|
@ -159,18 +159,18 @@ func find_label_instruction(label:String)->int:
|
||||||
|
|
||||||
func run_instruction(instruction)->bool:
|
func run_instruction(instruction)->bool:
|
||||||
match instruction.operation:
|
match instruction.operation:
|
||||||
YarnGlobals.ByteCode.Label:
|
WolGlobals.ByteCode.Label:
|
||||||
#do nothing woooo!
|
#do nothing woooo!
|
||||||
pass
|
pass
|
||||||
YarnGlobals.ByteCode.JumpTo:
|
WolGlobals.ByteCode.JumpTo:
|
||||||
#jump to named label
|
#jump to named label
|
||||||
_state .programCounter = find_label_instruction(instruction.operands[0].value)-1
|
_state .programCounter = find_label_instruction(instruction.operands[0].value)-1
|
||||||
YarnGlobals.ByteCode.RunLine:
|
WolGlobals.ByteCode.RunLine:
|
||||||
#look up string from string table
|
#look up string from string table
|
||||||
#pass it to client as line
|
#pass it to client as line
|
||||||
var key = instruction.operands[0].value
|
var key = instruction.operands[0].value
|
||||||
|
|
||||||
var line = Line.new(key, _program.yarnStrings[key])
|
var line = Line.new(key, _program.wolStrings[key])
|
||||||
|
|
||||||
#the second operand is the expression count
|
#the second operand is the expression count
|
||||||
# of format function
|
# of format function
|
||||||
|
@ -180,11 +180,11 @@ func run_instruction(instruction)->bool:
|
||||||
var pause : int = lineHandler.call_func(line)
|
var pause : int = lineHandler.call_func(line)
|
||||||
|
|
||||||
|
|
||||||
if pause == YarnGlobals.HandlerState.PauseExecution:
|
if pause == WolGlobals.HandlerState.PauseExecution:
|
||||||
executionState = YarnGlobals.ExecutionState.Suspended
|
executionState = WolGlobals.ExecutionState.Suspended
|
||||||
|
|
||||||
|
|
||||||
YarnGlobals.ByteCode.RunCommand:
|
WolGlobals.ByteCode.RunCommand:
|
||||||
var commandText : String = instruction.operands[0].value
|
var commandText : String = instruction.operands[0].value
|
||||||
|
|
||||||
if instruction.operands.size() > 1:
|
if instruction.operands.size() > 1:
|
||||||
|
@ -193,37 +193,37 @@ func run_instruction(instruction)->bool:
|
||||||
var command = Command.new(commandText)
|
var command = Command.new(commandText)
|
||||||
|
|
||||||
var pause = commandHandler.call_func(command) as int
|
var pause = commandHandler.call_func(command) as int
|
||||||
if pause == YarnGlobals.HandlerState.PauseExecution:
|
if pause == WolGlobals.HandlerState.PauseExecution:
|
||||||
executionState = YarnGlobals.ExecutionState.Suspended
|
executionState = WolGlobals.ExecutionState.Suspended
|
||||||
|
|
||||||
|
|
||||||
YarnGlobals.ByteCode.PushString:
|
WolGlobals.ByteCode.PushString:
|
||||||
#push String var to stack
|
#push String var to stack
|
||||||
_state.push_value(instruction.operands[0].value)
|
_state.push_value(instruction.operands[0].value)
|
||||||
YarnGlobals.ByteCode.PushNumber:
|
WolGlobals.ByteCode.PushNumber:
|
||||||
#push number to stack
|
#push number to stack
|
||||||
_state.push_value(instruction.operands[0].value)
|
_state.push_value(instruction.operands[0].value)
|
||||||
YarnGlobals.ByteCode.PushBool:
|
WolGlobals.ByteCode.PushBool:
|
||||||
#push boolean to stack
|
#push boolean to stack
|
||||||
_state.push_value(instruction.operands[0].value)
|
_state.push_value(instruction.operands[0].value)
|
||||||
|
|
||||||
YarnGlobals.ByteCode.PushNull:
|
WolGlobals.ByteCode.PushNull:
|
||||||
#push null t
|
#push null t
|
||||||
_state.push_value(NULL_VALUE)
|
_state.push_value(NULL_VALUE)
|
||||||
|
|
||||||
YarnGlobals.ByteCode.JumpIfFalse:
|
WolGlobals.ByteCode.JumpIfFalse:
|
||||||
#jump to named label if value of stack top is false
|
#jump to named label if value of stack top is false
|
||||||
if !_state.peek_value().as_bool():
|
if !_state.peek_value().as_bool():
|
||||||
_state.programCounter = find_label_instruction(instruction.operands[0].value)-1
|
_state.programCounter = find_label_instruction(instruction.operands[0].value)-1
|
||||||
|
|
||||||
YarnGlobals.ByteCode.Jump:
|
WolGlobals.ByteCode.Jump:
|
||||||
#jump to label whose name is on the stack
|
#jump to label whose name is on the stack
|
||||||
var dest : String = _state.peek_value().as_string()
|
var dest : String = _state.peek_value().as_string()
|
||||||
_state.programCounter = find_label_instruction(dest)-1
|
_state.programCounter = find_label_instruction(dest)-1
|
||||||
YarnGlobals.ByteCode.Pop:
|
WolGlobals.ByteCode.Pop:
|
||||||
#pop value from stack
|
#pop value from stack
|
||||||
_state.pop_value()
|
_state.pop_value()
|
||||||
YarnGlobals.ByteCode.CallFunc:
|
WolGlobals.ByteCode.CallFunc:
|
||||||
#call function with params on stack
|
#call function with params on stack
|
||||||
#push any return value to stack
|
#push any return value to stack
|
||||||
var functionName : String = instruction.operands[0].value
|
var functionName : String = instruction.operands[0].value
|
||||||
|
@ -259,25 +259,25 @@ func run_instruction(instruction)->bool:
|
||||||
_state.push_value(result)
|
_state.push_value(result)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
YarnGlobals.ByteCode.PushVariable:
|
WolGlobals.ByteCode.PushVariable:
|
||||||
#get content of variable and push to stack
|
#get content of variable and push to stack
|
||||||
var name : String = instruction.operands[0].value
|
var name : String = instruction.operands[0].value
|
||||||
var loaded = _dialogue._variableStorage.get_value(name)
|
var loaded = _dialogue._variableStorage.get_value(name)
|
||||||
_state.push_value(loaded)
|
_state.push_value(loaded)
|
||||||
YarnGlobals.ByteCode.StoreVariable:
|
WolGlobals.ByteCode.StoreVariable:
|
||||||
#store top stack value to variable
|
#store top stack value to variable
|
||||||
var top = _state.peek_value()
|
var top = _state.peek_value()
|
||||||
var destination : String = instruction.operands[0].value
|
var destination : String = instruction.operands[0].value
|
||||||
_dialogue._variableStorage.set_value(destination,top)
|
_dialogue._variableStorage.set_value(destination,top)
|
||||||
|
|
||||||
YarnGlobals.ByteCode.Stop:
|
WolGlobals.ByteCode.Stop:
|
||||||
#stop execution and repost it
|
#stop execution and repost it
|
||||||
nodeCompleteHandler.call_func(_currentNode.nodeName)
|
nodeCompleteHandler.call_func(_currentNode.nodeName)
|
||||||
dialogueCompleteHandler.call_func()
|
dialogueCompleteHandler.call_func()
|
||||||
executionState = YarnGlobals.ExecutionState.Stopped
|
executionState = WolGlobals.ExecutionState.Stopped
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
YarnGlobals.ByteCode.RunNode:
|
WolGlobals.ByteCode.RunNode:
|
||||||
#run a node
|
#run a node
|
||||||
var name : String
|
var name : String
|
||||||
|
|
||||||
|
@ -290,24 +290,24 @@ func run_instruction(instruction)->bool:
|
||||||
var pause = nodeCompleteHandler.call_func(_currentNode.nodeName)
|
var pause = nodeCompleteHandler.call_func(_currentNode.nodeName)
|
||||||
set_node(name)
|
set_node(name)
|
||||||
_state.programCounter-=1
|
_state.programCounter-=1
|
||||||
if pause == YarnGlobals.HandlerState.PauseExecution:
|
if pause == WolGlobals.HandlerState.PauseExecution:
|
||||||
executionState = YarnGlobals.ExecutionState.Suspended
|
executionState = WolGlobals.ExecutionState.Suspended
|
||||||
|
|
||||||
YarnGlobals.ByteCode.AddOption:
|
WolGlobals.ByteCode.AddOption:
|
||||||
# add an option to current state
|
# add an option to current state
|
||||||
var key = instruction.operands[0].value
|
var key = instruction.operands[0].value
|
||||||
|
|
||||||
var line = Line.new(key, _program.yarnStrings[key])
|
var line = Line.new(key, _program.wolStrings[key])
|
||||||
|
|
||||||
if instruction.operands.size() > 2:
|
if instruction.operands.size() > 2:
|
||||||
pass #formated text options
|
pass #formated text options
|
||||||
|
|
||||||
# line to show and node name
|
# line to show and node name
|
||||||
_state.currentOptions.append(SimpleEntry.new(line,instruction.operands[1].value))
|
_state.currentOptions.append(SimpleEntry.new(line,instruction.operands[1].value))
|
||||||
YarnGlobals.ByteCode.ShowOptions:
|
WolGlobals.ByteCode.ShowOptions:
|
||||||
#show options - stop if none
|
#show options - stop if none
|
||||||
if _state.currentOptions.size() == 0:
|
if _state.currentOptions.size() == 0:
|
||||||
executionState = YarnGlobals.ExecutionState.Stopped
|
executionState = WolGlobals.ExecutionState.Stopped
|
||||||
reset()
|
reset()
|
||||||
dialogueCompleteHandler.call_func()
|
dialogueCompleteHandler.call_func()
|
||||||
return false
|
return false
|
||||||
|
@ -319,7 +319,7 @@ func run_instruction(instruction)->bool:
|
||||||
choices.append(Option.new(option.key, optionIndex, option.value))
|
choices.append(Option.new(option.key, optionIndex, option.value))
|
||||||
|
|
||||||
#we cant continue until option chosen
|
#we cant continue until option chosen
|
||||||
executionState = YarnGlobals.ExecutionState.WaitingForOption
|
executionState = WolGlobals.ExecutionState.WaitingForOption
|
||||||
|
|
||||||
#pass the options to the client
|
#pass the options to the client
|
||||||
#delegate for them to call
|
#delegate for them to call
|
||||||
|
@ -329,7 +329,7 @@ func run_instruction(instruction)->bool:
|
||||||
pass
|
pass
|
||||||
_:
|
_:
|
||||||
#bytecode messed up woopsise
|
#bytecode messed up woopsise
|
||||||
executionState = YarnGlobals.ExecutionState.Stopped
|
executionState = WolGlobals.ExecutionState.Stopped
|
||||||
reset()
|
reset()
|
||||||
printerr("Unknown Bytecode %s "%instruction.operation)
|
printerr("Unknown Bytecode %s "%instruction.operation)
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -3,18 +3,18 @@ extends EditorPlugin
|
||||||
|
|
||||||
func _enter_tree():
|
func _enter_tree():
|
||||||
add_autoload_singleton(
|
add_autoload_singleton(
|
||||||
'YarnGlobals',
|
'WolGlobals',
|
||||||
'res://addons/Wol/autoloads/execution_states.gd'
|
'res://addons/Wol/autoloads/execution_states.gd'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_type(
|
add_custom_type(
|
||||||
'Wol',
|
'Wol',
|
||||||
'Node',
|
'Node',
|
||||||
load('res://addons/Wol/yarn_runner.gd'),
|
load('res://addons/Wol/Wol.gd'),
|
||||||
load('res://addons/Wol/assets/icon.png')
|
load('res://addons/Wol/assets/icon.png')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func _exit_tree():
|
func _exit_tree():
|
||||||
remove_autoload_singleton('YarnGlobals')
|
remove_autoload_singleton('WolGlobals')
|
||||||
remove_custom_type('Wol')
|
remove_custom_type('Wol')
|
||||||
|
|
|
@ -15,7 +15,7 @@ config/icon="res://icon.png"
|
||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
YarnGlobals="*res://addons/Wol/autoloads/execution_states.gd"
|
WolGlobals="*res://addons/Wol/autoloads/execution_states.gd"
|
||||||
|
|
||||||
[editor_plugins]
|
[editor_plugins]
|
||||||
|
|
||||||
|
|
Reference in a new issue