![]() |
|
|||
File indexing completed on 2025-08-03 08:19:36
0001 /* This software is distributed under the GNU Lesser General Public License */ 0002 //========================================================================== 0003 // 0004 // gml_scanner.h 0005 // 0006 //========================================================================== 0007 // $Id: gml_scanner.h,v 1.11 2000/03/06 15:16:52 raitner Exp $ 0008 0009 #ifndef GTL_GML_SCANNER_H 0010 #define GTL_GML_SCANNER_H 0011 0012 #include <GTL/GTL.h> 0013 0014 #include <cstdio> 0015 0016 __GTL_BEGIN_NAMESPACE 0017 0018 /* 0019 * start-size of buffers for reading strings. If too small it will be enlarged 0020 * dynamically 0021 */ 0022 0023 #define INITIAL_SIZE 1024 0024 0025 GTL_EXTERN typedef enum { 0026 GML_KEY, GML_INT, GML_DOUBLE, GML_STRING, GML_L_BRACKET, 0027 GML_R_BRACKET, GML_END, GML_LIST, GML_ERROR 0028 } GML_value; 0029 0030 0031 /** 0032 * Possible errors while parsing a GML file. 0033 */ 0034 GTL_EXTERN typedef enum { 0035 GML_UNEXPECTED, GML_SYNTAX, GML_PREMATURE_EOF, GML_TOO_MANY_DIGITS, 0036 GML_OPEN_BRACKET, GML_TOO_MANY_BRACKETS, GML_OK, GML_FILE_NOT_FOUND 0037 } GML_error_value; 0038 0039 0040 /** 0041 * @short Reason and position of an error in a GML file. 0042 * 0043 * When an error occurs while parsing the structure of a GML file 0044 * <code>GML_error</code> is used to return the type and position 0045 * of the error detected. Position is specified by 0046 * <code>line</code> and <code>column</code>, but might be 0047 * somewhat imprecise. However at least the line number should 0048 * not differ too much from the real position. 0049 * 0050 * @see graph#load 0051 */ 0052 struct GTL_EXTERN GML_error { 0053 /** 0054 * Contains the error description as symbolic constant: 0055 * <ul> 0056 * <li><code>GML_FILE_NOT_FOUND</code>: A file with that name 0057 * doesn't exist.</li> 0058 * <li><code>GML_OK</code>: No error :-)</li> 0059 * <li><code>GML_TOO_MANY_BRACKETS</code>: A mismatch of 0060 * brackets was detected, i.e. there were too many closing 0061 * brackets (<code>]</code>).</li> 0062 * <li><code>GML_OPEN_BRACKET</code>: Now, there were too many 0063 * opening brackets (<code>[</code>)</li> 0064 * <li><code>GML_TOO_MANY_DIGITS</code>: The number of digits a 0065 * integer or floating point value can have is limited to 0066 * 1024, this should be enough :-)</li> 0067 * <li><code>GML_PREMATURE_EOF</code>: An EOF occured, where it 0068 * wasn't expected, e.g. while scanning a string.</li> 0069 * <li><code>GML_SYNTAX</code>: The file isn't a valid GML file, 0070 * e.g. a mismatch in the key-value pairs.</li> 0071 * <li><code>GML_UNEXPECTED</code>: A character occured, where 0072 * it makes no sense, e.g. non-numerical characters in 0073 * numbers or keys beginning with numbers</li> 0074 * </ul> 0075 * 0076 */ 0077 GML_error_value err_num; 0078 0079 /** 0080 * Contains the line, where the error was detected. This will 0081 * usually be near the line where the error really is 0082 * located. 0083 */ 0084 int line; 0085 0086 /** 0087 * Contains the column, where the error was detected. 0088 */ 0089 int column; 0090 }; 0091 0092 0093 union GTL_EXTERN GML_tok_val { 0094 long integer; 0095 double floating; 0096 char* str; 0097 struct GML_error err; 0098 }; 0099 0100 /** 0101 * @internal 0102 */ 0103 struct GTL_EXTERN GML_token { 0104 GML_value kind; 0105 union GML_tok_val value; 0106 }; 0107 0108 /* 0109 * global variables 0110 */ 0111 0112 GTL_EXTERN extern unsigned int GML_line; 0113 GTL_EXTERN extern unsigned int GML_column; 0114 0115 /* 0116 * if you are interested in the position where an error occured it is a good 0117 * idea to set GML_line and GML_column back. 0118 * This is what GML_init does. 0119 */ 0120 0121 GTL_EXTERN void GML_init (); 0122 0123 /* 0124 * returns the next token in file. If an error occured it will be stored in 0125 * GML_token. 0126 */ 0127 0128 GTL_EXTERN struct GML_token GML_scanner (FILE*); 0129 0130 GTL_EXTERN extern const char* GML_table[]; 0131 0132 __GTL_END_NAMESPACE 0133 0134 #endif // GTL_GML_SCANNER_H 0135 0136 //-------------------------------------------------------------------------- 0137 // end of file 0138 //--------------------------------------------------------------------------
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |