Changeset c1c1112 for src/Parser/lex.ll


Ignore:
Timestamp:
Aug 25, 2016, 9:14:06 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
4e2b9710
Parents:
2acf5fc
Message:

fix segment fault when printing syntax error, more refactoring of parser code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/lex.ll

    r2acf5fc rc1c1112  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Thu Aug 18 22:17:30 2016
    13  * Update Count     : 472
     12 * Last Modified On : Wed Aug 24 13:27:04 2016
     13 * Update Count     : 487
    1414 */
    1515
     
    141141^{h_white}*"#"{h_white}*[0-9]+{h_white}*["][^"\n]+["].*"\n" {
    142142        /* " stop highlighting */
    143         static char *filename[FILENAME_MAX];                            // temporarily store current source-file name
     143        static char filename[FILENAME_MAX];                                     // temporarily store current source-file name
    144144        char *end_num;
    145145        char *begin_string, *end_string;
     
    156156                //std::cout << "file " << filename << " line " << lineno << std::endl;
    157157                yylineno = lineno;
    158                 yyfilename = filename[0];
     158                yyfilename = filename;
    159159        } // if
    160160}
     
    288288
    289289                                /* character constant, allows empty value */
    290 ({cwide_prefix}[_]?)?['] { BEGIN QUOTE; rm_underscore(); strtext = new std::string; *strtext += std::string( yytext ); }
    291 <QUOTE>[^'\\\n]* { *strtext += std::string( yytext ); }
    292 <QUOTE>['\n]    { BEGIN 0; *strtext += std::string( yytext); RETURN_STR(CHARACTERconstant); }
     290({cwide_prefix}[_]?)?['] { BEGIN QUOTE; rm_underscore(); strtext = new std::string( yytext, yyleng ); }
     291<QUOTE>[^'\\\n]* { strtext->append( yytext, yyleng ); }
     292<QUOTE>['\n]    { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(CHARACTERconstant); }
    293293                                /* ' stop highlighting */
    294294
    295295                                /* string constant */
    296 ({swide_prefix}[_]?)?["] { BEGIN STRING; rm_underscore(); strtext = new std::string; *strtext += std::string( yytext ); }
    297 <STRING>[^"\\\n]* { *strtext += std::string( yytext ); }
    298 <STRING>["\n]   { BEGIN 0; *strtext += std::string( yytext ); RETURN_STR(STRINGliteral); }
     296({swide_prefix}[_]?)?["] { BEGIN STRING; rm_underscore(); strtext = new std::string( yytext, yyleng ); }
     297<STRING>[^"\\\n]* { strtext->append( yytext, yyleng ); }
     298<STRING>["\n]   { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(STRINGliteral); }
    299299                                /* " stop highlighting */
    300300
    301301                                /* common character/string constant */
    302 <QUOTE,STRING>{escape_seq} { rm_underscore(); *strtext += std::string( yytext ); }
     302<QUOTE,STRING>{escape_seq} { rm_underscore(); strtext->append( yytext, yyleng ); }
    303303<QUOTE,STRING>"\\"{h_white}*"\n" {}                                             // continuation (ALSO HANDLED BY CPP)
    304 <QUOTE,STRING>"\\" { *strtext += std::string( yytext ); } // unknown escape character
     304<QUOTE,STRING>"\\" { strtext->append( yytext, yyleng ); } // unknown escape character
    305305
    306306                                /* punctuation */
Note: See TracChangeset for help on using the changeset viewer.