你可能已经猜到了,我需要一些帮助。我目前正在和一个朋友一起做一个WPF,但是我们有一个问题:我们需要解析某种类型的文本,但是我们不知道该怎么做。我们发现了Sprache,它看起来是一个很棒的解析器,但我们不知道如何使用它。另外:英语不是我们的母语,所以这篇介绍文章对我们来说不是很容易理解。
所以我们决定在Stackoverflow上询问它。
我们要解析的文本位于一个简单的.txt文件中,如下所示:
focus_tree = {
id = german_focus
country = {
factor = 0
modifier = {
add = 10
tag = GER
}
}
default = no
focus = {
id = GER_autobahn
icon = GFX_goal_generic_construct_infrastructure
x = 0
y = 0
cost = 10
ai_will_do = {
factor = 12
}
completion_reward = {
custom_effect_tooltip = GER_autobahn_tt
hidden_effect = {
64 = {
if = {
limit = { is_controlled_by = ROOT }
add_building_construction = {
type = infrastructure
level = 10
instant_build = yes
}
}
}
59 = {
if = {
limit = { is_controlled_by = ROOT }
add_building_construction = {
type = infrastructure
level = 10
instant_build = yes
}
}
}
60 = {
if = {
limit = { is_controlled_by = ROOT }
add_building_construction = {
type = infrastructure
level = 10
instant_build = yes
}
}
}
54 = {
if = {
limit = { is_controlled_by = ROOT }
add_building_construction = {
type = infrastructure
level = 10
instant_build = yes
}
}
}
}
}
}(它来自一款名为“钢铁之心IV”的游戏,只是整个游戏的一小部分)
你们能给我们一点帮助或者一点小提示来启动吗?
先谢谢你,斯图菲
发布于 2017-02-21 04:48:27
这看起来很像JSON,但是使用未加引号的标记而不是字符串,等号(=)而不是冒号(:),属性之间没有逗号。为什么不检索库SpracheJSON,看看是否可以稍微修改一下它来解析文件呢?
https://stackoverflow.com/questions/42353815
复制相似问题