Changeset 32cab5b for src/Parser/lex.ll


Ignore:
Timestamp:
Apr 17, 2018, 12:01:09 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, 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, with_gc
Children:
3265399
Parents:
b2fe1c9 (diff), 81bb114 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/lex.ll

    rb2fe1c9 r32cab5b  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Sat Mar  3 18:38:16 2018
    13  * Update Count     : 640
     12 * Last Modified On : Fri Apr  6 15:16:15 2018
     13 * Update Count     : 670
    1414 */
    1515
     
    5454
    5555void rm_underscore() {
    56         // Remove underscores in numeric constant by copying the non-underscore characters to the front of the string.
     56        // SKULLDUGGERY: remove underscores (ok to shorten?)
    5757        yyleng = 0;
    58         for ( int i = 0; yytext[i] != '\0'; i += 1 ) {
    59                 if ( yytext[i] == '`' ) {
    60                         // copy user suffix
    61                         for ( ; yytext[i] != '\0'; i += 1 ) {
    62                                 yytext[yyleng] = yytext[i];
    63                                 yyleng += 1;
    64                         } // for
    65                         break;
    66                 } // if
     58        for ( int i = 0; yytext[i] != '\0'; i += 1 ) {          // copying non-underscore characters to front of string
    6759                if ( yytext[i] != '_' ) {
    6860                        yytext[yyleng] = yytext[i];
     
    7163        } // for
    7264        yytext[yyleng] = '\0';
    73 }
     65} // rm_underscore
    7466
    7567// Stop warning due to incorrectly generated flex code.
     
    9082attr_identifier "@"{identifier}
    9183
    92 user_suffix_opt ("`"{identifier})?
    93 
    9484                                // numeric constants, CFA: '_' in constant
    9585hex_quad {hex}("_"?{hex}){3}
    9686size_opt (8|16|32|64|128)?
    9787length ("ll"|"LL"|[lL]{size_opt})|("hh"|"HH"|[hH])
    98 integer_suffix_opt ("_"?(([uU]({length}?[iI]?)|([iI]{length}))|([iI]({length}?[uU]?)|([uU]{length}))|({length}([iI]?[uU]?)|([uU][iI]))|[zZ]))?{user_suffix_opt}
     88integer_suffix_opt ("_"?(([uU]({length}?[iI]?)|([iI]{length}))|([iI]({length}?[uU]?)|([uU]{length}))|({length}([iI]?[uU]?)|([uU][iI]))|[zZ]))?
    9989
    10090octal_digits ({octal})|({octal}({octal}|"_")*{octal})
     
    118108floating_length ([fFdDlL]|[lL]{floating_size})
    119109floating_suffix ({floating_length}?[iI]?)|([iI]{floating_length})
    120 floating_suffix_opt ("_"?({floating_suffix}|"DL"))?{user_suffix_opt}
     110floating_suffix_opt ("_"?({floating_suffix}|"DL"))?
    121111decimal_digits ({decimal})|({decimal}({decimal}|"_")*{decimal})
    122112floating_decimal {decimal_digits}"."{exponent}?{floating_suffix_opt}
     
    125115
    126116binary_exponent "_"?[pP]"_"?[+-]?{decimal_digits}
    127 hex_floating_suffix_opt ("_"?({floating_suffix}))?{user_suffix_opt}
     117hex_floating_suffix_opt ("_"?({floating_suffix}))?
    128118hex_floating_fraction ({hex_digits}?"."{hex_digits})|({hex_digits}".")
    129119hex_floating_constant {hex_prefix}(({hex_floating_fraction}{binary_exponent})|({hex_digits}{binary_exponent})){hex_floating_suffix_opt}
     
    208198__asm                   { KEYWORD_RETURN(ASM); }                                // GCC
    209199__asm__                 { KEYWORD_RETURN(ASM); }                                // GCC
    210 _At                             { KEYWORD_RETURN(AT); }                                 // CFA
    211200_Atomic                 { KEYWORD_RETURN(ATOMIC); }                             // C11
    212201__attribute             { KEYWORD_RETURN(ATTRIBUTE); }                  // GCC
     
    239228exception               { KEYWORD_RETURN(EXCEPTION); }                  // CFA
    240229extern                  { KEYWORD_RETURN(EXTERN); }
     230fallthrough             { KEYWORD_RETURN(FALLTHROUGH); }                // CFA
    241231fallthru                { KEYWORD_RETURN(FALLTHRU); }                   // CFA
    242 fallthrough             { KEYWORD_RETURN(FALLTHROUGH); }                // CFA
    243232finally                 { KEYWORD_RETURN(FINALLY); }                    // CFA
    244233float                   { KEYWORD_RETURN(FLOAT); }
     
    270259__builtin_offsetof { KEYWORD_RETURN(OFFSETOF); }                // GCC
    271260one_t                   { NUMERIC_RETURN(ONE_T); }                              // CFA
     261or                              { QKEYWORD_RETURN(WOR); }                               // CFA
    272262otype                   { KEYWORD_RETURN(OTYPE); }                              // CFA
    273263register                { KEYWORD_RETURN(REGISTER); }
     
    306296__volatile__    { KEYWORD_RETURN(VOLATILE); }                   // GCC
    307297waitfor                 { KEYWORD_RETURN(WAITFOR); }
    308 or                              { QKEYWORD_RETURN(WOR); }                               // CFA
    309298when                    { KEYWORD_RETURN(WHEN); }
    310299while                   { KEYWORD_RETURN(WHILE); }
     
    314303                                /* identifier */
    315304{identifier}    { IDENTIFIER_RETURN(); }
     305"`"{identifier}"`" {                                                                    // CFA
     306        yytext[yyleng - 1] = '\0'; yytext += 1;                         // SKULLDUGGERY: remove backquotes (ok to shorten?)
     307        IDENTIFIER_RETURN();
     308}
    316309{attr_identifier} { ATTRIBUTE_RETURN(); }
    317 "`"                             { BEGIN BKQUOTE; }
    318 <BKQUOTE>{identifier} { IDENTIFIER_RETURN(); }
    319 <BKQUOTE>"`"    { BEGIN 0; }
    320310
    321311                                /* numeric constants */
     
    332322({cwide_prefix}[_]?)?['] { BEGIN QUOTE; rm_underscore(); strtext = new string( yytext, yyleng ); }
    333323<QUOTE>[^'\\\n]* { strtext->append( yytext, yyleng ); }
    334 <QUOTE>['\n]{user_suffix_opt}   { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(CHARACTERconstant); }
     324<QUOTE>['\n]    { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(CHARACTERconstant); }
    335325                                /* ' stop editor highlighting */
    336326
     
    338328({swide_prefix}[_]?)?["] { BEGIN STRING; rm_underscore(); strtext = new string( yytext, yyleng ); }
    339329<STRING>[^"\\\n]* { strtext->append( yytext, yyleng ); }
    340 <STRING>["\n]{user_suffix_opt}  { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(STRINGliteral); }
     330<STRING>["\n]   { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(STRINGliteral); }
    341331                                /* " stop editor highlighting */
    342332
     
    348338                                /* punctuation */
    349339"@"                             { ASCIIOP_RETURN(); }
     340"`"                             { ASCIIOP_RETURN(); }
    350341"["                             { ASCIIOP_RETURN(); }
    351342"]"                             { ASCIIOP_RETURN(); }
     
    412403"?"({op_unary_pre_post}|"()"|"[?]"|"{}") { IDENTIFIER_RETURN(); }
    413404"^?{}"                  { IDENTIFIER_RETURN(); }
    414 "?`"{identifier} { IDENTIFIER_RETURN(); }                               // unit operator
     405"?`"{identifier} { IDENTIFIER_RETURN(); }                               // postfix operator
    415406"?"{op_binary_over}"?"  { IDENTIFIER_RETURN(); }                // binary
    416407        /*
Note: See TracChangeset for help on using the changeset viewer.