📄 glib-lexical-scanner.html
字号:
</td></tr><tr><td><p><span class="term"><a class="link" href="glib-Lexical-Scanner.html#GTokenType">GTokenType</a> <em class="structfield"><code>next_token</code></em>;</span></p></td><td> token parsed by the last <a class="link" href="glib-Lexical-Scanner.html#g-scanner-peek-next-token"><code class="function">g_scanner_peek_next_token()</code></a></td></tr><tr><td><p><span class="term"><a class="link" href="glib-Lexical-Scanner.html#GTokenValue">GTokenValue</a> <em class="structfield"><code>next_value</code></em>;</span></p></td><td> value of the last token from <a class="link" href="glib-Lexical-Scanner.html#g-scanner-peek-next-token"><code class="function">g_scanner_peek_next_token()</code></a></td></tr><tr><td><p><span class="term"><a class="link" href="glib-Basic-Types.html#guint">guint</a> <em class="structfield"><code>next_line</code></em>;</span></p></td><td> line number of the last token from <a class="link" href="glib-Lexical-Scanner.html#g-scanner-peek-next-token"><code class="function">g_scanner_peek_next_token()</code></a></td></tr><tr><td><p><span class="term"><a class="link" href="glib-Basic-Types.html#guint">guint</a> <em class="structfield"><code>next_position</code></em>;</span></p></td><td>char number of the last token from <a class="link" href="glib-Lexical-Scanner.html#g-scanner-peek-next-token"><code class="function">g_scanner_peek_next_token()</code></a></td></tr><tr><td><p><span class="term"><a class="link" href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *<em class="structfield"><code>symbol_table</code></em>;</span></p></td><td></td></tr><tr><td><p><span class="term"><a class="link" href="glib-Basic-Types.html#gint">gint</a> <em class="structfield"><code>input_fd</code></em>;</span></p></td><td></td></tr><tr><td><p><span class="term">const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *<em class="structfield"><code>text</code></em>;</span></p></td><td></td></tr><tr><td><p><span class="term">const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *<em class="structfield"><code>text_end</code></em>;</span></p></td><td></td></tr><tr><td><p><span class="term"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *<em class="structfield"><code>buffer</code></em>;</span></p></td><td></td></tr><tr><td><p><span class="term"><a class="link" href="glib-Basic-Types.html#guint">guint</a> <em class="structfield"><code>scope_id</code></em>;</span></p></td><td></td></tr><tr><td><p><span class="term"><a class="link" href="glib-Lexical-Scanner.html#GScannerMsgFunc">GScannerMsgFunc</a> <em class="structfield"><code>msg_handler</code></em>;</span></p></td><td>function to handle GScanner message output</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3081562"></a><h3><a name="GScannerConfig"></a>GScannerConfig</h3><a class="indexterm" name="id3081575"></a><pre class="programlisting">typedef struct { /* Character sets */ gchar *cset_skip_characters; /* default: " \t\n" */ gchar *cset_identifier_first; gchar *cset_identifier_nth; gchar *cpair_comment_single; /* default: "#\n" */ /* Should symbol lookup work case sensitive? */ guint case_sensitive : 1; /* Boolean values to be adjusted "on the fly" * to configure scanning behaviour. */ guint skip_comment_multi : 1; /* C like comment */ guint skip_comment_single : 1; /* single line comment */ guint scan_comment_multi : 1; /* scan multi line comments? */ guint scan_identifier : 1; guint scan_identifier_1char : 1; guint scan_identifier_NULL : 1; guint scan_symbols : 1; guint scan_binary : 1; guint scan_octal : 1; guint scan_float : 1; guint scan_hex : 1; /* `0x0ff0' */ guint scan_hex_dollar : 1; /* `$0ff0' */ guint scan_string_sq : 1; /* string: 'anything' */ guint scan_string_dq : 1; /* string: "\\-escapes!\n" */ guint numbers_2_int : 1; /* bin, octal, hex => int */ guint int_2_float : 1; /* int => G_TOKEN_FLOAT? */ guint identifier_2_string : 1; guint char_2_token : 1; /* return G_TOKEN_CHAR? */ guint symbol_2_token : 1; guint scope_0_fallback : 1; /* try scope 0 on lookups? */ guint store_int64 : 1; /* use value.v_int64 rather than v_int */ guint padding_dummy;} GScannerConfig;</pre><p>Specifies the <a class="link" href="glib-Lexical-Scanner.html#GScanner"><span class="type">GScanner</span></a> parser configuration. Most settings can be changed duringthe parsing phase and will affect the lexical parsing of the next unpeeked token.</p><p><em class="structfield"><code>cset_skip_characters</code></em> specifies which charactersshould be skipped by the scanner (the default is the whitespace characters:space, tab, carriage-return and line-feed).</p><p><em class="structfield"><code>cset_identifier_first</code></em> specifies the characterswhich can start identifiers (the default is <a class="link" href="glib-Lexical-Scanner.html#G-CSET-a-2-z"><span class="type">G_CSET_a_2_z</span></a>, "_", and <a class="link" href="glib-Lexical-Scanner.html#G-CSET-A-2-Z:CAPS"><span class="type">G_CSET_A_2_Z</span></a>).</p><p><em class="structfield"><code>cset_identifier_nth</code></em> specifies the characterswhich can be used in identifiers, after the first character (the default is <a class="link" href="glib-Lexical-Scanner.html#G-CSET-a-2-z"><span class="type">G_CSET_a_2_z</span></a>, "_0123456789", <a class="link" href="glib-Lexical-Scanner.html#G-CSET-A-2-Z:CAPS"><span class="type">G_CSET_A_2_Z</span></a>, <a class="link" href="glib-Lexical-Scanner.html#G-CSET-LATINS:CAPS"><span class="type">G_CSET_LATINS</span></a>,<a class="link" href="glib-Lexical-Scanner.html#G-CSET-LATINC:CAPS"><span class="type">G_CSET_LATINC</span></a>).</p><p><em class="structfield"><code>cpair_comment_single</code></em> specifies the charactersat the start and end of single-line comments. The default is "#\n" whichmeans that single-line comments start with a '#' and continue until a '\n'(end of line).</p><p><em class="structfield"><code>case_sensitive</code></em> specifies if symbols arecase sensitive (the default is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>).</p><p><em class="structfield"><code>skip_comment_multi</code></em> specifies if multi-linecomments are skipped and not returned as tokens (the default is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>).</p><p><em class="structfield"><code>skip_comment_single</code></em> specifies if single-linecomments are skipped and not returned as tokens (the default is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>).</p><p><em class="structfield"><code>scan_comment_multi</code></em> specifies if multi-linecomments are recognized (the default is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>).</p><p><em class="structfield"><code>scan_identifier</code></em> specifies if identifiersare recognized (the default is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>).</p><p><em class="structfield"><code>scan_identifier_1char</code></em> specifies if single-characteridentifiers are recognized (the default is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>).</p><p><em class="structfield"><code>scan_identifier_NULL</code></em> specifies if <code class="literal">NULL</code> is reported as <span class="type">G_TOKEN_IDENTIFIER_NULL</span>.(the default is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>).</p><p><em class="structfield"><code>scan_symbols</code></em> specifies if symbols arerecognized (the default is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>).</p><p><em class="structfield"><code>scan_binary</code></em> specifies if binary numbersare recognized (the default is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>).</p><p><em class="structfield"><code>scan_octal</code></em> specifies if octal numbersare recognized (the default is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>).</p><p><em class="structfield"><code>scan_float</code></em> specifies if floating point numbersare recognized (the default is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>).</p><p><em class="structfield"><code>scan_hex</code></em> specifies if hexadecimal numbersare recognized (the default is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>).</p><p><em class="structfield"><code>scan_hex_dollar</code></em> specifies if '$' is recognizedas a prefix for hexadecimal numbers (the default is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>).</p><p><em class="structfield"><code>scan_string_sq</code></em> specifies if strings can beenclosed in single quotes (the default is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>).</p><p><em class="structfield"><code>scan_string_dq</code></em> specifies if strings can beenclosed in double quotes (the default is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>).</p><p><em class="structfield"><code>numbers_2_int</code></em> specifies if binary, octal andhexadecimal numbers are reported as <span class="type">G_TOKEN_INT</span> (the default is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>).</p><p><em class="structfield"><code>int_2_float</code></em> specifies if all numbers are reported as <span class="type">G_TOKEN_FLOAT</span> (the default is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>).</p><p><em class="structfield"><code>identifier_2_string</code></em> specifies if identifiersare reported as strings (the default is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>).</p><p><em class="structfield"><code>char_2_token</code></em> specifies if charactersare reported by setting <code class="literal">token = ch</code> or as <span class="type">G_TOKEN_CHAR</span> (the default is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>).</p><p><em class="structfield"><code>symbol_2_token</code></em> specifies if symbols are reported by setting <code class="literal">token = v_symbol</code> or as<span class="type">G_TOKEN_SYMBOL</span> (the default is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>).</p><p><em class="structfield"><code>scope_0_fallback</code></em> specifies if a symbol is searched for in the default scope in addition to the current scope(the default is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>).</p></div><hr><div class="refsect2" lang="en"><a name="id3082168"></a><h3><a name="g-scanner-new"></a>g_scanner_new ()</h3><a class="indexterm" name="id3082181"></a><pre class="programlisting"><a class="link" href="glib-Lexical-Scanner.html#GScanner">GScanner</a>* g_scanner_new (const <a class="link" href="glib-Lexical-Scanner.html#GScannerConfig">GScannerConfig</a> *config_templ);</pre><p>Creates a new <a class="link" href="glib-Lexical-Scanner.html#GScanner"><span class="type">GScanner</span></a>.The <em class="parameter"><code>config_templ</code></em> structure specifies the initial settings of the scanner,which are copied into the <a class="link" href="glib-Lexical-Scanner.html#GScanner"><span class="type">GScanner</span></a> <em class="structfield"><code>config</code></em> field.If you pass <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> then the default settings are used.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>config_templ</code></em> :</span></p></td><td>the initial scanner settings.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>the new <a class="link" href="glib-Lexical-Scanner.html#GScanner"><span class="type">GScanner</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3082285"></a><h3><a name="g-scanner-destroy"></a>g_scanner_destroy ()</h3><a class="indexterm" name="id3082298"></a><pre class="programlisting">void g_scanner_destroy (<a class="link" href="glib-Lexical-Scanner.html#GScanner">GScanner</a> *scanner);</pre><p>Frees all memory used by the <a class="link" href="glib-Lexical-Scanner.html#GScanner"><span class="type">GScanner</span></a>.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -