Ignore:
Timestamp:
Oct 27, 2016, 9:37:58 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:
d93d980
Parents:
efe4d730 (diff), 6d7c3df (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

    refe4d730 r25f49f4  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Oct 19 22:19:33 2016
    13 // Update Count     : 2003
     12// Last Modified On : Wed Oct 26 17:35:53 2016
     13// Update Count     : 2066
    1414//
    1515
     
    9494%token<tok> IDENTIFIER                  QUOTED_IDENTIFIER               TYPEDEFname                             TYPEGENname
    9595%token<tok> ATTR_IDENTIFIER             ATTR_TYPEDEFname                ATTR_TYPEGENname
    96 %token<tok> INTEGERconstant             FLOATINGconstant                CHARACTERconstant               STRINGliteral
     96%token<tok> INTEGERconstant             CHARACTERconstant               STRINGliteral
     97// Floating point constant is broken into three kinds of tokens because of the ambiguity with tuple indexing and
     98// overloading constants 0/1, e.g., x.1 is lexed as (x)(.1), where (.1) is a factional constant, but is semantically
     99// converted into the tuple index (.)(1). e.g., 3.x
     100%token<tok>     REALDECIMALconstant     REALFRACTIONconstant    FLOATINGconstant
    97101%token<tok> ZERO                                ONE                                             // CFA
    98102
     
    312316                // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant".
    313317        INTEGERconstant                                                         { $$ = new ExpressionNode( build_constantInteger( *$1 ) ); }
     318        | REALDECIMALconstant                                           { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }
     319        | REALFRACTIONconstant                                          { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }
    314320        | FLOATINGconstant                                                      { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }
    315321        | CHARACTERconstant                                                     { $$ = new ExpressionNode( build_constantChar( *$1 ) ); }
     
    358364        | zero_one
    359365                { $$ = new ExpressionNode( build_varref( $1 ) ); }
     366        | tuple
    360367        | '(' comma_expression ')'
    361368                { $$ = $2; }
     
    374381        | postfix_expression '(' argument_expression_list ')'
    375382                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
    376                 // ambiguity with .0 so space required after field-selection, e.g.
    377                 //   struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;
    378383        | postfix_expression '.' no_attr_identifier
    379384                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
    380385        | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
    381         | postfix_expression '.' INTEGERconstant
     386        | postfix_expression REALFRACTIONconstant                       // CFA, tuple index
    382387        | postfix_expression ARROW no_attr_identifier
    383388                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
     
    416421field:                                                                                                  // CFA, tuple field selector
    417422        field_name
    418                 // ambiguity with .0 so space required after field-selection, e.g.
    419                 //   struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;
    420423                { $$ = new ExpressionNode( build_varref( $1 ) ); }
     424        | REALDECIMALconstant field
     425                { $$ = new ExpressionNode( build_fieldSel( $2, build_varref( $1 ) ) ); }
     426        | REALDECIMALconstant '[' push field_list pop ']'
     427                { $$ = new ExpressionNode( build_fieldSel( $4, build_varref( $1 ) ) ); }
    421428        | field_name '.' field
    422429                { $$ = new ExpressionNode( build_fieldSel( $3, build_varref( $1 ) ) ); }
     
    430437
    431438field_name:
    432         no_attr_identifier
    433                 // x.1, x.[0, 0.0]
    434         | INTEGERconstant
     439        INTEGERconstant fraction_constants
     440                { $$ = $1; }
     441        | FLOATINGconstant fraction_constants
     442                { $$ = $1; }
     443        | no_attr_identifier fraction_constants
     444                { $$ = $1; }
     445        ;
     446
     447fraction_constants:
     448        // empty
     449        | fraction_constants REALFRACTIONconstant
    435450        ;
    436451
     
    505520        | '(' type_name_no_function ')' cast_expression
    506521                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    507         | '(' type_name_no_function ')' tuple
    508                 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
     522//      | '(' type_name_no_function ')' tuple
     523//              { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    509524        ;
    510525
     
    592607        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    593608                { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
    594         | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression
    595                 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
     609//      | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression
     610//              { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
    596611        ;
    597612
     
    605620        | unary_expression assignment_operator assignment_expression
    606621                { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); }
    607         | tuple assignment_opt                                                          // CFA, tuple expression
    608                 { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }
     622//      | tuple assignment_opt                                                          // CFA, tuple expression
     623//              { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }
    609624        ;
    610625
     
    633648                // CFA, one assignment_expression is factored out of comma_expression to eliminate a shift/reduce conflict with
    634649                // comma_expression in new_identifier_parameter_array and new_abstract_array
    635         '[' ']'
    636                 { $$ = new ExpressionNode( build_tuple() ); }
    637         | '[' push assignment_expression pop ']'
    638                 { $$ = new ExpressionNode( build_tuple( $3 ) ); }
    639         | '[' push ',' tuple_expression_list pop ']'
     650//      '[' ']'
     651//              { $$ = new ExpressionNode( build_tuple() ); }
     652//      '[' push assignment_expression pop ']'
     653//              { $$ = new ExpressionNode( build_tuple( $3 ) ); }
     654        '[' push ',' tuple_expression_list pop ']'
    640655                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $4 ) ) ); }
    641656        | '[' push assignment_expression ',' tuple_expression_list pop ']'
     
    11361151
    11371152new_function_specifier:                                                                 // CFA
    1138         '[' ']' identifier_or_type_name '(' push new_parameter_type_list_opt pop ')' // S/R conflict
    1139                 {
    1140                         $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );
    1141                 }
     1153//      '[' ']' identifier_or_type_name '(' push new_parameter_type_list_opt pop ')' // S/R conflict
     1154//              {
     1155//                      $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );
     1156//              }
    11421157//      '[' ']' identifier '(' push new_parameter_type_list_opt pop ')'
    11431158//              {
     
    11581173                // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be
    11591174                // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name.
    1160         | new_abstract_tuple identifier_or_type_name '(' push new_parameter_type_list_opt pop ')'
     1175        new_abstract_tuple identifier_or_type_name '(' push new_parameter_type_list_opt pop ')'
    11611176                // To obtain LR(1 ), this rule must be factored out from function return type (see new_abstract_declarator).
    11621177                {
     
    28222837
    28232838new_abstract_function:                                                                  // CFA
    2824         '[' ']' '(' new_parameter_type_list_opt ')'
    2825                 { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); }
    2826         | new_abstract_tuple '(' push new_parameter_type_list_opt pop ')'
     2839//      '[' ']' '(' new_parameter_type_list_opt ')'
     2840//              { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); }
     2841        new_abstract_tuple '(' push new_parameter_type_list_opt pop ')'
    28272842                { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
    28282843        | new_function_return '(' push new_parameter_type_list_opt pop ')'
Note: See TracChangeset for help on using the changeset viewer.