Ignore:
Timestamp:
Nov 1, 2016, 3:18:59 PM (9 years ago)
Author:
Aaron Moss <a3moss@…>
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:
84118d8
Parents:
40744af8 (diff), 0afffee (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

    r40744af8 rf51aefb  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep 24 12:16:53 2016
    13 // Update Count     : 1992
     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
     
    196200%type<decl> field_declaration field_declaration_list field_declarator field_declaring_list
    197201%type<en> field field_list
     202%type<tok> field_name
    198203
    199204%type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr
     
    277282//
    278283// Cforall compounds this problem by introducing type names local to the scope of a declaration (for instance, those
    279 // introduced through "forall" qualifiers), and by introducing "type generators" -- parametrized types.  This latter
     284// introduced through "forall" qualifiers), and by introducing "type generators" -- parameterized types.  This latter
    280285// type name creates a third class of identifiers that must be distinguished by the scanner.
    281286//
    282287// Since the scanner cannot distinguish among the different classes of identifiers without some context information, it
    283 // accesses a data structure (the TypedefTable) to allow classification of an identifier that it has just read.
    284 // Semantic actions during the parser update this data structure when the class of identifiers change.
     288// accesses a data structure (TypedefTable) to allow classification of an identifier that it has just read.  Semantic
     289// actions during the parser update this data structure when the class of identifiers change.
    285290//
    286291// Because the Cforall language is block-scoped, there is the possibility that an identifier can change its class in a
     
    288293// particular declaration, each declaration is itself a scope.  This requires distinguishing between type names that are
    289294// local to the current declaration scope and those that persist past the end of the declaration (i.e., names defined in
    290 // "typedef" or "type" declarations).
     295// "typedef" or "otype" declarations).
    291296//
    292297// The non-terminals "push" and "pop" derive the empty string; their only use is to denote the opening and closing of
     
    311316                // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant".
    312317        INTEGERconstant                                                         { $$ = new ExpressionNode( build_constantInteger( *$1 ) ); }
     318        | REALDECIMALconstant                                           { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }
     319        | REALFRACTIONconstant                                          { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }
    313320        | FLOATINGconstant                                                      { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }
    314321        | CHARACTERconstant                                                     { $$ = new ExpressionNode( build_constantChar( *$1 ) ); }
     
    357364        | zero_one
    358365                { $$ = new ExpressionNode( build_varref( $1 ) ); }
     366        | tuple
    359367        | '(' comma_expression ')'
    360368                { $$ = $2; }
     
    373381        | postfix_expression '(' argument_expression_list ')'
    374382                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
    375                 // ambiguity with .0 so space required after field-selection, e.g.
    376                 //   struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;
    377383        | postfix_expression '.' no_attr_identifier
    378384                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
    379385        | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
     386        | postfix_expression REALFRACTIONconstant                       // CFA, tuple index
    380387        | postfix_expression ARROW no_attr_identifier
    381388                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
     
    413420
    414421field:                                                                                                  // CFA, tuple field selector
    415         no_attr_identifier
     422        field_name
    416423                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    417                 // ambiguity with .0 so space required after field-selection, e.g.
    418                 //   struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;
    419         | no_attr_identifier '.' field
     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 ) ) ); }
     428        | field_name '.' field
    420429                { $$ = new ExpressionNode( build_fieldSel( $3, build_varref( $1 ) ) ); }
    421         | no_attr_identifier '.' '[' push field_list pop ']'
     430        | field_name '.' '[' push field_list pop ']'
    422431                { $$ = new ExpressionNode( build_fieldSel( $5, build_varref( $1 ) ) ); }
    423         | no_attr_identifier ARROW field
     432        | field_name ARROW field
    424433                { $$ = new ExpressionNode( build_pfieldSel( $3, build_varref( $1 ) ) ); }
    425         | no_attr_identifier ARROW '[' push field_list pop ']'
     434        | field_name ARROW '[' push field_list pop ']'
    426435                { $$ = new ExpressionNode( build_pfieldSel( $5, build_varref( $1 ) ) ); }
     436        ;
     437
     438field_name:
     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
    427450        ;
    428451
     
    497520        | '(' type_name_no_function ')' cast_expression
    498521                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    499         | '(' type_name_no_function ')' tuple
    500                 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
     522//      | '(' type_name_no_function ')' tuple
     523//              { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    501524        ;
    502525
     
    584607        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    585608                { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
    586         | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression
    587                 { $$ = 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 ) ); }
    588611        ;
    589612
     
    597620        | unary_expression assignment_operator assignment_expression
    598621                { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); }
    599         | tuple assignment_opt                                                          // CFA, tuple expression
    600                 { $$ = ( $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 ) ); }
    601624        ;
    602625
     
    625648                // CFA, one assignment_expression is factored out of comma_expression to eliminate a shift/reduce conflict with
    626649                // comma_expression in new_identifier_parameter_array and new_abstract_array
    627         '[' ']'
    628                 { $$ = new ExpressionNode( build_tuple() ); }
    629         | '[' push assignment_expression pop ']'
    630                 { $$ = new ExpressionNode( build_tuple( $3 ) ); }
    631         | '[' 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 ']'
    632655                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $4 ) ) ); }
    633656        | '[' push assignment_expression ',' tuple_expression_list pop ']'
     
    11281151
    11291152new_function_specifier:                                                                 // CFA
    1130         '[' ']' identifier_or_type_name '(' push new_parameter_type_list_opt pop ')' // S/R conflict
    1131                 {
    1132                         $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true );
    1133                 }
     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//              }
    11341157//      '[' ']' identifier '(' push new_parameter_type_list_opt pop ')'
    11351158//              {
     
    11501173                // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be
    11511174                // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name.
    1152         | 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 ')'
    11531176                // To obtain LR(1 ), this rule must be factored out from function return type (see new_abstract_declarator).
    11541177                {
     
    20052028                {
    20062029                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    2007                         linkage = LinkageSpec::fromString( *$2 );
     2030                        linkage = LinkageSpec::linkageCheck( $2 );
    20082031                }
    20092032          '{' external_definition_list_opt '}'                          // C++-style linkage specifier
     
    27162739        | multi_array_dimension type_specifier
    27172740                { $$ = $2->addNewArray( $1 ); }
     2741
    27182742        | '[' ']' new_identifier_parameter_ptr
    27192743                { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     
    28132837
    28142838new_abstract_function:                                                                  // CFA
    2815         '[' ']' '(' new_parameter_type_list_opt ')'
    2816                 { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); }
    2817         | 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 ')'
    28182842                { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
    28192843        | new_function_return '(' push new_parameter_type_list_opt pop ')'
Note: See TracChangeset for help on using the changeset viewer.