Changeset f487962
- Timestamp:
- Aug 18, 2016, 10:37:38 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 8b7ee09
- Parents:
- 9b967914
- Location:
- src/Parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Parser/lex.cc ¶
r9b967914 rf487962 1469 1469 * Created On : Sat Sep 22 08:58:10 2001 1470 1470 * Last Modified By : Peter A. Buhr 1471 * Last Modified On : T ue Aug 16 22:34:3120161472 * Update Count : 4 601471 * Last Modified On : Thu Aug 18 22:17:30 2016 1472 * Update Count : 472 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" … … 1494 1495 #define RETURN_STR(x) yylval.tok.str = strtext; RETURN_LOCN( x ) 1495 1496 1496 #define WHITE_RETURN(x) 1497 #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[0]; 1845 1845 } // if 1846 1846 } -
TabularUnified src/Parser/lex.ll ¶
r9b967914 rf487962 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : T ue Aug 16 22:34:31201613 * Update Count : 4 6012 * Last Modified On : Thu Aug 18 22:17:30 2016 13 * Update Count : 472 14 14 */ 15 15 … … 25 25 26 26 #include <string> 27 #include <cstdio> // FILENAME_MAX 27 28 28 29 #include "lex.h" … … 39 40 #define RETURN_STR(x) yylval.tok.str = strtext; RETURN_LOCN( x ) 40 41 41 #define WHITE_RETURN(x) 42 #define WHITE_RETURN(x) // do nothing 42 43 #define NEWLINE_RETURN() WHITE_RETURN( '\n' ) 43 44 #define ASCIIOP_RETURN() RETURN_CHAR( (int)yytext[0] ) // single character operator 44 #define NAMEDOP_RETURN(x) RETURN_ VAL( x )// multichar operator, with a name45 #define NAMEDOP_RETURN(x) RETURN_CHAR( x ) // multichar operator, with a name 45 46 #define NUMERIC_RETURN(x) rm_underscore(); RETURN_VAL( x ) // numeric constant 46 47 #define KEYWORD_RETURN(x) RETURN_CHAR( x ) // keyword … … 140 141 ^{h_white}*"#"{h_white}*[0-9]+{h_white}*["][^"\n]+["].*"\n" { 141 142 /* " stop highlighting */ 143 static char *filename[FILENAME_MAX]; // temporarily store current source-file name 142 144 char *end_num; 143 145 char *begin_string, *end_string; 144 char *filename;145 146 long lineno, length; 146 147 lineno = strtol( yytext + 1, &end_num, 0 ); 147 148 begin_string = strchr( end_num, '"' ); 148 if ( begin_string ) { 149 end_string = strchr( begin_string + 1, '"' ); 150 if ( end_string ) { 151 length = end_string - begin_string - 1; 152 filename = new char[ length + 1 ]; 153 memcpy( filename, begin_string + 1, length ); 154 filename[ length ] = '\0'; 155 //std::cout << "file " << filename << " line " << lineno << std::endl; 156 yylineno = lineno; 157 yyfilename = filename; 158 } // if 149 if ( begin_string ) { // file name ? 150 end_string = strchr( begin_string + 1, '"' ); // look for ending delimiter 151 assert( end_string ); // closing quote ? 152 length = end_string - begin_string - 1; // file-name length without quotes or sentinel 153 assert( length < FILENAME_MAX ); // room for sentinel ? 154 memcpy( &filename, begin_string + 1, length ); // copy file name from yytext 155 filename[ length ] = '\0'; // terminate string with sentinel 156 //std::cout << "file " << filename << " line " << lineno << std::endl; 157 yylineno = lineno; 158 yyfilename = filename[0]; 159 159 } // if 160 160 }
Note: See TracChangeset
for help on using the changeset viewer.