Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rf9941ff rd48e529  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Oct 25 12:28:54 2017
    13 // Update Count     : 2893
     12// Last Modified On : Thu Sep 14 23:07:12 2017
     13// Update Count     : 2815
    1414//
    1515
     
    4343#define YYDEBUG_LEXER_TEXT (yylval)                                             // lexer loads this up each time
    4444#define YYDEBUG 1                                                                               // get the pretty debugging code to compile
    45 #define YYERROR_VERBOSE                                                                 // more information in syntax errors
     45#define YYERROR_VERBOSE
    4646
    4747#undef __GNUC_MINOR__
     
    117117bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
    118118
    119 // https://www.gnu.org/software/bison/manual/bison.html#Location-Type
    120 #define YYLLOC_DEFAULT(Cur, Rhs, N)                                                                                             \
    121 if ( N ) {                                                                                                                                              \
    122         (Cur).first_line   = YYRHSLOC( Rhs, 1 ).first_line;                                                     \
    123         (Cur).first_column = YYRHSLOC( Rhs, 1 ).first_column;                                           \
    124         (Cur).last_line    = YYRHSLOC( Rhs, N ).last_line;                                                      \
    125         (Cur).last_column  = YYRHSLOC( Rhs, N ).last_column;                                            \
    126         (Cur).filename     = YYRHSLOC( Rhs, 1 ).filename;                                                       \
    127 } else {                                                                                                                                                \
    128         (Cur).first_line   = (Cur).last_line = YYRHSLOC( Rhs, 0 ).last_line;            \
    129         (Cur).first_column = (Cur).last_column = YYRHSLOC( Rhs, 0 ).last_column;        \
    130         (Cur).filename     = YYRHSLOC( Rhs, 0 ).filename;                                                       \
    131 }
     119# define YYLLOC_DEFAULT(Cur, Rhs, N)                            \
     120do                                                              \
     121        if (N) {                                                      \
     122                (Cur).first_line   = YYRHSLOC(Rhs, 1).first_line;           \
     123                (Cur).first_column = YYRHSLOC(Rhs, 1).first_column;         \
     124                (Cur).last_line    = YYRHSLOC(Rhs, N).last_line;            \
     125                (Cur).last_column  = YYRHSLOC(Rhs, N).last_column;          \
     126                (Cur).filename     = YYRHSLOC(Rhs, 1).filename;             \
     127        } else {                                                      \
     128                (Cur).first_line   = (Cur).last_line   =                    \
     129                        YYRHSLOC(Rhs, 0).last_line;                               \
     130                (Cur).first_column = (Cur).last_column =                    \
     131                        YYRHSLOC(Rhs, 0).last_column;                             \
     132                (Cur).filename     = YYRHSLOC(Rhs, 0).filename;             \
     133        }                                                             \
     134while (0)
    132135%}
    133136
    134137%define parse.error verbose
    135138
    136 // Types declaration for productions
     139// Types declaration
    137140%union
    138141{
     
    170173%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
    171174%token BOOL COMPLEX IMAGINARY                                                   // C99
    172 %token INT128 FLOAT80 FLOAT128                                                  // GCC
    173175%token ZERO_T ONE_T                                                                             // CFA
    174176%token VALIST                                                                                   // GCC
     
    180182%token ATTRIBUTE EXTENSION                                                              // GCC
    181183%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
    182 %token CHOOSE DISABLE ENABLE FALLTHRU FALLTHROUGH TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH WHEN WAITFOR // CFA
     184%token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH WHEN WAITFOR // CFA
    183185%token ASM                                                                                              // C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
    184186%token ALIGNAS ALIGNOF GENERIC STATICASSERT                             // C11
     
    250252%type<sn> exception_statement                   handler_clause                          finally_clause
    251253%type<catch_kind> handler_key
    252 %type<sn> mutex_statement
    253254%type<en> when_clause                                   when_clause_opt                         waitfor                                         timeout
    254255%type<sn> waitfor_statement
     
    362363%precedence ELSE        // token precedence for start of else clause in IF/WAITFOR statement
    363364
    364 %locations                      // support location tracking for error messages
     365%locations
    365366
    366367%start translation_unit                                                                 // parse-tree root
     
    457458        | '(' compound_statement ')'                                            // GCC, lambda expression
    458459                { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); }
     460        | primary_expression '{' argument_expression_list '}' // CFA, constructor call
     461                {
     462                        Token fn;
     463                        fn.str = new std::string( "?{}" );                      // location undefined - use location of '{'?
     464                        $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
     465                }
    459466        | type_name '.' no_attr_identifier                                      // CFA, nested type
    460                 { throw SemanticError("Qualified names are currently unimplemented."); $$ = nullptr; }                                                          // FIX ME
     467                { $$ = nullptr; }                                                               // FIX ME
    461468        | type_name '.' '[' push field_list pop ']'                     // CFA, nested type / tuple field selector
    462                 { throw SemanticError("Qualified names are currently unimplemented."); $$ = nullptr; }                                                          // FIX ME
     469                { $$ = nullptr; }                                                               // FIX ME
    463470        ;
    464471
     
    471478                // equivalent to the old x[i,j].
    472479                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $4 ) ); }
    473         | postfix_expression '{' argument_expression_list '}' // CFA, constructor call
    474                 {
    475                         Token fn;
    476                         fn.str = new std::string( "?{}" );                      // location undefined - use location of '{'?
    477                         $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
    478                 }
    479480        | postfix_expression '(' argument_expression_list ')'
    480481                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
     
    808809        | jump_statement
    809810        | with_statement
    810         | mutex_statement
    811811        | waitfor_statement
    812812        | exception_statement
     
    974974        ;
    975975
    976 fall_through_name:                                                                              // CFA
     976fall_through:                                                                                   // CFA
    977977        FALLTHRU
    978         | FALLTHROUGH
    979         ;
    980 
    981 fall_through:                                                                                   // CFA
    982         fall_through_name
    983978                { $$ = nullptr; }
    984         | fall_through_name ';'
     979        | FALLTHRU ';'
    985980                { $$ = nullptr; }
    986981        ;
     
    10381033        ;
    10391034
    1040 // If MUTEX becomes a general qualifier, there are shift/reduce conflicts, so change syntax to "with mutex".
    1041 mutex_statement:
    1042         MUTEX '(' argument_expression_list ')' statement
    1043                 { $$ = nullptr; }                                                               // FIX ME
    1044         ;
    1045 
    10461035when_clause:
    10471036        WHEN '(' comma_expression ')'
     
    15621551        | VOLATILE
    15631552                { $$ = DeclarationNode::newTypeQualifier( Type::Volatile ); }
     1553        | MUTEX
     1554                { $$ = DeclarationNode::newTypeQualifier( Type::Mutex ); }
    15641555        | ATOMIC
    15651556                { $$ = DeclarationNode::newTypeQualifier( Type::Atomic ); }
     
    16151606
    16161607basic_type_name:
    1617         VOID
     1608        CHAR
     1609                { $$ = DeclarationNode::newBasicType( DeclarationNode::Char ); }
     1610        | DOUBLE
     1611                { $$ = DeclarationNode::newBasicType( DeclarationNode::Double ); }
     1612        | FLOAT
     1613                { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); }
     1614        | INT
     1615                { $$ = DeclarationNode::newBasicType( DeclarationNode::Int ); }
     1616        | LONG
     1617                { $$ = DeclarationNode::newLength( DeclarationNode::Long ); }
     1618        | SHORT
     1619                { $$ = DeclarationNode::newLength( DeclarationNode::Short ); }
     1620        | SIGNED
     1621                { $$ = DeclarationNode::newSignedNess( DeclarationNode::Signed ); }
     1622        | UNSIGNED
     1623                { $$ = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); }
     1624        | VOID
    16181625                { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); }
    16191626        | BOOL                                                                                          // C99
    16201627                { $$ = DeclarationNode::newBasicType( DeclarationNode::Bool ); }
    1621         | CHAR
    1622                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Char ); }
    1623         | INT
    1624                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int ); }
    1625         | INT128
    1626                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 ); }
    1627         | FLOAT
    1628                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); }
    1629         | FLOAT80
    1630                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float80 ); }
    1631         | FLOAT128
    1632                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float128 ); }
    1633         | DOUBLE
    1634                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Double ); }
    16351628        | COMPLEX                                                                                       // C99
    16361629                { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); }
    16371630        | IMAGINARY                                                                                     // C99
    16381631                { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); }
    1639         | SIGNED
    1640                 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Signed ); }
    1641         | UNSIGNED
    1642                 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); }
    1643         | SHORT
    1644                 { $$ = DeclarationNode::newLength( DeclarationNode::Short ); }
    1645         | LONG
    1646                 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); }
    16471632        | ZERO_T
    16481633                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
     
    24912476        | TYPEDEFname
    24922477        | TYPEGENname
    2493         | FALLTHROUGH
    2494                 { $$ = Token{ new string( "fallthrough" ), { nullptr, -1 } }; }
    24952478        | CONST
    24962479                { $$ = Token{ new string( "__const__" ), { nullptr, -1 } }; }
     
    27162699        paren_identifier attribute_list_opt
    27172700                { $$ = $1->addQualifiers( $2 ); }
    2718         | '&' MUTEX paren_identifier attribute_list_opt
    2719                 { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( Type::Mutex ), OperKinds::AddressOf ) )->addQualifiers( $4 ); }
    27202701        | identifier_parameter_ptr
    27212702        | identifier_parameter_array attribute_list_opt
     
    27582739//
    27592740//              typedef int foo;
    2760 //              forall( otype T ) struct foo;
    27612741//              int f( int foo ); // redefine typedef name in new scope
    27622742//
     
    27662746        typedef attribute_list_opt
    27672747                { $$ = $1->addQualifiers( $2 ); }
    2768         | '&' MUTEX typedef attribute_list_opt
    2769                 { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( Type::Mutex ), OperKinds::AddressOf ) )->addQualifiers( $4 ); }
    27702748        | type_parameter_ptr
    27712749        | type_parameter_array attribute_list_opt
     
    29142892abstract_parameter_declarator:
    29152893        abstract_parameter_ptr
    2916         | '&' MUTEX attribute_list_opt
    2917                 { $$ = DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( Type::Mutex ), OperKinds::AddressOf )->addQualifiers( $3 ); }
    29182894        | abstract_parameter_array attribute_list_opt
    29192895                { $$ = $1->addQualifiers( $2 ); }
Note: See TracChangeset for help on using the changeset viewer.