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