Changes in src/Parser/lex.cc [08061589:c1c1112]
- File:
-
- 1 edited
-
src/Parser/lex.cc (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/lex.cc
r08061589 rc1c1112 1468 1468 * Author : Peter A. Buhr 1469 1469 * Created On : Sat Sep 22 08:58:10 2001 1470 * Last Modified By : 1471 * Last Modified On : Sun Jul 31 07:19:3620161472 * Update Count : 4 591470 * Last Modified By : Peter A. Buhr 1471 * Last Modified On : Wed Aug 24 13:27:04 2016 1472 * Update Count : 487 1473 1473 */ 1474 1474 #line 20 "lex.ll" … … 1480 1480 1481 1481 #include <string> 1482 #include <cstdio> // FILENAME_MAX 1482 1483 1483 1484 #include "lex.h" … … 1491 1492 #define RETURN_LOCN(x) yylval.tok.loc.file = yyfilename; yylval.tok.loc.line = yylineno; return( x ) 1492 1493 #define RETURN_VAL(x) yylval.tok.str = new std::string( yytext ); RETURN_LOCN( x ) 1493 #define RETURN_CHAR(x) yylval.tok.str = NULL; RETURN_LOCN( x )1494 #define RETURN_CHAR(x) yylval.tok.str = nullptr; RETURN_LOCN( x ) 1494 1495 #define RETURN_STR(x) yylval.tok.str = strtext; RETURN_LOCN( x ) 1495 1496 1496 #define WHITE_RETURN(x) // do nothing1497 #define WHITE_RETURN(x) // do nothing 1497 1498 #define NEWLINE_RETURN() WHITE_RETURN( '\n' ) 1498 1499 #define ASCIIOP_RETURN() RETURN_CHAR( (int)yytext[0] ) // single character operator 1499 #define NAMEDOP_RETURN(x) RETURN_ VAL( x )// multichar operator, with a name1500 #define NAMEDOP_RETURN(x) RETURN_CHAR( x ) // multichar operator, with a name 1500 1501 #define NUMERIC_RETURN(x) rm_underscore(); RETURN_VAL( x ) // numeric constant 1501 1502 #define KEYWORD_RETURN(x) RETURN_CHAR( x ) // keyword … … 1531 1532 1532 1533 1533 #line 153 4"Parser/lex.cc"1534 #line 1535 "Parser/lex.cc" 1534 1535 1535 1536 #define INITIAL 0 … … 1723 1724 register int yy_act; 1724 1725 1725 #line 13 8"lex.ll"1726 #line 139 "lex.ll" 1726 1727 1727 1728 /* line directives */ 1728 #line 17 29"Parser/lex.cc"1729 #line 1730 "Parser/lex.cc" 1729 1730 1730 1731 if ( !(yy_init) ) … … 1823 1824 /* rule 1 can match eol */ 1824 1825 YY_RULE_SETUP 1825 #line 14 0"lex.ll"1826 #line 141 "lex.ll" 1826 1827 { 1827 1828 /* " stop highlighting */ 1829 static char filename[FILENAME_MAX]; // temporarily store current source-file name 1828 1830 char *end_num; 1829 1831 char *begin_string, *end_string; 1830 char *filename;1831 1832 long lineno, length; 1832 1833 lineno = strtol( yytext + 1, &end_num, 0 ); 1833 1834 begin_string = strchr( end_num, '"' ); 1834 if ( begin_string ) { 1835 end_string = strchr( begin_string + 1, '"' ); 1836 if ( end_string ) { 1837 length = end_string - begin_string - 1; 1838 filename = new char[ length + 1 ]; 1839 memcpy( filename, begin_string + 1, length ); 1840 filename[ length ] = '\0'; 1841 //std::cout << "file " << filename << " line " << lineno << std::endl; 1842 yylineno = lineno; 1843 yyfilename = filename; 1844 } // if 1835 if ( begin_string ) { // file name ? 1836 end_string = strchr( begin_string + 1, '"' ); // look for ending delimiter 1837 assert( end_string ); // closing quote ? 1838 length = end_string - begin_string - 1; // file-name length without quotes or sentinel 1839 assert( length < FILENAME_MAX ); // room for sentinel ? 1840 memcpy( &filename, begin_string + 1, length ); // copy file name from yytext 1841 filename[ length ] = '\0'; // terminate string with sentinel 1842 //std::cout << "file " << filename << " line " << lineno << std::endl; 1843 yylineno = lineno; 1844 yyfilename = filename; 1845 1845 } // if 1846 1846 } … … 2426 2426 YY_RULE_SETUP 2427 2427 #line 290 "lex.ll" 2428 { BEGIN QUOTE; rm_underscore(); strtext = new std::string ; *strtext += std::string( yytext); }2428 { BEGIN QUOTE; rm_underscore(); strtext = new std::string( yytext, yyleng ); } 2429 2429 YY_BREAK 2430 2430 case 116: 2431 2431 YY_RULE_SETUP 2432 2432 #line 291 "lex.ll" 2433 { *strtext += std::string( yytext); }2433 { strtext->append( yytext, yyleng ); } 2434 2434 YY_BREAK 2435 2435 case 117: … … 2437 2437 YY_RULE_SETUP 2438 2438 #line 292 "lex.ll" 2439 { BEGIN 0; *strtext += std::string( yytext); RETURN_STR(CHARACTERconstant); }2439 { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(CHARACTERconstant); } 2440 2440 YY_BREAK 2441 2441 /* ' stop highlighting */ … … 2444 2444 YY_RULE_SETUP 2445 2445 #line 296 "lex.ll" 2446 { BEGIN STRING; rm_underscore(); strtext = new std::string ; *strtext += std::string( yytext); }2446 { BEGIN STRING; rm_underscore(); strtext = new std::string( yytext, yyleng ); } 2447 2447 YY_BREAK 2448 2448 case 119: 2449 2449 YY_RULE_SETUP 2450 2450 #line 297 "lex.ll" 2451 { *strtext += std::string( yytext); }2451 { strtext->append( yytext, yyleng ); } 2452 2452 YY_BREAK 2453 2453 case 120: … … 2455 2455 YY_RULE_SETUP 2456 2456 #line 298 "lex.ll" 2457 { BEGIN 0; *strtext += std::string( yytext); RETURN_STR(STRINGliteral); }2457 { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(STRINGliteral); } 2458 2458 YY_BREAK 2459 2459 /* " stop highlighting */ … … 2462 2462 YY_RULE_SETUP 2463 2463 #line 302 "lex.ll" 2464 { rm_underscore(); *strtext += std::string( yytext); }2464 { rm_underscore(); strtext->append( yytext, yyleng ); } 2465 2465 YY_BREAK 2466 2466 case 122: … … 2473 2473 YY_RULE_SETUP 2474 2474 #line 304 "lex.ll" 2475 { *strtext += std::string( yytext); } // unknown escape character2475 { strtext->append( yytext, yyleng ); } // unknown escape character 2476 2476 YY_BREAK 2477 2477 /* punctuation */
Note:
See TracChangeset
for help on using the changeset viewer.