Ignore:
Timestamp:
Aug 7, 2016, 9:47:37 AM (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, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
04273e9, d1625f8
Parents:
35f9114
Message:

more refactoring of parser code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r35f9114 r7bf7fb9  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug  5 15:06:44 2016
    13 // Update Count     : 1756
     12// Last Modified On : Sun Aug  7 09:37:48 2016
     13// Update Count     : 1764
    1414//
    1515
     
    6060std::stack< LinkageSpec::Type > linkageStack;
    6161TypedefTable typedefTable;
     62
     63void appendStr( std::string &to, std::string *from ) {
     64        // "abc" "def" "ghi" => "abcdefghi", remove new text from quotes and insert before last quote in old string.
     65        to.insert( to.length() - 1, from->substr( 1, from->length() - 2 ) );
     66} // appendStr
    6267%}
    6368
     
    304309constant:
    305310                // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant".
    306 INTEGERconstant                                                                 { $$ = makeConstantInteger( *$1 ); }
    307         | FLOATINGconstant                                                      { $$ = makeConstantFloat( *$1 ); }
    308         | CHARACTERconstant                                                     { $$ = makeConstantChar( *$1 ); }
     311INTEGERconstant                                                                 { $$ = build_constantInteger( *$1 ); }
     312        | FLOATINGconstant                                                      { $$ = build_constantFloat( *$1 ); }
     313        | CHARACTERconstant                                                     { $$ = build_constantChar( *$1 ); }
    309314        ;
    310315
     
    331336
    332337string_literal_list:                                                                    // juxtaposed strings are concatenated
    333         STRINGliteral                                                           { $$ = makeConstantStr( *$1 ); }
    334         | string_literal_list STRINGliteral                     { $$ = $1->appendstr( $2 ); }
     338        STRINGliteral                                                           { $$ = build_constantStr( *$1 ); }
     339        | string_literal_list STRINGliteral
     340                {
     341                        appendStr( $1->get_expr()->get_constant()->get_value(), $2 );
     342                        delete $2;                                                                      // allocated by lexer
     343                        $$ = $1;
     344                }
    335345        ;
    336346
Note: See TracChangeset for help on using the changeset viewer.