What does the scope_id parameter in g_scanner_scope_add_symbol represent?
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?
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.
精彩评论