Changeset 3848e0e for translator/Parser/lex.l
- Timestamp:
- Dec 3, 2014, 3:08:38 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- d9a0e76
- Parents:
- 42dcae7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/Parser/lex.l
r42dcae7 r3848e0e 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Tue Nov 11 08:10:05201413 * Update Count : 21512 * Last Modified On : Wed Dec 3 13:37:52 2014 13 * Update Count : 317 14 14 */ 15 15 … … 31 31 32 32 char *yyfilename; 33 std::string *strtext; // accumulate parts of character and string constant value 33 34 34 35 #define WHITE_RETURN(x) // do nothing … … 38 39 yylval.tok.loc.line = yylineno; \ 39 40 return(x) 41 #define RETURN_STR(x) yylval.tok.str = strtext; \ 42 yylval.tok.loc.file = yyfilename; \ 43 yylval.tok.loc.line = yylineno; \ 44 return(x) 40 45 41 46 #define KEYWORD_RETURN(x) RETURN_VAL(x) // keyword … … 49 54 #define NUMERIC_RETURN(x) rm_underscore(); RETURN_VAL(x) // numeric constant 50 55 51 void rm_underscore() { // remove underscores in constant or escape sequence 56 void rm_underscore() { 57 // remove underscores in numeric constant 52 58 int j = 0; 53 for ( int i = 0; i < yyleng; i += 1 ) {59 for ( int i = 0; yytext[i] != '\0'; i += 1 ) { 54 60 if ( yytext[i] != '_' ) { 55 61 yytext[j] = yytext[i]; … … 67 73 decimal [0-9] 68 74 hex [0-9a-fA-F] 69 universal_char "\\"((u {hex_quad})|(U{hex_quad}{2}))75 universal_char "\\"((u"_"?{hex_quad})|(U"_"?{hex_quad}{2})) 70 76 71 77 // identifier, GCC: $ in identifier … … 79 85 80 86 // numeric constants, CFA: '_' in constant 81 hex_quad {hex} {4}87 hex_quad {hex}("_"?{hex}){3} 82 88 integer_suffix "_"?(([uU][lL]?)|([uU]("ll"|"LL")?)|([lL][uU]?)|("ll"|"LL")[uU]?) 83 89 … … 106 112 simple_escape "\\"[abefnrtv'"?\\] 107 113 // ' stop highlighting 108 octal_escape "\\"{octal} {1,3}109 hex_escape "\\""x" {hex}+114 octal_escape "\\"{octal}("_"?{octal}){0,2} 115 hex_escape "\\""x""_"?{hex_digits} 110 116 escape_seq {simple_escape}|{octal_escape}|{hex_escape}|{universal_char} 111 117 … … 129 135 130 136 %x COMMENT 131 %x QUOTED 137 %x BKQUOTE 138 %x QUOTE 139 %x STRING 132 140 133 141 %% … … 141 149 lineno = strtol( yytext + 1, &end_num, 0 ); 142 150 begin_string = strchr( end_num, '"' ); 143 if ( begin_string ) {144 end_string = strchr( begin_string + 1, '"' );145 if( end_string ) {146 147 148 149 150 151 152 153 }151 if ( begin_string ) { 152 end_string = strchr( begin_string + 1, '"' ); 153 if ( end_string ) { 154 length = end_string - begin_string - 1; 155 filename = new char[ length + 1 ]; 156 memcpy( filename, begin_string + 1, length ); 157 filename[ length ] = '\0'; 158 //std::cout << "file " << filename << " line " << lineno << std::endl; 159 yylineno = lineno; 160 yyfilename = filename; 161 } 154 162 } 155 163 } … … 159 167 160 168 /* ignore C style comments */ 161 "/*" { BEGIN COMMENT;}169 "/*" { BEGIN COMMENT; } 162 170 <COMMENT>.|\n ; 163 <COMMENT>"*/" { BEGIN 0;}171 <COMMENT>"*/" { BEGIN 0; } 164 172 165 173 /* ignore C++ style comments */ … … 167 175 168 176 /* ignore whitespace */ 169 {h_white}+ { WHITE_RETURN(' ');}170 ({v_tab}|{c_return}|{form_feed})+ { WHITE_RETURN(' ');}171 ({h_white}|{v_tab}|{c_return}|{form_feed})*"\n" { NEWLINE_RETURN();}177 {h_white}+ { WHITE_RETURN(' '); } 178 ({v_tab}|{c_return}|{form_feed})+ { WHITE_RETURN(' '); } 179 ({h_white}|{v_tab}|{c_return}|{form_feed})*"\n" { NEWLINE_RETURN(); } 172 180 173 181 /* keywords */ 174 __alignof { KEYWORD_RETURN(ALIGNOF);} /* GCC */175 __alignof__ { KEYWORD_RETURN(ALIGNOF);} /* GCC */176 asm { KEYWORD_RETURN(ASM);}177 __asm { KEYWORD_RETURN(ASM);} /* GCC */178 __asm__ { KEYWORD_RETURN(ASM);} /* GCC */179 __attribute { KEYWORD_RETURN(ATTRIBUTE);} /* GCC */180 __attribute__ { KEYWORD_RETURN(ATTRIBUTE);} /* GCC */181 auto { KEYWORD_RETURN(AUTO);}182 _Bool { KEYWORD_RETURN(BOOL);} /* ANSI99 */183 break { KEYWORD_RETURN(BREAK);}184 case { KEYWORD_RETURN(CASE);}185 catch { KEYWORD_RETURN(CATCH);} /* CFA */186 char { KEYWORD_RETURN(CHAR);}187 choose { KEYWORD_RETURN(CHOOSE);} /* CFA */188 _Complex { KEYWORD_RETURN(COMPLEX);} /* ANSI99 */189 __complex { KEYWORD_RETURN(COMPLEX);} /* GCC */190 __complex__ { KEYWORD_RETURN(COMPLEX);} /* GCC */191 const { KEYWORD_RETURN(CONST);}192 __const { KEYWORD_RETURN(CONST);} /* GCC */193 __const__ { KEYWORD_RETURN(CONST);} /* GCC */194 context { KEYWORD_RETURN(CONTEXT);} /* CFA */195 continue { KEYWORD_RETURN(CONTINUE);}196 default { KEYWORD_RETURN(DEFAULT);}197 do { KEYWORD_RETURN(DO);}198 double { KEYWORD_RETURN(DOUBLE);}199 dtype { KEYWORD_RETURN(DTYPE);} /* CFA */200 else { KEYWORD_RETURN(ELSE);}201 enum { KEYWORD_RETURN(ENUM);}202 __extension__ { KEYWORD_RETURN(EXTENSION);} /* GCC */203 extern { KEYWORD_RETURN(EXTERN);}204 fallthru { KEYWORD_RETURN(FALLTHRU);} /* CFA */205 finally { KEYWORD_RETURN(FINALLY);} /* CFA */206 float { KEYWORD_RETURN(FLOAT);}207 for { KEYWORD_RETURN(FOR);}208 forall { KEYWORD_RETURN(FORALL);} /* CFA */209 fortran { KEYWORD_RETURN(FORTRAN);}210 ftype { KEYWORD_RETURN(FTYPE);} /* CFA */211 goto { KEYWORD_RETURN(GOTO);}212 if { KEYWORD_RETURN(IF);}213 _Imaginary { KEYWORD_RETURN(IMAGINARY);} /* ANSI99 */214 __imag { KEYWORD_RETURN(IMAGINARY);} /* GCC */215 __imag__ { KEYWORD_RETURN(IMAGINARY);} /* GCC */216 inline { KEYWORD_RETURN(INLINE);} /* ANSI99 */217 __inline { KEYWORD_RETURN(INLINE);} /* GCC */218 __inline__ { KEYWORD_RETURN(INLINE);} /* GCC */219 int { KEYWORD_RETURN(INT);}220 __label__ { KEYWORD_RETURN(LABEL);} /* GCC */221 long { KEYWORD_RETURN(LONG);}222 lvalue { KEYWORD_RETURN(LVALUE);} /* CFA */223 register { KEYWORD_RETURN(REGISTER);}224 restrict { KEYWORD_RETURN(RESTRICT);} /* ANSI99 */225 __restrict { KEYWORD_RETURN(RESTRICT);} /* GCC */226 __restrict__ { KEYWORD_RETURN(RESTRICT);} /* GCC */227 return { KEYWORD_RETURN(RETURN);}228 short { KEYWORD_RETURN(SHORT);}229 signed { KEYWORD_RETURN(SIGNED);}230 __signed { KEYWORD_RETURN(SIGNED);} /* GCC */231 __signed__ { KEYWORD_RETURN(SIGNED);} /* GCC */232 sizeof { KEYWORD_RETURN(SIZEOF);}233 static { KEYWORD_RETURN(STATIC);}234 struct { KEYWORD_RETURN(STRUCT);}235 switch { KEYWORD_RETURN(SWITCH);}236 throw { KEYWORD_RETURN(THROW);} /* CFA */237 try { KEYWORD_RETURN(TRY);} /* CFA */238 type { KEYWORD_RETURN(TYPE);} /* CFA */239 typedef { KEYWORD_RETURN(TYPEDEF);}240 typeof { KEYWORD_RETURN(TYPEOF);} /* GCC */241 __typeof { KEYWORD_RETURN(TYPEOF);} /* GCC */242 __typeof__ { KEYWORD_RETURN(TYPEOF);} /* GCC */243 union { KEYWORD_RETURN(UNION);}244 unsigned { KEYWORD_RETURN(UNSIGNED);}245 void { KEYWORD_RETURN(VOID);}246 volatile { KEYWORD_RETURN(VOLATILE);}247 __volatile { KEYWORD_RETURN(VOLATILE);} /* GCC */248 __volatile__ { KEYWORD_RETURN(VOLATILE);} /* GCC */249 while { KEYWORD_RETURN(WHILE);}182 __alignof { KEYWORD_RETURN(ALIGNOF); } // GCC 183 __alignof__ { KEYWORD_RETURN(ALIGNOF); } // GCC 184 asm { KEYWORD_RETURN(ASM); } 185 __asm { KEYWORD_RETURN(ASM); } // GCC 186 __asm__ { KEYWORD_RETURN(ASM); } // GCC 187 __attribute { KEYWORD_RETURN(ATTRIBUTE); } // GCC 188 __attribute__ { KEYWORD_RETURN(ATTRIBUTE); } // GCC 189 auto { KEYWORD_RETURN(AUTO); } 190 _Bool { KEYWORD_RETURN(BOOL); } // C99 191 break { KEYWORD_RETURN(BREAK); } 192 case { KEYWORD_RETURN(CASE); } 193 catch { KEYWORD_RETURN(CATCH); } // CFA 194 char { KEYWORD_RETURN(CHAR); } 195 choose { KEYWORD_RETURN(CHOOSE); } // CFA 196 _Complex { KEYWORD_RETURN(COMPLEX); } // C99 197 __complex { KEYWORD_RETURN(COMPLEX); } // GCC 198 __complex__ { KEYWORD_RETURN(COMPLEX); } // GCC 199 const { KEYWORD_RETURN(CONST); } 200 __const { KEYWORD_RETURN(CONST); } // GCC 201 __const__ { KEYWORD_RETURN(CONST); } // GCC 202 context { KEYWORD_RETURN(CONTEXT); } // CFA 203 continue { KEYWORD_RETURN(CONTINUE); } 204 default { KEYWORD_RETURN(DEFAULT); } 205 do { KEYWORD_RETURN(DO); } 206 double { KEYWORD_RETURN(DOUBLE); } 207 dtype { KEYWORD_RETURN(DTYPE); } // CFA 208 else { KEYWORD_RETURN(ELSE); } 209 enum { KEYWORD_RETURN(ENUM); } 210 __extension__ { KEYWORD_RETURN(EXTENSION); } // GCC 211 extern { KEYWORD_RETURN(EXTERN); } 212 fallthru { KEYWORD_RETURN(FALLTHRU); } // CFA 213 finally { KEYWORD_RETURN(FINALLY); } // CFA 214 float { KEYWORD_RETURN(FLOAT); } 215 for { KEYWORD_RETURN(FOR); } 216 forall { KEYWORD_RETURN(FORALL); } // CFA 217 fortran { KEYWORD_RETURN(FORTRAN); } 218 ftype { KEYWORD_RETURN(FTYPE); } // CFA 219 goto { KEYWORD_RETURN(GOTO); } 220 if { KEYWORD_RETURN(IF); } 221 _Imaginary { KEYWORD_RETURN(IMAGINARY); } // C99 222 __imag { KEYWORD_RETURN(IMAGINARY); } // GCC 223 __imag__ { KEYWORD_RETURN(IMAGINARY); } // GCC 224 inline { KEYWORD_RETURN(INLINE); } // C99 225 __inline { KEYWORD_RETURN(INLINE); } // GCC 226 __inline__ { KEYWORD_RETURN(INLINE); } // GCC 227 int { KEYWORD_RETURN(INT); } 228 __label__ { KEYWORD_RETURN(LABEL); } // GCC 229 long { KEYWORD_RETURN(LONG); } 230 lvalue { KEYWORD_RETURN(LVALUE); } // CFA 231 register { KEYWORD_RETURN(REGISTER); } 232 restrict { KEYWORD_RETURN(RESTRICT); } // C99 233 __restrict { KEYWORD_RETURN(RESTRICT); } // GCC 234 __restrict__ { KEYWORD_RETURN(RESTRICT); } // GCC 235 return { KEYWORD_RETURN(RETURN); } 236 short { KEYWORD_RETURN(SHORT); } 237 signed { KEYWORD_RETURN(SIGNED); } 238 __signed { KEYWORD_RETURN(SIGNED); } // GCC 239 __signed__ { KEYWORD_RETURN(SIGNED); } // GCC 240 sizeof { KEYWORD_RETURN(SIZEOF); } 241 static { KEYWORD_RETURN(STATIC); } 242 struct { KEYWORD_RETURN(STRUCT); } 243 switch { KEYWORD_RETURN(SWITCH); } 244 throw { KEYWORD_RETURN(THROW); } // CFA 245 try { KEYWORD_RETURN(TRY); } // CFA 246 type { KEYWORD_RETURN(TYPE); } // CFA 247 typedef { KEYWORD_RETURN(TYPEDEF); } 248 typeof { KEYWORD_RETURN(TYPEOF); } // GCC 249 __typeof { KEYWORD_RETURN(TYPEOF); } // GCC 250 __typeof__ { KEYWORD_RETURN(TYPEOF); } // GCC 251 union { KEYWORD_RETURN(UNION); } 252 unsigned { KEYWORD_RETURN(UNSIGNED); } 253 void { KEYWORD_RETURN(VOID); } 254 volatile { KEYWORD_RETURN(VOLATILE); } 255 __volatile { KEYWORD_RETURN(VOLATILE); } // GCC 256 __volatile__ { KEYWORD_RETURN(VOLATILE); } // GCC 257 while { KEYWORD_RETURN(WHILE); } 250 258 251 259 /* identifier */ 252 {identifier} { IDENTIFIER_RETURN();}253 {attr_identifier} { ATTRIBUTE_RETURN();}254 "`" { BEGIN QUOTED;}255 < QUOTED>{identifier} {IDENTIFIER_RETURN();}256 < QUOTED>"`" {BEGIN 0;}260 {identifier} { IDENTIFIER_RETURN(); } 261 {attr_identifier} { ATTRIBUTE_RETURN(); } 262 "`" { BEGIN BKQUOTE; } 263 <BKQUOTE>{identifier} { IDENTIFIER_RETURN(); } 264 <BKQUOTE>"`" { BEGIN 0; } 257 265 258 266 /* numeric constants */ 259 "0" { NUMERIC_RETURN(ZERO);} /* CFA */260 "1" { NUMERIC_RETURN(ONE);} /* CFA */261 {decimal_constant} { NUMERIC_RETURN(INTEGERconstant);}262 {octal_constant} { NUMERIC_RETURN(INTEGERconstant);}263 {hex_constant} { NUMERIC_RETURN(INTEGERconstant);}264 {floating_constant} { NUMERIC_RETURN(FLOATINGconstant);}265 {hex_floating_constant} { NUMERIC_RETURN(FLOATINGconstant);}267 "0" { NUMERIC_RETURN(ZERO); } // CFA 268 "1" { NUMERIC_RETURN(ONE); } // CFA 269 {decimal_constant} { NUMERIC_RETURN(INTEGERconstant); } 270 {octal_constant} { NUMERIC_RETURN(INTEGERconstant); } 271 {hex_constant} { NUMERIC_RETURN(INTEGERconstant); } 272 {floating_constant} { NUMERIC_RETURN(FLOATINGconstant); } 273 {hex_floating_constant} { NUMERIC_RETURN(FLOATINGconstant); } 266 274 267 275 /* character constant, allows empty value */ 268 "L"?[']([^'\\\n]|{escape_seq})*['] {RETURN_VAL(CHARACTERconstant);} 276 "L"?"_"?['] { BEGIN QUOTE; rm_underscore(); strtext = new std::string; *strtext += std::string( yytext ); } 277 <QUOTE>[^'\\\n]* { *strtext += std::string( yytext ); } 278 <QUOTE>['\n] { BEGIN 0; *strtext += std::string( yytext); RETURN_STR(CHARACTERconstant); } 269 279 /* ' stop highlighting */ 270 280 271 281 /* string constant */ 272 "L"?["]([^"\\\n]|{escape_seq})*["] {RETURN_VAL(STRINGliteral);} 282 "L"?"_"?["] { BEGIN STRING; rm_underscore(); strtext = new std::string; *strtext += std::string( yytext ); } 283 <STRING>[^"\\\n]* { *strtext += std::string( yytext ); } 284 <STRING>["\n] { BEGIN 0; *strtext += std::string( yytext); RETURN_STR(STRINGliteral); } 273 285 /* " stop highlighting */ 274 286 287 <QUOTE,STRING>{escape_seq} { rm_underscore(); *strtext += std::string( yytext ); } 288 <QUOTE,STRING>[\\] { *strtext += std::string( yytext ); } // unknown escape character 289 275 290 /* punctuation */ 276 "[" { ASCIIOP_RETURN();}277 "]" { ASCIIOP_RETURN();}278 "(" { ASCIIOP_RETURN();}279 ")" { ASCIIOP_RETURN();}280 "{" { ASCIIOP_RETURN();}281 "}" { ASCIIOP_RETURN();}282 "," { ASCIIOP_RETURN();} /* also operator */283 ":" { ASCIIOP_RETURN();}284 ";" { ASCIIOP_RETURN();}285 "." { ASCIIOP_RETURN();} /* also operator */286 "..." { NAMEDOP_RETURN(ELLIPSIS);}287 288 /* alternative ANSI99 brackets, "<:" & "<:<:" handled by preprocessor */289 "<:" { RETURN_VAL('[');}290 ":>" { RETURN_VAL(']');}291 "<%" { RETURN_VAL('{');}292 "%>" { RETURN_VAL('}');}291 "[" { ASCIIOP_RETURN(); } 292 "]" { ASCIIOP_RETURN(); } 293 "(" { ASCIIOP_RETURN(); } 294 ")" { ASCIIOP_RETURN(); } 295 "{" { ASCIIOP_RETURN(); } 296 "}" { ASCIIOP_RETURN(); } 297 "," { ASCIIOP_RETURN(); } // also operator 298 ":" { ASCIIOP_RETURN(); } 299 ";" { ASCIIOP_RETURN(); } 300 "." { ASCIIOP_RETURN(); } // also operator 301 "..." { NAMEDOP_RETURN(ELLIPSIS); } 302 303 /* alternative C99 brackets, "<:" & "<:<:" handled by preprocessor */ 304 "<:" { RETURN_VAL('['); } 305 ":>" { RETURN_VAL(']'); } 306 "<%" { RETURN_VAL('{'); } 307 "%>" { RETURN_VAL('}'); } 293 308 294 309 /* operators */ 295 "!" { ASCIIOP_RETURN();}296 "+" { ASCIIOP_RETURN();}297 "-" { ASCIIOP_RETURN();}298 "*" { ASCIIOP_RETURN();}299 "/" { ASCIIOP_RETURN();}300 "%" { ASCIIOP_RETURN();}301 "^" { ASCIIOP_RETURN();}302 "~" { ASCIIOP_RETURN();}303 "&" { ASCIIOP_RETURN();}304 "|" { ASCIIOP_RETURN();}305 "<" { ASCIIOP_RETURN();}306 ">" { ASCIIOP_RETURN();}307 "=" { ASCIIOP_RETURN();}308 "?" { ASCIIOP_RETURN();}309 310 "++" { NAMEDOP_RETURN(ICR);}311 "--" { NAMEDOP_RETURN(DECR);}312 "==" { NAMEDOP_RETURN(EQ);}313 "!=" { NAMEDOP_RETURN(NE);}314 "<<" { NAMEDOP_RETURN(LS);}315 ">>" { NAMEDOP_RETURN(RS);}316 "<=" { NAMEDOP_RETURN(LE);}317 ">=" { NAMEDOP_RETURN(GE);}318 "&&" { NAMEDOP_RETURN(ANDAND);}319 "||" { NAMEDOP_RETURN(OROR);}320 "->" { NAMEDOP_RETURN(ARROW);}321 "+=" { NAMEDOP_RETURN(PLUSassign);}322 "-=" { NAMEDOP_RETURN(MINUSassign);}323 "*=" { NAMEDOP_RETURN(MULTassign);}324 "/=" { NAMEDOP_RETURN(DIVassign);}325 "%=" { NAMEDOP_RETURN(MODassign);}326 "&=" { NAMEDOP_RETURN(ANDassign);}327 "|=" { NAMEDOP_RETURN(ORassign);}328 "^=" { NAMEDOP_RETURN(ERassign);}329 "<<=" { NAMEDOP_RETURN(LSassign);}330 ">>=" { NAMEDOP_RETURN(RSassign);}310 "!" { ASCIIOP_RETURN(); } 311 "+" { ASCIIOP_RETURN(); } 312 "-" { ASCIIOP_RETURN(); } 313 "*" { ASCIIOP_RETURN(); } 314 "/" { ASCIIOP_RETURN(); } 315 "%" { ASCIIOP_RETURN(); } 316 "^" { ASCIIOP_RETURN(); } 317 "~" { ASCIIOP_RETURN(); } 318 "&" { ASCIIOP_RETURN(); } 319 "|" { ASCIIOP_RETURN(); } 320 "<" { ASCIIOP_RETURN(); } 321 ">" { ASCIIOP_RETURN(); } 322 "=" { ASCIIOP_RETURN(); } 323 "?" { ASCIIOP_RETURN(); } 324 325 "++" { NAMEDOP_RETURN(ICR); } 326 "--" { NAMEDOP_RETURN(DECR); } 327 "==" { NAMEDOP_RETURN(EQ); } 328 "!=" { NAMEDOP_RETURN(NE); } 329 "<<" { NAMEDOP_RETURN(LS); } 330 ">>" { NAMEDOP_RETURN(RS); } 331 "<=" { NAMEDOP_RETURN(LE); } 332 ">=" { NAMEDOP_RETURN(GE); } 333 "&&" { NAMEDOP_RETURN(ANDAND); } 334 "||" { NAMEDOP_RETURN(OROR); } 335 "->" { NAMEDOP_RETURN(ARROW); } 336 "+=" { NAMEDOP_RETURN(PLUSassign); } 337 "-=" { NAMEDOP_RETURN(MINUSassign); } 338 "*=" { NAMEDOP_RETURN(MULTassign); } 339 "/=" { NAMEDOP_RETURN(DIVassign); } 340 "%=" { NAMEDOP_RETURN(MODassign); } 341 "&=" { NAMEDOP_RETURN(ANDassign); } 342 "|=" { NAMEDOP_RETURN(ORassign); } 343 "^=" { NAMEDOP_RETURN(ERassign); } 344 "<<=" { NAMEDOP_RETURN(LSassign); } 345 ">>=" { NAMEDOP_RETURN(RSassign); } 331 346 332 347 /* CFA, operator identifier */ 333 {op_unary}"?" { IDENTIFIER_RETURN();} /* unary */334 "?"({op_unary_pre_post}|"()"|"[?]") { IDENTIFIER_RETURN();}335 "?"{op_binary_over}"?" { IDENTIFIER_RETURN();} /* binary */348 {op_unary}"?" { IDENTIFIER_RETURN(); } // unary 349 "?"({op_unary_pre_post}|"()"|"[?]") { IDENTIFIER_RETURN(); } 350 "?"{op_binary_over}"?" { IDENTIFIER_RETURN(); } // binary 336 351 /* 337 352 This rule handles ambiguous cases with operator identifiers, e.g., "int *?*?()", where the … … 365 380 // 1 or 2 character unary operator ? 366 381 int i = yytext[1] == '?' ? 1 : 2; 367 yyless( i ); / * put back characters up to first '?' */382 yyless( i ); // put back characters up to first '?' 368 383 if ( i > 1 ) { 369 384 NAMEDOP_RETURN( yytext[0] == '+' ? ICR : DECR ); … … 374 389 375 390 /* unknown characters */ 376 . { printf("unknown character(s):\"%s\" on line %d\n", yytext, yylineno);}391 . { printf("unknown character(s):\"%s\" on line %d\n", yytext, yylineno); } 377 392 378 393 %%
Note: See TracChangeset
for help on using the changeset viewer.