Changeset 4122
- Timestamp:
- 08/31/06 04:55:47 (7 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/scanner-opt-branch/lib/conf-lex.l
r3300 r4122 47 47 %} 48 48 49 /* Scanner for configuration files */49 /* Scanner for configuration files */ 50 50 51 51 %option nodefault … … 54 54 %option nounput 55 55 56 /* States. 'Normal' states STRING and MIDDLE share some rules; other states 57 have only their own rules */ 56 /* 57 * States. 'Normal' states STRING and MIDDLE share some rules; 58 * other states have only their own rules 59 */ 60 58 61 %s MIDDLE 59 62 %x STRING 60 63 %x ERR 61 64 62 /* Any whitespace-like character */ 65 /* Any whitespace-like character */ 66 63 67 BLANK [[:space:]] 64 68 65 69 IDCHAR [[:alnum:]_] 66 70 67 /* Note: `10', `10.4' and `.4' are valid, `10.' is not */ 71 /* Note: `10', `10.4' and `.4' are valid, `10.' is not */ 72 68 73 FLOAT [[:digit:]]*\.?[[:digit:]]+ 69 74 70 /* Only positive whole numbers are recognized here */ 75 /* Only positive whole numbers are recognized here */ 76 71 77 NUM 0|([1-9][[:digit:]]*) 72 78 73 /* Only number between 1 and 255, octally represented. */ 79 /* Only number between 1 and 255, octally represented. */ 80 74 81 OCTESC (1[0-7]{0,2})|([2-7][0-7]?)|(0[1-7][0-7]?)|(00[1-7]) 75 82 … … 79 86 80 87 /* End of line: It may be the end of this line. Same for End of file. */ 88 81 89 <MIDDLE>\n | 82 90 <MIDDLE><<EOF>> { … … 85 93 } 86 94 87 /* We want to match any blank, except End of line; that is why we have to 88 match whitespace one by one! */ 95 /* 96 * We want to match any blank, except End of line; that is why we have to 97 * match whitespace one by one! 98 */ 99 89 100 {BLANK} /* Eat up a blank */ 90 101 91 102 /* Escaped End of line: eat and be happy */ 103 92 104 <MIDDLE>\\\n /* Eat this! */ 93 105 94 /* Remove a comment; we do not change the state, this is done when the \n is 95 eaten */ 106 /* 107 * Remove a comment; we do not change the state, 108 * this is done when the \n is eaten 109 */ 110 96 111 #[^\n]* /* Eat this! */ 97 112 98 113 /* Some keywords at the beginning of lines */ 114 99 115 <INITIAL>"label" { 100 116 sensors_yylval.line = sensors_yylineno; … … 133 149 134 150 /* Anything else at the beginning of a line is an error */ 151 135 152 <INITIAL>. { 136 153 yymore(); … … 145 162 146 163 /* A number */ 164 147 165 <MIDDLE>{FLOAT} { 148 166 sensors_yylval.value = atof(sensors_yytext); … … 151 169 152 170 /* Some operators */ 153 <MIDDLE>"+" { 154 return '+'; 155 } 156 157 <MIDDLE>"-" { 158 return '-'; 159 } 160 161 <MIDDLE>"*" { 162 return '*'; 163 } 164 165 <MIDDLE>"/" { 166 return '/'; 167 } 168 169 <MIDDLE>"(" { 170 return '('; 171 } 172 173 <MIDDLE>")" { 174 return ')'; 175 } 176 <MIDDLE>"," { 177 return ','; 178 } 179 <MIDDLE>"@" { 180 return '@'; 181 } 182 <MIDDLE>"^" { 183 return '^'; 184 } 185 <MIDDLE>"`" { 186 return '`'; 187 } 171 172 <MIDDLE>"+" return '+'; 173 <MIDDLE>"-" return '-'; 174 <MIDDLE>"*" return '*'; 175 <MIDDLE>"/" return '/'; 176 <MIDDLE>"(" return '('; 177 <MIDDLE>")" return ')'; 178 <MIDDLE>"," return ','; 179 <MIDDLE>"@" return '@'; 180 <MIDDLE>"^" return '^'; 181 <MIDDLE>"`" return '`'; 188 182 189 183 /* Quoted string */ 184 190 185 <MIDDLE>\" { 191 186 buffer_malloc(); … … 194 189 195 190 /* Oops, newline while in a string is not good */ 191 196 192 <STRING>\n | 197 193 <STRING>\\\n { … … 204 200 205 201 /* At the end */ 202 206 203 <STRING>\" { 207 204 buffer_add_char("\0"); … … 244 241 245 242 /* We can't support \0, this would cause havoc! */ 243 246 244 <STRING>\\{OCTESC} { 247 245 int res; … … 251 249 252 250 /* Other escapes: just copy the character behind the slash */ 251 253 252 <STRING>\\. { 254 253 buffer_add_char(&sensors_yytext[1]); … … 256 255 257 256 /* Anything else */ 257 258 258 <STRING>[^\\\n\"]+ { 259 259 buffer_add_string(sensors_yytext); … … 261 261 262 262 /* A normal, unquoted identifier */ 263 263 264 <MIDDLE>{IDCHAR}+ { 264 265 sensors_yylval.name = strdup(sensors_yytext);
