首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用Sprache在C#中解析带有"xxx ={ .. }“的文本

用Sprache在C#中解析带有"xxx ={ .. }“的文本
EN

Stack Overflow用户
提问于 2017-02-21 04:40:01
回答 1查看 359关注 0票数 0

你可能已经猜到了,我需要一些帮助。我目前正在和一个朋友一起做一个WPF,但是我们有一个问题:我们需要解析某种类型的文本,但是我们不知道该怎么做。我们发现了Sprache,它看起来是一个很棒的解析器,但我们不知道如何使用它。另外:英语不是我们的母语,所以这篇介绍文章对我们来说不是很容易理解。

所以我们决定在Stackoverflow上询问它。

我们要解析的文本位于一个简单的.txt文件中,如下所示:

代码语言:javascript
复制
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”的游戏,只是整个游戏的一小部分)

你们能给我们一点帮助或者一点小提示来启动吗?

先谢谢你,斯图菲

EN

回答 1

Stack Overflow用户

发布于 2017-02-21 04:48:27

这看起来很像JSON,但是使用未加引号的标记而不是字符串,等号(=)而不是冒号(:),属性之间没有逗号。为什么不检索库SpracheJSON,看看是否可以稍微修改一下它来解析文件呢?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42353815

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档