Changeset 4a7d895 for src/Parser/lex.ll
- Timestamp:
- Aug 20, 2016, 5:33:07 AM (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:
- 80722d0
- Parents:
- 7b1bfc5 (diff), 2037f82 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
src/Parser/lex.ll (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/lex.ll
r7b1bfc5 r4a7d895 9 9 * Author : Peter A. Buhr 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 * Last Modified By : 12 * Last Modified On : Sun Jul 31 07:19:36201613 * Update Count : 4 5911 * Last Modified By : Peter A. Buhr 12 * 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" … … 36 37 #define RETURN_LOCN(x) yylval.tok.loc.file = yyfilename; yylval.tok.loc.line = yylineno; return( x ) 37 38 #define RETURN_VAL(x) yylval.tok.str = new std::string( yytext ); RETURN_LOCN( x ) 38 #define RETURN_CHAR(x) yylval.tok.str = NULL; RETURN_LOCN( x )39 #define RETURN_CHAR(x) yylval.tok.str = nullptr; RETURN_LOCN( x ) 39 40 #define RETURN_STR(x) yylval.tok.str = strtext; RETURN_LOCN( x ) 40 41 41 #define WHITE_RETURN(x) // do nothing42 #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.