Changes in src/Parser/lex.ll [5b2edbc:ad28abb]
- File:
-
- 1 edited
-
src/Parser/lex.ll (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/lex.ll
r5b2edbc rad28abb 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Tue Aug 22 22:43:39201713 * Update Count : 5 5812 * Last Modified On : Wed Aug 30 17:35:21 2017 13 * Update Count : 584 14 14 */ 15 15 … … 19 19 20 20 %{ 21 // Th islexer assumes the program has been preprocessed by cpp. Hence, all user level preprocessor directive have been21 // The lexer assumes the program has been preprocessed by cpp. Hence, all user level preprocessor directive have been 22 22 // performed and removed from the source. The only exceptions are preprocessor directives passed to the compiler (e.g., 23 23 // line-number directives) and C/C++ style comments, which are ignored. … … 25 25 //**************************** Includes and Defines **************************** 26 26 27 unsigned int column = 0; // position of the end of the last token parsed 28 #define YY_USER_ACTION column += yyleng; // trigger before each matching rule's action 29 27 30 #include <string> 28 31 #include <cstdio> // FILENAME_MAX 32 using namespace std; 29 33 30 34 #include "ParseNode.h" … … 32 36 33 37 char *yyfilename; 34 st d::string *strtext;// accumulate parts of character and string constant value38 string *strtext; // accumulate parts of character and string constant value 35 39 36 40 #define RETURN_LOCN(x) yylval.tok.loc.file = yyfilename; yylval.tok.loc.line = yylineno; return( x ) 37 #define RETURN_VAL(x) yylval.tok.str = new st d::string( yytext ); RETURN_LOCN( x )41 #define RETURN_VAL(x) yylval.tok.str = new string( yytext ); RETURN_LOCN( x ) 38 42 #define RETURN_CHAR(x) yylval.tok.str = nullptr; RETURN_LOCN( x ) 39 43 #define RETURN_STR(x) yylval.tok.str = strtext; RETURN_LOCN( x ) 40 44 41 45 #define WHITE_RETURN(x) // do nothing 42 #define NEWLINE_RETURN() WHITE_RETURN( '\n' )46 #define NEWLINE_RETURN() column = 0; WHITE_RETURN( '\n' ) 43 47 #define ASCIIOP_RETURN() RETURN_CHAR( (int)yytext[0] ) // single character operator 44 48 #define NAMEDOP_RETURN(x) RETURN_CHAR( x ) // multichar operator, with a name … … 154 158 memcpy( &filename, begin_string + 1, length ); // copy file name from yytext 155 159 filename[ length ] = '\0'; // terminate string with sentinel 156 // std::cout << "file " << filename << " line " << lineno << std::endl;160 //cout << "file " << filename << " line " << lineno << endl; 157 161 yylineno = lineno; 158 162 yyfilename = filename; … … 237 241 __label__ { KEYWORD_RETURN(LABEL); } // GCC 238 242 long { KEYWORD_RETURN(LONG); } 239 lvalue { KEYWORD_RETURN(LVALUE); } // CFA240 243 monitor { KEYWORD_RETURN(MONITOR); } // CFA 241 244 mutex { KEYWORD_RETURN(MUTEX); } // CFA … … 303 306 304 307 /* character constant, allows empty value */ 305 ({cwide_prefix}[_]?)?['] { BEGIN QUOTE; rm_underscore(); strtext = new st d::string( yytext, yyleng ); }308 ({cwide_prefix}[_]?)?['] { BEGIN QUOTE; rm_underscore(); strtext = new string( yytext, yyleng ); } 306 309 <QUOTE>[^'\\\n]* { strtext->append( yytext, yyleng ); } 307 310 <QUOTE>['\n] { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(CHARACTERconstant); } … … 309 312 310 313 /* string constant */ 311 ({swide_prefix}[_]?)?["] { BEGIN STRING; rm_underscore(); strtext = new st d::string( yytext, yyleng ); }314 ({swide_prefix}[_]?)?["] { BEGIN STRING; rm_underscore(); strtext = new string( yytext, yyleng ); } 312 315 <STRING>[^"\\\n]* { strtext->append( yytext, yyleng ); } 313 316 <STRING>["\n] { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(STRINGliteral); } … … 423 426 } 424 427 425 /* unknown character s*/426 . { printf("unknown character(s):\"%s\" on line %d\n", yytext, yylineno); }428 /* unknown character */ 429 . { yyerror( "unknown character" ); } 427 430 428 431 %% 432 // ----end of lexer---- 433 434 void yyerror( const char * errmsg ) { 435 cout << (yyfilename ? yyfilename : "*unknown file*") << ':' << yylineno << ':' << column - yyleng + 1 436 << ": " << SemanticError::error_str() << errmsg << " at token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl; 437 } 429 438 430 439 // Local Variables: //
Note:
See TracChangeset
for help on using the changeset viewer.