Changes in / [2ad4b49:f77dbc0]


Ignore:
Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r2ad4b49 rf77dbc0  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun  1 17:59:57 2018
    13 // Update Count     : 3476
     12// Last Modified On : Sat Jun  2 17:18:40 2018
     13// Update Count     : 3487
    1414//
    1515
     
    13311331        c_declaration ';'
    13321332        | cfa_declaration ';'                                                           // CFA
    1333         | static_assert
     1333        | static_assert                                                                         // C11
    13341334        ;
    13351335
     
    13371337        STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11
    13381338                { $$ = DeclarationNode::newStaticAssert( $3, $5 ); }
     1339        | STATICASSERT '(' constant_expression ')' ';'          // CFA
     1340                { $$ = DeclarationNode::newStaticAssert( $3, build_constantStr( *new string( "" ) ) ); }
    13391341
    13401342// C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
     
    18811883
    18821884field_declaration:
    1883         cfa_field_declaring_list ';'                                            // CFA, new style field declaration
     1885        type_specifier field_declaring_list ';'
     1886                { $$ = distAttr( $1, $2 ); }
     1887        | EXTENSION type_specifier field_declaring_list ';'     // GCC
     1888                { distExt( $3 ); $$ = distAttr( $2, $3 ); }             // mark all fields in list
     1889        | typedef_declaration ';'                                                       // CFA
     1890                { SemanticError( yylloc, "Typedef in aggregate is currently unimplemented." ); $$ = nullptr; }
     1891        | cfa_field_declaring_list ';'                                          // CFA, new style field declaration
    18841892        | EXTENSION cfa_field_declaring_list ';'                        // GCC
    1885                 {
    1886                         distExt( $2 );                                                          // mark all fields in list
    1887                         $$ = $2;
    1888                 }
    1889         | type_specifier field_declaring_list ';'
    1890                 {
    1891                         $$ = distAttr( $1, $2 ); }
    1892         | EXTENSION type_specifier field_declaring_list ';'     // GCC
    1893                 {
    1894                         distExt( $3 );                                                          // mark all fields in list
    1895                         $$ = distAttr( $2, $3 );
    1896                 }
    1897         | static_assert
     1893                { distExt( $2 ); $$ = $2; }                                             // mark all fields in list
     1894        | cfa_typedef_declaration ';'                                           // CFA
     1895                { SemanticError( yylloc, "Typedef in aggregate is currently unimplemented." ); $$ = nullptr; }
     1896        | static_assert                                                                         // C11
    18981897        ;
    18991898
  • src/tests/sum.c

    r2ad4b49 rf77dbc0  
    1111// Created On       : Wed May 27 17:56:53 2015
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Sat Feb 17 11:49:17 2018
    14 // Update Count     : 273
     13// Last Modified On : Sun Jun  3 19:23:41 2018
     14// Update Count     : 278
    1515//
    1616
     
    1818#include <stdlib>
    1919
    20 void ?{}( int & c, zero_t ) { c = 0; }
     20void ?{}( int & c, zero_t ) { c = 0; }                                  // not in prelude
    2121
    2222trait sumable( otype T ) {
    23         void ?{}( T &, zero_t );                                                        // constructor from 0 literal
     23        void ?{}( T &, zero_t );                                                        // 0 literal constructor
    2424        T ?+?( T, T );                                                                          // assortment of additions
    2525        T ?+=?( T &, T );
     
    2929
    3030forall( otype T | sumable( T ) )                                                // use trait
    31 T sum( unsigned int size, T a[] ) {
    32         T total = 0;                                                                            // instantiate T from 0 by calling constructor
    33         for ( unsigned int i = 0; i < size; i += 1 )
     31T sum( size_t size, T a[] ) {
     32        T total = 0;                                                                            // initialize by 0 constructor
     33        for ( size_t i = 0; i < size; i += 1 )
    3434                total += a[i];                                                                  // select appropriate +
    3535        return total;
     
    111111        for ( int i = 0; i < size; i += 1, v += 1 ) {
    112112                s += (int)v;
    113                 gs.x[i] = (int)v;                                                               // set filed array in generic type
     113                gs.x[i] = (int)v;                                                               // set field array in generic type
    114114        } // for
    115115        sout | "sum from" | low | "to" | High | "is"
    116                  | sum( size, gs.x ) | ", check" | (int)s | endl; // add filed array in generic type
     116                 | sum( size, gs.x ) | ", check" | (int)s | endl; // add field array in generic type
    117117} // main
    118118
Note: See TracChangeset for help on using the changeset viewer.