g_scanner_scope_add_symbol中的scope_id参数代表什么?

发布于 2024-12-03 13:48:31 字数 358 浏览 0 评论 0原文

使用词法扫描器 GScanner 时,我想添加自己的符号进行扫描。在查找信息时,我只找到 API 文档和其他人的源代码(例如 Gimp)。除非我错过了一些明显的东西,否则没有任何地方可以解释作用域的作用。

我可以使用 g_scanner_add_symbol 并忽略该问题,但 g_scanner_add_symbol 已被弃用,唯一可以使用的是 g_scanner_scope_add_symbol。我了解如何使用此函数向自定义扫描仪添加符号,但我仍然不知道参数scope_id 的用途。我可以每次都将其设置为零而不用担心。问题是我不喜欢神秘,并且觉得scope_id可能非常有用。我想知道有多有用。

GScanner 中的scope_id 代表什么以及如何利用它?

When using the Lexical Scanner GScanner I want to add my own symbols to scan for. When looking for information I find only the API documentation and in other peoples source code like Gimp. No where is there any explanation as to what scope does, unless I've missed something obvious.

I could use g_scanner_add_symbol and ignore the problem, but g_scanner_add_symbol is deprecated and the only one left to use is g_scanner_scope_add_symbol. I understand how to add symbols to my custom scanner using this function, but I still have no idea what the parameter scope_id is used for. I could just set it to zero every-time and not worry about it. The problem is I don't like mysteries, and feel that scope_id could be very useful. I want to know how useful.

What does scope_id in GScanner represent and how can I take advantage of it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想挽留 2024-12-10 13:48:31

我想你可以使用范围来拥有不同的符号集。像这样的事情:

...
g_scanner_set_scope (scanner, first_scope);
g_scanner_scope_add_symbol (scanner, first_scope, "ONE", GINT_TO_POINTER(1));
...
g_scanner_set_scope (scanner, second_scope);
g_scanner_scope_add_symbol (scanner, second_scope, "TWO", GINT_TO_POINTER(2));
// The scanner wont find the symbol "ONE" now

我对此并不完全确定,但这就是我认为范围的用途。不过,您可以轻松测试它。

I guess you can use scopes to have different sets of symbols. Something like this:

...
g_scanner_set_scope (scanner, first_scope);
g_scanner_scope_add_symbol (scanner, first_scope, "ONE", GINT_TO_POINTER(1));
...
g_scanner_set_scope (scanner, second_scope);
g_scanner_scope_add_symbol (scanner, second_scope, "TWO", GINT_TO_POINTER(2));
// The scanner wont find the symbol "ONE" now

I'm not entirely sure about that, but that is what I thought scopes were for. You could easily test it, though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文