Changeset b5563e1 for src/Parser
- Timestamp:
- Mar 27, 2018, 10:21:32 AM (7 years ago)
- 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:
- 3d2b7bc
- Parents:
- a9b1b0c (diff), af1ed1ad (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. - Location:
- src/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cc
ra9b1b0c rb5563e1 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Mar 3 18:22:33201813 // Update Count : 79612 // Last Modified On : Thu Mar 22 11:57:39 2018 13 // Update Count : 801 14 14 // 15 15 … … 94 94 } // checkLNInt 95 95 96 static void sepNumeric( string & str, string & units ) {97 string::size_type posn = str.find_first_of( "`" );98 if ( posn != string::npos ) {99 units = "?" + str.substr( posn ); // extract units100 str.erase( posn ); // remove units101 } // if102 } // sepNumeric103 104 96 Expression * build_constantInteger( string & str ) { 105 97 static const BasicType::Kind kind[2][6] = { … … 108 100 { BasicType::ShortUnsignedInt, BasicType::UnsignedChar, BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt, BasicType::UnsignedInt128, }, 109 101 }; 110 111 string units;112 sepNumeric( str, units ); // separate constant from units113 102 114 103 bool dec = true, Unsigned = false; // decimal, unsigned constant … … 232 221 } // if 233 222 CLEANUP: 234 if ( units.length() != 0 ) {235 ret = new UntypedExpr( new NameExpr( units ), { ret } );236 } // if237 223 238 224 delete &str; // created by lex … … 268 254 }; 269 255 270 string units;271 sepNumeric( str, units ); // separate constant from units272 273 256 bool complx = false; // real, complex 274 257 int size = 1; // 0 => float, 1 => double, 2 => long double … … 303 286 if ( lnth != -1 ) { // explicit length ? 304 287 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ) ); 305 } // if306 if ( units.length() != 0 ) {307 ret = new UntypedExpr( new NameExpr( units ), { ret } );308 288 } // if 309 289 -
src/Parser/lex.ll
ra9b1b0c rb5563e1 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Sat Mar 3 18:38:16 201813 * Update Count : 6 4012 * Last Modified On : Thu Mar 22 16:47:06 2018 13 * Update Count : 668 14 14 */ 15 15 … … 54 54 55 55 void 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?) 57 57 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 67 59 if ( yytext[i] != '_' ) { 68 60 yytext[yyleng] = yytext[i]; … … 71 63 } // for 72 64 yytext[yyleng] = '\0'; 73 } 65 } // rm_underscore 74 66 75 67 // Stop warning due to incorrectly generated flex code. … … 90 82 attr_identifier "@"{identifier} 91 83 92 user_suffix_opt ("`"{identifier})?93 94 84 // numeric constants, CFA: '_' in constant 95 85 hex_quad {hex}("_"?{hex}){3} 96 86 size_opt (8|16|32|64|128)? 97 87 length ("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}88 integer_suffix_opt ("_"?(([uU]({length}?[iI]?)|([iI]{length}))|([iI]({length}?[uU]?)|([uU]{length}))|({length}([iI]?[uU]?)|([uU][iI]))|[zZ]))? 99 89 100 90 octal_digits ({octal})|({octal}({octal}|"_")*{octal}) … … 118 108 floating_length ([fFdDlL]|[lL]{floating_size}) 119 109 floating_suffix ({floating_length}?[iI]?)|([iI]{floating_length}) 120 floating_suffix_opt ("_"?({floating_suffix}|"DL"))? {user_suffix_opt}110 floating_suffix_opt ("_"?({floating_suffix}|"DL"))? 121 111 decimal_digits ({decimal})|({decimal}({decimal}|"_")*{decimal}) 122 112 floating_decimal {decimal_digits}"."{exponent}?{floating_suffix_opt} … … 125 115 126 116 binary_exponent "_"?[pP]"_"?[+-]?{decimal_digits} 127 hex_floating_suffix_opt ("_"?({floating_suffix}))? {user_suffix_opt}117 hex_floating_suffix_opt ("_"?({floating_suffix}))? 128 118 hex_floating_fraction ({hex_digits}?"."{hex_digits})|({hex_digits}".") 129 119 hex_floating_constant {hex_prefix}(({hex_floating_fraction}{binary_exponent})|({hex_digits}{binary_exponent})){hex_floating_suffix_opt} … … 314 304 /* identifier */ 315 305 {identifier} { IDENTIFIER_RETURN(); } 306 "`"{identifier}"`" { // CFA 307 yytext[yyleng - 1] = '\0'; yytext += 1; // SKULLDUGGERY: remove backquotes (ok to shorten?) 308 IDENTIFIER_RETURN(); 309 } 316 310 {attr_identifier} { ATTRIBUTE_RETURN(); } 317 "`" { BEGIN BKQUOTE; }318 <BKQUOTE>{identifier} { IDENTIFIER_RETURN(); }319 <BKQUOTE>"`" { BEGIN 0; }320 311 321 312 /* numeric constants */ … … 332 323 ({cwide_prefix}[_]?)?['] { BEGIN QUOTE; rm_underscore(); strtext = new string( yytext, yyleng ); } 333 324 <QUOTE>[^'\\\n]* { strtext->append( yytext, yyleng ); } 334 <QUOTE>['\n] {user_suffix_opt}{ BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(CHARACTERconstant); }325 <QUOTE>['\n] { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(CHARACTERconstant); } 335 326 /* ' stop editor highlighting */ 336 327 … … 338 329 ({swide_prefix}[_]?)?["] { BEGIN STRING; rm_underscore(); strtext = new string( yytext, yyleng ); } 339 330 <STRING>[^"\\\n]* { strtext->append( yytext, yyleng ); } 340 <STRING>["\n] {user_suffix_opt}{ BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(STRINGliteral); }331 <STRING>["\n] { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(STRINGliteral); } 341 332 /* " stop editor highlighting */ 342 333 … … 348 339 /* punctuation */ 349 340 "@" { ASCIIOP_RETURN(); } 341 "`" { ASCIIOP_RETURN(); } 350 342 "[" { ASCIIOP_RETURN(); } 351 343 "]" { ASCIIOP_RETURN(); } … … 412 404 "?"({op_unary_pre_post}|"()"|"[?]"|"{}") { IDENTIFIER_RETURN(); } 413 405 "^?{}" { IDENTIFIER_RETURN(); } 414 "?`"{identifier} { IDENTIFIER_RETURN(); } // unitoperator406 "?`"{identifier} { IDENTIFIER_RETURN(); } // postfix operator 415 407 "?"{op_binary_over}"?" { IDENTIFIER_RETURN(); } // binary 416 408 /* -
src/Parser/parser.yy
ra9b1b0c rb5563e1 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 16 17:24:44201813 // Update Count : 3 08112 // Last Modified On : Thu Mar 22 16:56:21 2018 13 // Update Count : 3125 14 14 // 15 15 … … 126 126 } // if 127 127 } // rebindForall 128 129 NameExpr * build_postfix_name( const string * name ) { 130 NameExpr * new_name = build_varref( new string( "?`" + *name ) ); 131 delete name; 132 return new_name; 133 } // build_postfix_name 128 134 129 135 bool forall = false; // aggregate have one or more forall qualifiers ? … … 480 486 | '(' compound_statement ')' // GCC, lambda expression 481 487 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); } 488 | constant '`' IDENTIFIER // CFA, postfix call 489 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); } 490 | string_literal '`' IDENTIFIER // CFA, postfix call 491 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); } 492 | IDENTIFIER '`' IDENTIFIER // CFA, postfix call 493 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( build_varref( $1 ) ) ) ); } 494 | tuple '`' IDENTIFIER // CFA, postfix call 495 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); } 496 | '(' comma_expression ')' '`' IDENTIFIER // CFA, postfix call 497 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 482 498 | type_name '.' no_attr_identifier // CFA, nested type 483 499 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
Note:
See TracChangeset
for help on using the changeset viewer.