mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-08 01:49:35 +01:00
Mostly class related improvements to the parser.
This commit is contained in:
parent
e44bf42190
commit
b7522472cd
@ -38,9 +38,10 @@ enum GDScopeType {
|
|||||||
|
|
||||||
class GDSScope:
|
class GDSScope:
|
||||||
var type : int = GDScopeType.GDSCOPE_TYPE_GENERIC
|
var type : int = GDScopeType.GDSCOPE_TYPE_GENERIC
|
||||||
var scope_name : String = ""
|
|
||||||
var scope_data : String = ""
|
var scope_data : String = ""
|
||||||
var raw_scope_data : String = ""
|
var raw_scope_data : String = ""
|
||||||
|
var scope_data_alt : String = ""
|
||||||
|
var raw_scope_data_alt : String = ""
|
||||||
var subscopes : Array = Array()
|
var subscopes : Array = Array()
|
||||||
var scope_lines : PoolStringArray = PoolStringArray()
|
var scope_lines : PoolStringArray = PoolStringArray()
|
||||||
|
|
||||||
@ -48,6 +49,25 @@ class GDSScope:
|
|||||||
while current_index < contents.size():
|
while current_index < contents.size():
|
||||||
var cl : String = contents[current_index]
|
var cl : String = contents[current_index]
|
||||||
|
|
||||||
|
if cl == "tool":
|
||||||
|
scope_lines.append("#" + cl)
|
||||||
|
current_index += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if cl.begins_with("class_name "):
|
||||||
|
type = GDScopeType.GDSCOPE_TYPE_CLASS
|
||||||
|
raw_scope_data = cl
|
||||||
|
scope_data = cl.trim_prefix("class_name ")
|
||||||
|
current_index += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if cl.begins_with("extends "):
|
||||||
|
type = GDScopeType.GDSCOPE_TYPE_CLASS
|
||||||
|
raw_scope_data_alt = cl
|
||||||
|
scope_data_alt = cl.trim_prefix("extends ")
|
||||||
|
current_index += 1
|
||||||
|
continue
|
||||||
|
|
||||||
if cl.begins_with("#"):
|
if cl.begins_with("#"):
|
||||||
scope_lines.append(cl)
|
scope_lines.append(cl)
|
||||||
current_index += 1
|
current_index += 1
|
||||||
@ -121,7 +141,13 @@ class GDSScope:
|
|||||||
|
|
||||||
var s : String = indents + "---GDSScope---\n"
|
var s : String = indents + "---GDSScope---\n"
|
||||||
|
|
||||||
s += indents + raw_scope_data + " -- " + type_to_print_string() + " " + scope_data + "\n"
|
s += indents + raw_scope_data + " -- " + type_to_print_string() + " "
|
||||||
|
s += scope_data
|
||||||
|
|
||||||
|
if scope_data_alt != "":
|
||||||
|
s += " " + scope_data_alt
|
||||||
|
|
||||||
|
s += "\n"
|
||||||
|
|
||||||
indents += " "
|
indents += " "
|
||||||
|
|
||||||
@ -164,8 +190,10 @@ class GDSScope:
|
|||||||
class GDSParser:
|
class GDSParser:
|
||||||
var root : GDSScope
|
var root : GDSScope
|
||||||
|
|
||||||
func parse(contents : String) -> void:
|
func parse(contents : String, file_name : String) -> void:
|
||||||
root = GDSScope.new()
|
root = GDSScope.new()
|
||||||
|
root.raw_scope_data = file_name
|
||||||
|
root.scope_data = file_name.get_file().trim_suffix(".gd")
|
||||||
var c : PoolStringArray = split_preprocess_content(contents)
|
var c : PoolStringArray = split_preprocess_content(contents)
|
||||||
root.parse(c)
|
root.parse(c)
|
||||||
|
|
||||||
@ -217,6 +245,6 @@ func process_file(file_name : String) -> void:
|
|||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
var parser : GDSParser = GDSParser.new()
|
var parser : GDSParser = GDSParser.new()
|
||||||
parser.parse(contents)
|
parser.parse(contents, file_name)
|
||||||
print(parser)
|
print(parser)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user