Changeset 8e4aa05 for src


Ignore:
Timestamp:
Mar 4, 2021, 7:40:25 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
77d601f
Parents:
342af53 (diff), a5040fe (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

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/lex.ll

    r342af53 r8e4aa05  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Tue Oct  6 18:15:41 2020
    13  * Update Count     : 743
     12 * Last Modified On : Wed Feb 17 08:38:13 2021
     13 * Update Count     : 752
    1414 */
    1515
     
    221221break                   { KEYWORD_RETURN(BREAK); }
    222222case                    { KEYWORD_RETURN(CASE); }
    223 catch                   { KEYWORD_RETURN(CATCH); }                              // CFA
    224 catchResume             { KEYWORD_RETURN(CATCHRESUME); }                // CFA
     223catch                   { QKEYWORD_RETURN(CATCH); }                             // CFA
     224catchResume             { QKEYWORD_RETURN(CATCHRESUME); }               // CFA
    225225char                    { KEYWORD_RETURN(CHAR); }
    226226choose                  { KEYWORD_RETURN(CHOOSE); }                             // CFA
     
    247247fallthrough             { KEYWORD_RETURN(FALLTHROUGH); }                // CFA
    248248fallthru                { KEYWORD_RETURN(FALLTHRU); }                   // CFA
    249 finally                 { KEYWORD_RETURN(FINALLY); }                    // CFA
     249finally                 { QKEYWORD_RETURN(FINALLY); }                   // CFA
     250fixup                   { QKEYWORD_RETURN(FIXUP); }                             // CFA
    250251float                   { KEYWORD_RETURN(FLOAT); }
    251252__float80               { KEYWORD_RETURN(uuFLOAT80); }                  // GCC
     
    287288or                              { QKEYWORD_RETURN(WOR); }                               // CFA
    288289otype                   { KEYWORD_RETURN(OTYPE); }                              // CFA
     290recover                 { QKEYWORD_RETURN(RECOVER); }                   // CFA
    289291register                { KEYWORD_RETURN(REGISTER); }
     292report                  { KEYWORD_RETURN(THROWRESUME); }                // CFA
    290293restrict                { KEYWORD_RETURN(RESTRICT); }                   // C99
    291294__restrict              { KEYWORD_RETURN(RESTRICT); }                   // GCC
     
    324327__volatile              { KEYWORD_RETURN(VOLATILE); }                   // GCC
    325328__volatile__    { KEYWORD_RETURN(VOLATILE); }                   // GCC
    326 waitfor                 { KEYWORD_RETURN(WAITFOR); }
    327 when                    { KEYWORD_RETURN(WHEN); }
     329waitfor                 { KEYWORD_RETURN(WAITFOR); }                    // CFA
     330when                    { KEYWORD_RETURN(WHEN); }                               // CFA
    328331while                   { KEYWORD_RETURN(WHILE); }
    329332with                    { KEYWORD_RETURN(WITH); }                               // CFA
  • src/Parser/parser.yy

    r342af53 r8e4aa05  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan 11 21:32:10 2021
    13 // Update Count     : 4633
     12// Last Modified On : Wed Feb 17 09:03:07 2021
     13// Update Count     : 4722
    1414//
    1515
     
    4141
    4242%{
    43 #define YYDEBUG_LEXER_TEXT (yylval)                                             // lexer loads this up each time
     43#define YYDEBUG_LEXER_TEXT( yylval )                                    // lexer loads this up each time
    4444#define YYDEBUG 1                                                                               // get the pretty debugging code to compile
    4545#define YYERROR_VERBOSE                                                                 // more information in syntax errors
     
    6363extern TypedefTable typedefTable;
    6464
    65 stack< LinkageSpec::Spec > linkageStack;
     65stack<LinkageSpec::Spec> linkageStack;
    6666
    6767bool appendStr( string & to, string & from ) {
     
    187187        ConstantExpr * constant = dynamic_cast<ConstantExpr *>(type->expr.get());
    188188        if ( constant && (constant->get_constant()->get_value() == "0" || constant->get_constant()->get_value() == "1") ) {
    189         type = new ExpressionNode( new CastExpr( maybeMoveBuild< Expression >(type), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) );
     189                type = new ExpressionNode( new CastExpr( maybeMoveBuild<Expression>(type), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) );
    190190        } // if
    191191        return new ForCtrl(
     
    282282%token ATTRIBUTE EXTENSION                                                              // GCC
    283283%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
    284 %token CHOOSE DISABLE ENABLE FALLTHRU FALLTHROUGH TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH WHEN WAITFOR // CFA
     284%token CHOOSE DISABLE ENABLE FALLTHRU FALLTHROUGH TRY THROW THROWRESUME AT WITH WHEN WAITFOR // CFA
    285285%token ASM                                                                                              // C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
    286286%token ALIGNAS ALIGNOF GENERIC STATICASSERT                             // C11
    287287
    288288// names and constants: lexer differentiates between identifier and typedef names
    289 %token<tok> IDENTIFIER                  QUOTED_IDENTIFIER               TYPEDEFname                             TYPEGENname
    290 %token<tok> TIMEOUT                             WOR
    291 %token<tok> INTEGERconstant             CHARACTERconstant               STRINGliteral
     289%token<tok> IDENTIFIER          QUOTED_IDENTIFIER       TYPEDEFname             TYPEGENname
     290%token<tok> TIMEOUT                     WOR                                     CATCH                   RECOVER                 CATCHRESUME             FIXUP           FINALLY         // CFA
     291%token<tok> INTEGERconstant     CHARACTERconstant       STRINGliteral
    292292%token<tok> DIRECTIVE
    293293// Floating point constant is broken into three kinds of tokens because of the ambiguity with tuple indexing and
     
    440440
    441441%type<decl> type_qualifier type_qualifier_name forall type_qualifier_list_opt type_qualifier_list
    442 %type<decl> type_specifier type_specifier_nobody
     442%type<decl> type_specifier type_specifier_nobody enum_specifier_nobody
    443443
    444444%type<decl> variable_declarator variable_ptr variable_array variable_function
    445445%type<decl> variable_abstract_declarator variable_abstract_ptr variable_abstract_array variable_abstract_function
    446446
    447 %type<decl> attribute_list_opt attribute_list attribute_name_list attribute attribute_name
     447%type<decl> attribute_list_opt attribute_list attribute_opt attribute attribute_name_list attribute_name
    448448
    449449// initializers
     
    462462// Order of these lines matters (low-to-high precedence). THEN is left associative over WOR/TIMEOUT/ELSE, WOR is left
    463463// associative over TIMEOUT/ELSE, and TIMEOUT is left associative over ELSE.
    464 %precedence THEN        // rule precedence for IF/WAITFOR statement
    465 %precedence WOR         // token precedence for start of WOR in WAITFOR statement
    466 %precedence TIMEOUT     // token precedence for start of TIMEOUT in WAITFOR statement
    467 %precedence ELSE        // token precedence for start of else clause in IF/WAITFOR statement
     464%precedence THEN                // rule precedence for IF/WAITFOR statement
     465%precedence WOR                 // token precedence for start of WOR in WAITFOR statement
     466%precedence TIMEOUT             // token precedence for start of TIMEOUT in WAITFOR statement
     467%precedence CATCH               // token precedence for start of TIMEOUT in WAITFOR statement
     468%precedence RECOVER             // token precedence for start of TIMEOUT in WAITFOR statement
     469%precedence CATCHRESUME // token precedence for start of TIMEOUT in WAITFOR statement
     470%precedence FIXUP               // token precedence for start of TIMEOUT in WAITFOR statement
     471%precedence FINALLY             // token precedence for start of TIMEOUT in WAITFOR statement
     472%precedence ELSE                // token precedence for start of else clause in IF/WAITFOR statement
     473
    468474
    469475// Handle shift/reduce conflict for generic type by shifting the '(' token. For example, this string is ambiguous:
     
    544550        TIMEOUT
    545551        | WOR
     552        | CATCH
     553        | RECOVER
     554        | CATCHRESUME
     555        | FIXUP
     556        | FINALLY
    546557        ;
    547558
     
    578589                { $$ = $2; }
    579590        | '(' compound_statement ')'                                            // GCC, lambda expression
    580                 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); }
     591                { $$ = new ExpressionNode( new StmtExpr( dynamic_cast<CompoundStmt *>(maybeMoveBuild<Statement>($2) ) ) ); }
    581592        | type_name '.' identifier                                                      // CFA, nested type
    582593                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
     
    610621                {
    611622                        // create a GenericExpr wrapper with one association pair
    612                         $$ = new GenericExpr( nullptr, { { maybeMoveBuildType($1), maybeMoveBuild<Expression>($3) } } );
     623                        $$ = new GenericExpr( nullptr, { { maybeMoveBuildType($1), maybeMoveBuild<Expression>( $3 ) } } );
    613624                }
    614625        | DEFAULT ':' assignment_expression
    615                 { $$ = new GenericExpr( nullptr, { { maybeMoveBuild<Expression>($3) } } ); }
     626                { $$ = new GenericExpr( nullptr, { { maybeMoveBuild<Expression>( $3 ) } } ); }
    616627        ;
    617628
    618629postfix_expression:
    619630        primary_expression
     631        | postfix_expression '[' assignment_expression ',' comma_expression ']'
     632                // { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_binary_val( OperKinds::Index, $3, $5 ) ) ) ); }
     633                { SemanticError( yylloc, "New array subscript is currently unimplemented." ); $$ = nullptr; }
    620634        | postfix_expression '[' assignment_expression ']'
    621635                // CFA, comma_expression disallowed in this context because it results in a common user error: subscripting a
     
    743757                        switch ( $1 ) {
    744758                          case OperKinds::AddressOf:
    745                                 $$ = new ExpressionNode( new AddressExpr( maybeMoveBuild< Expression >( $2 ) ) );
     759                                $$ = new ExpressionNode( new AddressExpr( maybeMoveBuild<Expression>( $2 ) ) );
    746760                                break;
    747761                          case OperKinds::PointTo:
     
    749763                                break;
    750764                          case OperKinds::And:
    751                                 $$ = new ExpressionNode( new AddressExpr( new AddressExpr( maybeMoveBuild< Expression >( $2 ) ) ) );
     765                                $$ = new ExpressionNode( new AddressExpr( new AddressExpr( maybeMoveBuild<Expression>( $2 ) ) ) );
    752766                                break;
    753767                          default:
     
    762776                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::Decr, $2 ) ); }
    763777        | SIZEOF unary_expression
    764                 { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuild< Expression >( $2 ) ) ); }
     778                { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuild<Expression>( $2 ) ) ); }
    765779        | SIZEOF '(' type_no_function ')'
    766780                { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuildType( $3 ) ) ); }
    767781        | ALIGNOF unary_expression                                                      // GCC, variable alignment
    768                 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuild< Expression >( $2 ) ) ); }
     782                { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuild<Expression>( $2 ) ) ); }
    769783        | ALIGNOF '(' type_no_function ')'                                      // GCC, type alignment
    770784                { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); }
     
    794808                { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
    795809        | '(' VIRTUAL ')' cast_expression                                       // CFA
    796                 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); }
     810                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild<Expression>( $4 ), maybeMoveBuildType( nullptr ) ) ); }
    797811        | '(' VIRTUAL type_no_function ')' cast_expression      // CFA
    798                 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $5 ), maybeMoveBuildType( $3 ) ) ); }
     812                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild<Expression>( $5 ), maybeMoveBuildType( $3 ) ) ); }
    799813        | '(' RETURN type_no_function ')' cast_expression       // CFA
    800814                { SemanticError( yylloc, "Return cast is currently unimplemented." ); $$ = nullptr; }
     
    977991        assignment_expression
    978992        | comma_expression ',' assignment_expression
    979                 { $$ = new ExpressionNode( new CommaExpr( maybeMoveBuild< Expression >( $1 ), maybeMoveBuild< Expression >( $3 ) ) ); }
     993                { $$ = new ExpressionNode( new CommaExpr( maybeMoveBuild<Expression>( $1 ), maybeMoveBuild<Expression>( $3 ) ) ); }
    980994        ;
    981995
     
    11021116        constant_expression                                                     { $$ = $1; }
    11031117        | constant_expression ELLIPSIS constant_expression      // GCC, subrange
    1104                 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $1 ), maybeMoveBuild< Expression >( $3 ) ) ); }
     1118                { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild<Expression>( $1 ), maybeMoveBuild<Expression>( $3 ) ) ); }
    11051119        | subrange                                                                                      // CFA, subrange
    11061120        ;
     
    12471261                { $$ = new StatementNode( build_computedgoto( $3 ) ); }
    12481262                // A semantic check is required to ensure fallthru appears only in the body of a choose statement.
    1249     | fall_through_name ';'                                                             // CFA
     1263        | fall_through_name ';'                                                         // CFA
    12501264                { $$ = new StatementNode( build_branch( BranchStmt::FallThrough ) ); }
    1251     | fall_through_name identifier_or_type_name ';'             // CFA
     1265        | fall_through_name identifier_or_type_name ';'         // CFA
    12521266                { $$ = new StatementNode( build_branch( $2, BranchStmt::FallThrough ) ); }
    12531267        | fall_through_name DEFAULT ';'                                         // CFA
     
    13631377
    13641378exception_statement:
    1365         TRY compound_statement handler_clause
     1379        TRY compound_statement handler_clause                                   %prec THEN
    13661380                { $$ = new StatementNode( build_try( $2, $3, 0 ) ); }
    13671381        | TRY compound_statement finally_clause
     
    13861400handler_key:
    13871401        CATCH                                                                           { $$ = CatchStmt::Terminate; }
     1402        | RECOVER                                                                       { $$ = CatchStmt::Terminate; }
    13881403        | CATCHRESUME                                                           { $$ = CatchStmt::Resume; }
     1404        | FIXUP                                                                         { $$ = CatchStmt::Resume; }
    13891405        ;
    13901406
     
    14481464asm_operand:                                                                                    // GCC
    14491465        string_literal '(' constant_expression ')'
    1450                 { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild< Expression >( $3 ) ) ); }
     1466                { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild<Expression>( $3 ) ) ); }
    14511467        | '[' IDENTIFIER ']' string_literal '(' constant_expression ')'
    1452                 { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild< Expression >( $6 ) ) ); }
     1468                { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild<Expression>( $6 ) ) ); }
    14531469        ;
    14541470
     
    17361752        | sue_type_specifier_nobody
    17371753        | type_type_specifier
     1754        ;
     1755
     1756enum_specifier_nobody:                                                                  // type specifier - {...}
     1757                // Preclude SUE declarations in restricted scopes (see type_specifier_nobody)
     1758        basic_type_specifier
     1759        | sue_type_specifier_nobody
    17381760        ;
    17391761
     
    20042026        ;
    20052027
    2006 fred:
    2007         // empty
    2008                 { yyy = false; }
    2009         ;
    2010 
    20112028aggregate_type:                                                                                 // struct, union
    20122029        aggregate_key attribute_list_opt
     
    20142031          '{' field_declaration_list_opt '}' type_parameters_opt
    20152032                { $$ = DeclarationNode::newAggregate( $1, nullptr, $7, $5, true )->addQualifiers( $2 ); }
    2016         | aggregate_key attribute_list_opt identifier fred
     2033        | aggregate_key attribute_list_opt identifier
    20172034                {
    20182035                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
     
    20202037                }
    20212038          '{' field_declaration_list_opt '}' type_parameters_opt
    2022                 { $$ = DeclarationNode::newAggregate( $1, $3, $9, $7, true )->addQualifiers( $2 ); }
    2023         | aggregate_key attribute_list_opt type_name fred
     2039                { $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); }
     2040        | aggregate_key attribute_list_opt type_name
    20242041                {
    20252042                        // for type_name can be a qualified type name S.T, in which case only the last name in the chain needs a typedef (other names in the chain should already have one)
     
    20282045                }
    20292046          '{' field_declaration_list_opt '}' type_parameters_opt
    2030                 { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $9, $7, true )->addQualifiers( $2 ); }
     2047                { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $8, $6, true )->addQualifiers( $2 ); }
    20312048        | aggregate_type_nobody
    20322049        ;
     
    20402057
    20412058aggregate_type_nobody:                                                                  // struct, union - {...}
    2042         aggregate_key attribute_list_opt identifier fred
     2059        aggregate_key attribute_list_opt identifier
    20432060                {
    20442061                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname );
     
    20462063                        $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
    20472064                }
    2048         | aggregate_key attribute_list_opt type_name fred
     2065        | aggregate_key attribute_list_opt type_name
    20492066                {
    20502067                        forall = false;                                                         // reset
     
    21842201        ;
    21852202
     2203// Cannot use attribute_list_opt because of ambiguity with enum_specifier_nobody, which already parses attribute.
     2204// Hence, only a single attribute is allowed after the "ENUM".
    21862205enum_type:                                                                                              // enum
    2187         ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
     2206        ENUM attribute_opt '{' enumerator_list comma_opt '}'
    21882207                { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); }
    2189         | ENUM attribute_list_opt identifier
     2208        | ENUM attribute_opt identifier
    21902209                { typedefTable.makeTypedef( *$3 ); }
    21912210          '{' enumerator_list comma_opt '}'
    21922211                { $$ = DeclarationNode::newEnum( $3, $6, true )->addQualifiers( $2 ); }
    2193         | ENUM attribute_list_opt type_name
     2212        | ENUM attribute_opt typedef                                            // enum cannot be generic
    21942213          '{' enumerator_list comma_opt '}'
    2195                 { $$ = DeclarationNode::newEnum( $3->type->symbolic.name, $5, true )->addQualifiers( $2 ); }
     2214                { $$ = DeclarationNode::newEnum( $3->name, $5, true )->addQualifiers( $2 ); }
     2215        | ENUM enum_specifier_nobody '{' enumerator_list comma_opt '}'
     2216                // { $$ = DeclarationNode::newEnum( nullptr, $4, true ); }
     2217                { SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; }
     2218        | ENUM enum_specifier_nobody declarator '{' enumerator_list comma_opt '}'
     2219                // {
     2220                //      typedefTable.makeTypedef( *$3->name );
     2221                //      $$ = DeclarationNode::newEnum( nullptr, $5, true );
     2222                // }
     2223                { SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; }
    21962224        | enum_type_nobody
    21972225        ;
    21982226
    21992227enum_type_nobody:                                                                               // enum - {...}
    2200         ENUM attribute_list_opt identifier
     2228        ENUM attribute_opt identifier
    22012229                {
    22022230                        typedefTable.makeTypedef( *$3 );
    22032231                        $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 );
    22042232                }
    2205         | ENUM attribute_list_opt type_name
     2233        | ENUM attribute_opt type_name                                          // enum cannot be generic
    22062234                {
    22072235                        typedefTable.makeTypedef( *$3->type->symbolic.name );
     
    22202248        // empty
    22212249                { $$ = nullptr; }
    2222         | '=' constant_expression
    2223                 { $$ = $2; }
     2250        // | '=' constant_expression
     2251        //      { $$ = $2; }
     2252        | '=' initializer
     2253                { $$ = $2->get_expression(); }                                  // FIX ME: enum only deals with constant_expression
    22242254        ;
    22252255
     
    24032433                { $$ = $3; }
    24042434        | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    2405                 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $3 ), maybeMoveBuild< Expression >( $5 ) ) ); }
     2435                { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild<Expression>( $3 ), maybeMoveBuild<Expression>( $5 ) ) ); }
    24062436        | '.' '[' push field_name_list pop ']'                          // CFA, tuple field selector
    24072437                { $$ = $4; }
     
    24412471type_parameter:                                                                                 // CFA
    24422472        type_class identifier_or_type_name
    2443                 { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); }
     2473                {
     2474                        typedefTable.addToScope( *$2, TYPEDEFname, "9" );
     2475                        if ( $1 == TypeDecl::Otype ) { SemanticError( yylloc, "otype keyword is deprecated, use T " ); }
     2476                        if ( $1 == TypeDecl::Dtype ) { SemanticError( yylloc, "dtype keyword is deprecated, use T &" ); }
     2477                        if ( $1 == TypeDecl::Ttype ) { SemanticError( yylloc, "ttype keyword is deprecated, use T ..." ); }
     2478                }
    24442479          type_initializer_opt assertion_list_opt
    24452480                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
     
    27342769subrange:
    27352770        constant_expression '~' constant_expression                     // CFA, integer subrange
    2736                 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $1 ), maybeMoveBuild< Expression >( $3 ) ) ); }
     2771                { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild<Expression>( $1 ), maybeMoveBuild<Expression>( $3 ) ) ); }
    27372772        ;
    27382773
     
    27582793        | attribute_list attribute
    27592794                { $$ = $2->addQualifiers( $1 ); }
     2795        ;
     2796
     2797attribute_opt:
     2798        // empty
     2799                { $$ = nullptr; }
     2800        | attribute
    27602801        ;
    27612802
     
    31623203        | '[' ']' multi_array_dimension
    31633204                { $$ = DeclarationNode::newArray( 0, 0, false )->addArray( $3 ); }
     3205        | '[' push assignment_expression pop ',' comma_expression ']'
     3206                { $$ = DeclarationNode::newArray( $3, 0, false )->addArray( DeclarationNode::newArray( $6, 0, false ) ); }
     3207                // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; }
    31643208        | multi_array_dimension
    31653209        ;
  • src/ResolvExpr/PolyCost.cc

    r342af53 r8e4aa05  
    3535                PassVisitor<PolyCost> coster( env, indexer );
    3636                type->accept( coster );
    37                 return coster.pass.result;
     37                return (coster.pass.result > 0) ? 1 : 0;
    3838        }
    3939
     
    8787        ast::Pass<PolyCost_new> costing( symtab, env );
    8888        type->accept( costing );
    89         return costing.core.result;
     89        return (costing.core.result > 0) ? 1 : 0;
    9090}
    9191
  • src/ResolvExpr/SpecCost.cc

    r342af53 r8e4aa05  
    4343                // mark specialization of base type
    4444                void postvisit(ReferenceType*) { if ( count >= 0 ) ++count; }
     45
     46                void postvisit(StructInstType*) { if ( count >= 0 ) ++count; }
     47                void postvisit(UnionInstType*) { if ( count >= 0 ) ++count; }
    4548
    4649        private:
     
    8285                void previsit(StructInstType* sty) {
    8386                        count = minover( sty->parameters );
    84                         visit_children = false;
    8587                }
    8688
     
    8890                void previsit(UnionInstType* uty) {
    8991                        count = minover( uty->parameters );
    90                         visit_children = false;
    9192                }
    9293
     
    174175                void postvisit( const ast::ArrayType * ) { if ( count >= 0 ) ++count; }
    175176                void postvisit( const ast::ReferenceType * ) { if ( count >= 0 ) ++count; }
     177
     178                void postvisit( const ast::StructInstType * ) { if ( count >= 0 ) ++count; }
     179                void postvisit( const ast::UnionInstType * ) { if ( count >= 0 ) ++count; }
    176180
    177181                // Use the minimal specialization value over returns and params.
     
    189193                void previsit( const ast::StructInstType * sty ) {
    190194                        count = minimumPresent( sty->params, expr_result );
    191                         visit_children = false;
    192195                }
    193196
     
    195198                void previsit( const ast::UnionInstType * uty ) {
    196199                        count = minimumPresent( uty->params, expr_result );
    197                         visit_children = false;
    198200                }
    199201
  • src/main.cc

    r342af53 r8e4aa05  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Dec  7 15:29:00 2020
    13 // Update Count     : 639
     12// Last Modified On : Fri Feb 19 14:59:00 2021
     13// Update Count     : 643
    1414//
    1515
     
    104104static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false );
    105105static void dump( list< Declaration * > & translationUnit, ostream & out = cout );
     106static void dump( ast::TranslationUnit && transUnit, ostream & out = cout );
    106107
    107108static void backtrace( int start ) {                                    // skip first N stack frames
     
    349350                        PASS( "Resolve", ResolvExpr::resolve( transUnit ) );
    350351                        if ( exprp ) {
    351                                 translationUnit = convert( move( transUnit ) );
    352                                 dump( translationUnit );
     352                                dump( move( transUnit ) );
    353353                                return EXIT_SUCCESS;
    354354                        } // if
     
    492492
    493493static const char * description[] = {
    494         "diagnostic color: never, always, or auto.",            // -c
     494        "diagnostic color: never, always, auto",                        // -c
    495495        "wait for gdb to attach",                                                       // -g
    496         "print help message",                                                           // -h
     496        "print translator help message",                                        // -h
    497497        "generate libcfa.c",                                                            // -l
    498498        "generate line marks",                                                          // -L
     
    500500        "do not generate line marks",                                           // -N
    501501        "do not read prelude",                                                          // -n
    502         "generate prototypes for prelude functions",            // -p
     502        "do not generate prelude prototypes => prelude not printed", // -p
    503503        "only print deterministic output",                  // -d
    504504        "Use the old-ast",                                                                      // -O
     
    506506        "print",                                                                                        // -P
    507507        "<directory> prelude directory for debug/nodebug",      // no flag
    508         "<option-list> enable profiling information:\n          counters,heap,time,all,none", // -S
     508        "<option-list> enable profiling information: counters, heap, time, all, none", // -S
    509509        "building cfa standard lib",                                            // -t
    510510        "",                                                                                                     // -w
     
    732732} // dump
    733733
     734static void dump( ast::TranslationUnit && transUnit, ostream & out ) {
     735        std::list< Declaration * > translationUnit = convert( move( transUnit ) );
     736        dump( translationUnit, out );
     737}
     738
    734739// Local Variables: //
    735740// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.