⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scanner.sgml

📁 This GLib version 2.16.1. GLib is the low-level core library that forms the basis for projects such
💻 SGML
📖 第 1 页 / 共 2 页
字号:
<!-- ##### SECTION Title ##### -->Lexical Scanner<!-- ##### SECTION Short_Description ##### -->a general purpose lexical scanner<!-- ##### SECTION Long_Description ##### --><para>The #GScanner and its associated functions provide a general purposelexical scanner.</para><!--FIXME: really needs an example and more detail, but I don't completelyunderstand it myself. Look at gtkrc.c for some code using the scanner.--><!-- ##### SECTION See_Also ##### --><para></para><!-- ##### SECTION Stability_Level ##### --><!-- ##### STRUCT GScanner ##### --><para>The data structure representing a lexical scanner.</para><para>You should set <structfield>input_name</structfield> after creating the scanner, since it is used by the default message handler when displaying warnings and errors. If you are scanning a file, the file name would be a good choice.</para><para>The <structfield>user_data</structfield> and<structfield>max_parse_errors</structfield> fields are not used.If you need to associate extra data with the scanner you can place them here.</para><para>If you want to use your own message handler you can set the<structfield>msg_handler</structfield> field. The type of the messagehandler function is declared by #GScannerMsgFunc.</para>@user_data: @max_parse_errors: @parse_errors: @input_name: @qdata: @config: @token:       token parsed by the last g_scanner_get_next_token()@value:       value of the last token from g_scanner_get_next_token()@line:        line number of the last token from g_scanner_get_next_token()@position:    char number of the last token from g_scanner_get_next_token()@next_token:    token parsed by the last g_scanner_peek_next_token()@next_value:    value of the last token from g_scanner_peek_next_token()@next_line:     line number of the last token from g_scanner_peek_next_token()@next_position: char number of the last token from g_scanner_peek_next_token()@symbol_table: @input_fd: @text: @text_end: @buffer: @scope_id: @msg_handler: function to handle GScanner message output<!-- ##### STRUCT GScannerConfig ##### --><para>Specifies the #GScanner parser configuration. Most settings can be changed duringthe parsing phase and will affect the lexical parsing of the next unpeeked token.</para><para><structfield>cset_skip_characters</structfield> specifies which charactersshould be skipped by the scanner (the default is the whitespace characters:space, tab, carriage-return and line-feed).</para><para><structfield>cset_identifier_first</structfield> specifies the characterswhich can start identifiers (the default is #G_CSET_a_2_z, "_", and #G_CSET_A_2_Z).</para><para><structfield>cset_identifier_nth</structfield> specifies the characterswhich can be used in identifiers, after the first character (the default is #G_CSET_a_2_z, "_0123456789", #G_CSET_A_2_Z, #G_CSET_LATINS,#G_CSET_LATINC).</para><para><structfield>cpair_comment_single</structfield> 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).</para><para><structfield>case_sensitive</structfield> specifies if symbols arecase sensitive (the default is %FALSE).</para><para><structfield>skip_comment_multi</structfield> specifies if multi-linecomments are skipped and not returned as tokens (the default is %TRUE).</para><para><structfield>skip_comment_single</structfield> specifies if single-linecomments are skipped and not returned as tokens (the default is %TRUE).</para><para><structfield>scan_comment_multi</structfield> specifies if multi-linecomments are recognized (the default is %TRUE).</para><para><structfield>scan_identifier</structfield> specifies if identifiersare recognized (the default is %TRUE).</para><para><structfield>scan_identifier_1char</structfield> specifies if single-characteridentifiers are recognized (the default is %FALSE).</para><para><structfield>scan_identifier_NULL</structfield> specifies if <literal>NULL</literal> is reported as #G_TOKEN_IDENTIFIER_NULL.(the default is %FALSE).</para><para><structfield>scan_symbols</structfield> specifies if symbols arerecognized (the default is %TRUE).</para><para><structfield>scan_binary</structfield> specifies if binary numbersare recognized (the default is %FALSE).</para><para><structfield>scan_octal</structfield> specifies if octal numbersare recognized (the default is %TRUE).</para><para><structfield>scan_float</structfield> specifies if floating point numbersare recognized (the default is %TRUE).</para><para><structfield>scan_hex</structfield> specifies if hexadecimal numbersare recognized (the default is %TRUE).</para><para><structfield>scan_hex_dollar</structfield> specifies if '$' is recognizedas a prefix for hexadecimal numbers (the default is %FALSE).</para><para><structfield>scan_string_sq</structfield> specifies if strings can beenclosed in single quotes (the default is %TRUE).</para><para><structfield>scan_string_dq</structfield> specifies if strings can beenclosed in double quotes (the default is %TRUE).</para><para><structfield>numbers_2_int</structfield> specifies if binary, octal andhexadecimal numbers are reported as #G_TOKEN_INT (the default is %TRUE).</para><para><structfield>int_2_float</structfield> specifies if all numbers are reported as #G_TOKEN_FLOAT (the default is %FALSE).</para><para><structfield>identifier_2_string</structfield> specifies if identifiersare reported as strings (the default is %FALSE).</para><para><structfield>char_2_token</structfield> specifies if charactersare reported by setting <literal>token = ch</literal> or as #G_TOKEN_CHAR (the default is %TRUE).</para><para><structfield>symbol_2_token</structfield> specifies if symbols are reported by setting <literal>token = v_symbol</literal> or as#G_TOKEN_SYMBOL (the default is %FALSE).</para><para><structfield>scope_0_fallback</structfield> specifies if a symbol is searched for in the default scope in addition to the current scope(the default is %FALSE).</para>@cset_skip_characters: @cset_identifier_first: @cset_identifier_nth: @cpair_comment_single: @case_sensitive: @skip_comment_multi: @skip_comment_single: @scan_comment_multi: @scan_identifier: @scan_identifier_1char: @scan_identifier_NULL: @scan_symbols: @scan_binary: @scan_octal: @scan_float: @scan_hex: @scan_hex_dollar: @scan_string_sq: @scan_string_dq: @numbers_2_int: @int_2_float: @identifier_2_string: @char_2_token: @symbol_2_token: @scope_0_fallback: @store_int64: @padding_dummy: <!-- ##### FUNCTION g_scanner_new ##### --><para>Creates a new #GScanner.The @config_templ structure specifies the initial settings of the scanner,which are copied into the #GScanner <structfield>config</structfield> field.If you pass %NULL then the default settings are used.</para>@config_templ: the initial scanner settings.@Returns: the new #GScanner.<!-- ##### FUNCTION g_scanner_destroy ##### --><para>Frees all memory used by the #GScanner.</para>@scanner: a #GScanner.<!-- ##### FUNCTION g_scanner_input_file ##### --><para>Prepares to scan a file.</para>@scanner: a #GScanner.@input_fd: a file descriptor.<!-- ##### FUNCTION g_scanner_sync_file_offset ##### --><para>Rewinds the filedescriptor to the current buffer position and blows the file read ahead buffer. This is useful for third party uses ofthe scanners filedescriptor, which hooks onto the current scanning position.</para>@scanner: a #GScanner.<!-- ##### FUNCTION g_scanner_input_text ##### --><para>Prepares to scan a text buffer.</para>@scanner: a #GScanner.@text: the text buffer to scan.@text_len: the length of the text buffer.<!-- ##### FUNCTION g_scanner_peek_next_token ##### --><para>Parses the next token, without removing it from the input stream.The token data is placed in the<structfield>next_token</structfield>,<structfield>next_value</structfield>,<structfield>next_line</structfield>, and<structfield>next_position</structfield> fields of the #GScanner structure.</para><para>Note that, while the token is not removed from the input stream (i.e.the next call to g_scanner_get_next_token() will return the same token),it will not be reevaluated. This can lead to surprising results whenchanging scope or the scanner configuration after peeking the next token.Getting the next token after switching the scope or configuration willreturn whatever was peeked before, regardless of any symbols that mayhave been added or removed in the new scope. </para>@scanner: a #GScanner.@Returns: the type of the token.<!-- ##### FUNCTION g_scanner_get_next_token ##### --><para>Parses the next token just like g_scanner_peek_next_token() and alsoremoves it from the input stream.The token data is placed in the<structfield>token</structfield>,<structfield>value</structfield>,<structfield>line</structfield>, and<structfield>position</structfield> fields of the #GScanner structure.</para>@scanner: a #GScanner.@Returns: the type of the token.<!-- ##### FUNCTION g_scanner_eof ##### --><para>Returns %TRUE if the scanner has reached the end of the file or text buffer.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -