Changeset 59db689 for src/Parser/lex.ll


Ignore:
Timestamp:
Jun 6, 2015, 11:38:58 PM (9 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, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
cd623a4
Parents:
a65d92e
Message:

constant types, first attempt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/lex.ll

    ra65d92e r59db689  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Wed Jun  3 22:24:07 2015
    13  * Update Count     : 336
     12 * Last Modified On : Fri Jun  5 17:50:17 2015
     13 * Update Count     : 373
    1414 */
    1515
     
    2727#include "lex.h"
    2828#include "ParseNode.h"
    29 #include "parser.h"                                                                     // YACC generated definitions based on C++ grammar
     29#include "parser.h"                                                                             // YACC generated definitions based on C++ grammar
    3030
    3131char *yyfilename;
     
    3434#define WHITE_RETURN(x)                                                                 // do nothing
    3535#define NEWLINE_RETURN()        WHITE_RETURN('\n')
    36 #define RETURN_VAL(x)           yylval.tok.str = new std::string(yytext); \
     36#define RETURN_VAL(x)           yylval.tok.str = new std::string( yytext ); \
    3737                                        yylval.tok.loc.file = yyfilename; \
    3838                                        yylval.tok.loc.line = yylineno; \
     
    114114hex_escape "\\""x""_"?{hex_digits}
    115115escape_seq {simple_escape}|{octal_escape}|{hex_escape}|{universal_char}
     116cwide_prefix "L"|"U"|"u"
     117swide_prefix {cwide_prefix}|"u8"
    116118
    117119                                // display/white-space characters
     
    275277"0"                             { NUMERIC_RETURN(ZERO); }                               // CFA
    276278"1"                             { NUMERIC_RETURN(ONE); }                                // CFA
    277 {decimal_constant}      { NUMERIC_RETURN(INTEGERconstant); }
    278 {octal_constant}        { NUMERIC_RETURN(INTEGERconstant); }
    279 {hex_constant}          { NUMERIC_RETURN(INTEGERconstant); }
     279{decimal_constant} { NUMERIC_RETURN(INTEGERconstant); }
     280{octal_constant} { NUMERIC_RETURN(INTEGERconstant); }
     281{hex_constant}  { NUMERIC_RETURN(INTEGERconstant); }
    280282{floating_constant}     { NUMERIC_RETURN(FLOATINGconstant); }
    281283{hex_floating_constant} { NUMERIC_RETURN(FLOATINGconstant); }
    282284
    283285                                /* character constant, allows empty value */
    284 "L"?"_"?[']             { BEGIN QUOTE; rm_underscore(); strtext = new std::string; *strtext += std::string( yytext ); }
     286({cwide_prefix}[_]?)?['] { BEGIN QUOTE; rm_underscore(); strtext = new std::string; *strtext += std::string( yytext ); }
    285287<QUOTE>[^'\\\n]* { *strtext += std::string( yytext ); }
    286288<QUOTE>['\n]    { BEGIN 0; *strtext += std::string( yytext); RETURN_STR(CHARACTERconstant); }
     
    288290
    289291                                /* string constant */
    290 "L"?"_"?["]             { BEGIN STRING; rm_underscore(); strtext = new std::string; *strtext += std::string( yytext ); }
     292({swide_prefix}[_]?)?["] { BEGIN STRING; rm_underscore(); strtext = new std::string; *strtext += std::string( yytext ); }
    291293<STRING>[^"\\\n]* { *strtext += std::string( yytext ); }
    292 <STRING>["\n]   { BEGIN 0; *strtext += std::string( yytext); RETURN_STR(STRINGliteral); }
     294<STRING>["\n]   { BEGIN 0; *strtext += std::string( yytext ); RETURN_STR(STRINGliteral); }
    293295                                /* " stop highlighting */
    294296
     297                                /* common character/string constant */
    295298<QUOTE,STRING>{escape_seq} { rm_underscore(); *strtext += std::string( yytext ); }
    296 <QUOTE,STRING>[\\]      { *strtext += std::string( yytext ); } // unknown escape character
     299<QUOTE,STRING>"\\"{h_white}*"\n" {}                                             // continuation
     300<QUOTE,STRING>"\\" { *strtext += std::string( yytext ); } // unknown escape character
    297301
    298302                                /* punctuation */
Note: See TracChangeset for help on using the changeset viewer.