Ignore:
Timestamp:
Sep 29, 2016, 10:48:09 AM (9 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, resolv-new, with_gc
Children:
7e10773
Parents:
7b69174 (diff), 4b1fd2c (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/parser.yy

    r7b69174 raee7e35  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 12 17:29:45 2016
    13 // Update Count     : 1969
     12// Last Modified On : Sat Sep 24 12:16:53 2016
     13// Update Count     : 1992
    1414//
    1515
     
    5454#include "TypeData.h"
    5555#include "LinkageSpec.h"
     56using namespace std;
    5657
    5758extern DeclarationNode * parseTree;
     
    5960extern TypedefTable typedefTable;
    6061
    61 std::stack< LinkageSpec::Spec > linkageStack;
    62 
    63 void appendStr( std::string *to, std::string *from ) {
     62stack< LinkageSpec::Spec > linkageStack;
     63
     64void appendStr( string *to, string *from ) {
    6465        // "abc" "def" "ghi" => "abcdefghi", remove new text from quotes and insert before last quote in old string.
    6566        to->insert( to->length() - 1, from->substr( 1, from->length() - 2 ) );
     
    359360                { $$ = $2; }
    360361        | '(' compound_statement ')'                                            // GCC, lambda expression
    361         { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
     362                { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
    362363        ;
    363364
     
    389390                {
    390391                        Token fn;
    391                         fn.str = new std::string( "?{}" ); // location undefined - use location of '{'?
     392                        fn.str = new std::string( "?{}" );                      // location undefined - use location of '{'?
    392393                        $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
    393394                }
     
    666667                {
    667668                        Token fn;
    668                         fn.str = new std::string( "^?{}" ); // location undefined
     669                        fn.str = new string( "^?{}" );                          // location undefined
    669670                        $$ = new StatementNode( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) ) ) );
    670671                }
     
    896897                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
    897898        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    898         { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     899                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
    899900        | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    900901                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     
    968969                { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); }
    969970        | '[' constant_expression ']' string_literal '(' constant_expression ')'
    970         { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
     971                { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
    971972        ;
    972973
     
    14671468aggregate_name:
    14681469        aggregate_key '{' field_declaration_list '}'
    1469                 { $$ = DeclarationNode::newAggregate( $1, 0, 0, $3, true ); }
     1470                { $$ = DeclarationNode::newAggregate( $1, nullptr, nullptr, $3, true ); }
    14701471        | aggregate_key no_attr_identifier_or_type_name
    14711472                {
    14721473                        typedefTable.makeTypedef( *$2 );
    1473                         $$ = DeclarationNode::newAggregate( $1, $2, 0, 0, false );
     1474                        $$ = DeclarationNode::newAggregate( $1, $2, nullptr, nullptr, false );
    14741475                }
    14751476        | aggregate_key no_attr_identifier_or_type_name
    14761477                { typedefTable.makeTypedef( *$2 ); }
    14771478                '{' field_declaration_list '}'
    1478                 { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5, true ); }
     1479                { $$ = DeclarationNode::newAggregate( $1, $2, nullptr, $5, true ); }
    14791480        | aggregate_key '(' type_name_list ')' '{' field_declaration_list '}' // CFA
    1480                 { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6, false ); }
     1481                { $$ = DeclarationNode::newAggregate( $1, nullptr, $3, $6, false ); }
    14811482        | aggregate_key typegen_name                                            // CFA, S/R conflict
    14821483                { $$ = $2; }
     
    15591560enum_name:
    15601561        enum_key '{' enumerator_list comma_opt '}'
    1561                 { $$ = DeclarationNode::newEnum( 0, $3 ); }
     1562                { $$ = DeclarationNode::newEnum( nullptr, $3 ); }
    15621563        | enum_key no_attr_identifier_or_type_name
    15631564                {
     
    25202521abstract_function:
    25212522        '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    2522                 { $$ = DeclarationNode::newFunction( 0, 0, $3, 0 ); }
     2523                { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
    25232524        | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    25242525                { $$ = $2->addParamList( $6 ); }
     
    25892590abstract_parameter_function:
    25902591        '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    2591                 { $$ = DeclarationNode::newFunction( 0, 0, $3, 0 ); }
     2592                { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
    25922593        | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    25932594                { $$ = $2->addParamList( $6 ); }
     
    27932794                // empty (void) function return type.
    27942795        '[' ']' type_specifier
    2795                 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2796                { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    27962797        | '[' ']' multi_array_dimension type_specifier
    2797                 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2798                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    27982799        | multi_array_dimension type_specifier
    27992800                { $$ = $2->addNewArray( $1 ); }
    28002801        | '[' ']' new_abstract_ptr
    2801                 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2802                { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    28022803        | '[' ']' multi_array_dimension new_abstract_ptr
    2803                 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2804                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    28042805        | multi_array_dimension new_abstract_ptr
    28052806                { $$ = $2->addNewArray( $1 ); }
     
    28132814new_abstract_function:                                                                  // CFA
    28142815        '[' ']' '(' new_parameter_type_list_opt ')'
    2815                 { $$ = DeclarationNode::newFunction( 0, DeclarationNode::newTuple( 0 ), $4, 0 ); }
     2816                { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); }
    28162817        | new_abstract_tuple '(' push new_parameter_type_list_opt pop ')'
    2817                 { $$ = DeclarationNode::newFunction( 0, $1, $4, 0 ); }
     2818                { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
    28182819        | new_function_return '(' push new_parameter_type_list_opt pop ')'
    2819                 { $$ = DeclarationNode::newFunction( 0, $1, $4, 0 ); }
     2820                { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
    28202821        ;
    28212822
     
    28522853
    28532854void yyerror( const char * ) {
    2854         std::cout << "Error ";
     2855        cout << "Error ";
    28552856        if ( yyfilename ) {
    2856                 std::cout << "in file " << yyfilename << " ";
     2857                cout << "in file " << yyfilename << " ";
    28572858        } // if
    2858         std::cout << "at line " << yylineno << " reading token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" << std::endl;
     2859        cout << "at line " << yylineno << " reading token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" << endl;
    28592860}
    28602861
Note: See TracChangeset for help on using the changeset viewer.