Changeset 930f69e for src/Parser/lex.ll


Ignore:
Timestamp:
Sep 10, 2017, 5:35:59 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, resolv-new, with_gc
Children:
de9285f
Parents:
0cc818b
Message:

fix lexing issue for floating-point numbers, and add "h", "hh", and "z" integral suffixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/lex.ll

    r0cc818b r930f69e  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Thu Aug 31 21:30:10 2017
    13  * Update Count     : 598
     12 * Last Modified On : Sun Sep 10 11:15:37 2017
     13 * Update Count     : 617
    1414 */
    1515
     
    9393                                // numeric constants, CFA: '_' in constant
    9494hex_quad {hex}("_"?{hex}){3}
    95 integer_suffix_opt ("_"?(([uU](("ll"|"LL"|[lL])[iI]|[iI]?("ll"|"LL"|[lL])?))|([iI](("ll"|"LL"|[lL])[uU]|[uU]?("ll"|"LL"|[lL])?))|(("ll"|"LL"|[lL])([iI][uU]|[uU]?[iI]?))))?
     95length ("ll"|"LL"|[lL])|("hh"|"HH"|[hH])
     96integer_suffix_opt ("_"?(([uU]({length}?[iI]?)|([iI]{length}))|([iI]({length}?[uU]?)|([uU]{length}))|({length}([iI]?[uU]?)|([uU][iI]))|[zZ]))?{user_suffix_opt}
    9697
    9798octal_digits ({octal})|({octal}({octal}|"_")*{octal})
    9899octal_prefix "0""_"?
    99 octal_constant (("0")|({octal_prefix}{octal_digits})){integer_suffix_opt}{user_suffix_opt}
     100octal_constant (("0")|({octal_prefix}{octal_digits})){integer_suffix_opt}
    100101
    101102nonzero_digits ({nonzero})|({nonzero}({decimal}|"_")*{decimal})
    102 decimal_constant {nonzero_digits}{integer_suffix_opt}{user_suffix_opt}
     103decimal_constant {nonzero_digits}{integer_suffix_opt}
    103104
    104105hex_digits ({hex})|({hex}({hex}|"_")*{hex})
    105106hex_prefix "0"[xX]"_"?
    106 hex_constant {hex_prefix}{hex_digits}{integer_suffix_opt}{user_suffix_opt}
     107hex_constant {hex_prefix}{hex_digits}{integer_suffix_opt}
    107108
    108109                                // GCC: D (double) and iI (imaginary) suffixes, and DL (long double)
    109 floating_suffix_opt ("_"?([fFdDlL][iI]?|[iI][lLfFdD]?|"DL"))?
     110floating_suffix_opt ("_"?(([fFdDlL]?[iI]?)|([iI][lLfFdD])|"DL"))?{user_suffix_opt}
    110111decimal_digits ({decimal})|({decimal}({decimal}|"_")*{decimal})
    111 real_decimal {decimal_digits}"."{exponent}?{floating_suffix_opt}{user_suffix_opt}
    112 real_fraction "."{decimal_digits}{exponent}?{floating_suffix_opt}{user_suffix_opt}
    113 real_constant {decimal_digits}{real_fraction}
    114112exponent "_"?[eE]"_"?[+-]?{decimal_digits}
    115 floating_constant (({real_constant}{exponent}?)|({decimal_digits}{exponent})){floating_suffix_opt}{user_suffix_opt}
     113floating_decimal {decimal_digits}"."{exponent}?{floating_suffix_opt}
     114floating_fraction "."{decimal_digits}{exponent}?{floating_suffix_opt}
     115floating_constant ({decimal_digits}{exponent}{floating_suffix_opt})|({decimal_digits}{floating_fraction})
    116116
    117117binary_exponent "_"?[pP]"_"?[+-]?{decimal_digits}
    118 hex_fractional_constant ({hex_digits}?"."{hex_digits})|({hex_digits}".")
    119 hex_floating_constant {hex_prefix}(({hex_fractional_constant}{binary_exponent})|({hex_digits}{binary_exponent})){floating_suffix_opt}
     118hex_floating_fraction ({hex_digits}?"."{hex_digits})|({hex_digits}".")
     119hex_floating_constant {hex_prefix}(({hex_floating_fraction}{binary_exponent})|({hex_digits}{binary_exponent})){floating_suffix_opt}
    120120
    121121                                // character escape sequence, GCC: \e => esc character
    122122simple_escape "\\"[abefnrtv'"?\\]
    123                                 // ' stop highlighting
     123                                // ' stop editor highlighting
    124124octal_escape "\\"{octal}("_"?{octal}){0,2}
    125125hex_escape "\\""x""_"?{hex_digits}
     
    154154                                /* line directives */
    155155^{h_white}*"#"{h_white}*[0-9]+{h_white}*["][^"\n]+["].*"\n" {
    156         /* " stop highlighting */
     156        /* " stop editor highlighting */
    157157        static char filename[FILENAME_MAX];                                     // temporarily store current source-file name
    158158        char *end_num;
     
    310310{octal_constant} { NUMERIC_RETURN(INTEGERconstant); }
    311311{hex_constant}  { NUMERIC_RETURN(INTEGERconstant); }
    312 {real_decimal}  { NUMERIC_RETURN(REALDECIMALconstant); } // must appear before floating_constant
    313 {real_fraction} { NUMERIC_RETURN(REALFRACTIONconstant); } // must appear before floating_constant
     312{floating_decimal}      { NUMERIC_RETURN(FLOATING_DECIMALconstant); } // must appear before floating_constant
     313{floating_fraction}     { NUMERIC_RETURN(FLOATING_FRACTIONconstant); } // must appear before floating_constant
    314314{floating_constant}     { NUMERIC_RETURN(FLOATINGconstant); }
    315315{hex_floating_constant} { NUMERIC_RETURN(FLOATINGconstant); }
     
    319319<QUOTE>[^'\\\n]* { strtext->append( yytext, yyleng ); }
    320320<QUOTE>['\n]{user_suffix_opt}   { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(CHARACTERconstant); }
    321                                 /* ' stop highlighting */
     321                                /* ' stop editor highlighting */
    322322
    323323                                /* string constant */
     
    325325<STRING>[^"\\\n]* { strtext->append( yytext, yyleng ); }
    326326<STRING>["\n]{user_suffix_opt}  { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(STRINGliteral); }
    327                                 /* " stop highlighting */
     327                                /* " stop editor highlighting */
    328328
    329329                                /* common character/string constant */
Note: See TracChangeset for help on using the changeset viewer.