Changeset b63e376 for src/examples


Ignore:
Timestamp:
Mar 8, 2016, 10:24:43 PM (10 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
ae357ec
Parents:
4040425
Message:

update refrat with new keywords, update examples, update separators for quoted strings

Location:
src/examples
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • src/examples/fstream_test.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 15:12:21 2016
    13 // Update Count     : 51
     12// Last Modified On : Sun Mar  6 20:58:29 2016
     13// Update Count     : 54
    1414//
    1515
     
    2828        int i, j, k;
    2929        sin  | &i | &j | &k;
    30         sout | "Vous avez entré" | "i:" | i | "j:" | j | "k:" | k | endl;
     30        sout | "Vous avez entré" | "i:" | "" | i | "j:" | "" | j | "k:" | "" | k | endl;
    3131}
    3232
  • src/examples/huge.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:15:34 2015
    13 // Update Count     : 1
     12// Last Modified On : Tue Mar  8 22:16:32 2016
     13// Update Count     : 2
    1414//
    1515
    16 int huge( int n, forall( type T ) T (*f)( T ) ) {
     16int huge( int n, forall( otype T ) T (*f)( T ) ) {
    1717        if ( n <= 0 )
    1818                return f( 0 );
  • src/examples/identity.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Feb 29 23:40:45 2016
    13 // Update Count     : 12
     12// Last Modified On : Tue Mar  8 22:15:08 2016
     13// Update Count     : 13
    1414//
    1515
    1616#include <fstream>
    1717
    18 forall( type T )
     18forall( otype T )
    1919T identity( T t ) {
    2020        return t;
  • src/examples/includes.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Dec 21 13:54:09 2015
    13 // Update Count     : 322
     12// Last Modified On : Wed Mar  2 23:28:02 2016
     13// Update Count     : 328
    1414//
    1515
     
    4343#include <ctype.h>
    4444#include <curses.h>
    45 #include <demangle.h>           // enum / contains "type"
    46 #include <dialog.h>                     // enum / contains "type"
     45#include <demangle.h>
     46#include <dialog.h>
    4747#include <dirent.h>
    4848#include <dis-asm.h>
     
    5656#include <err.h>
    5757#include <errno.h>
     58#if 0
    5859#include <error.h>
     60#endif
     61#include <eti.h>
     62#include <evdns.h>
     63#include <event.h>
     64#include <evhttp.h>
    5965#if 0
    60 #include <eti.h>
    61 #include <evdns.h>                      // subdirectory event2 contains "type"
    62 #include <event.h>
    63 #include <evhttp.h>                     // enum / subdirectory event2 contains "type"
    6466#include <evrpc.h>
    6567#include <evutil.h>
    6668#include <execinfo.h>
    67 #include <expat.h>                      // enum / contains "type" and "context"
     69#include <expat.h>
    6870#include <expat_config.h>
    6971#include <expat_external.h>
     
    7476#include <fmtmsg.h>
    7577#include <fnmatch.h>
    76 #include <form.h>                       // contains "type"
     78#include <form.h>
    7779#include <fpu_control.h>
    7880#include <fstab.h>
     
    8183#include <ftw.h>
    8284#include <gconv.h>
    83 //#include <gcrypt.h>           // enum / contains "type"
     85//#include <gcrypt.h>
    8486//#include <gcrypt-module.h>
    8587#include <getopt.h>
     
    107109#include <limits.h>
    108110#include <locale.h>
    109 #include <math.h>                       // contains "type"
     111#include <math.h>
    110112#include <ncurses.h>
    111113#include <setjmp.h>
  • src/examples/it_out.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 18:11:00 2016
    13 // Update Count     : 5
     12// Last Modified On : Tue Mar  8 22:14:39 2016
     13// Update Count     : 8
    1414//
    1515
     
    2121};
    2222
    23 trait writeable( type T ) {
     23trait writeable( otype T ) {
    2424        forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, T );
    2525};
     
    3636};
    3737
    38 trait readable( type T ) {
     38trait readable( otype T ) {
    3939        forall( dtype is_type | istream( is_type ) ) is_type * ?<<?( is_type *, T );
    4040};
     
    4343forall( dtype is_type | istream( is_type ) ) is_type * ?>>?( is_type *, int* );
    4444
    45 trait iterator( type iterator_type, type elt_type ) {
     45trait iterator( otype iterator_type, otype elt_type ) {
    4646        iterator_type ?++( iterator_type* );
    4747        iterator_type ++?( iterator_type* );
     
    5252};
    5353
    54 forall( type elt_type | writeable( elt_type ),
    55                 type iterator_type | iterator( iterator_type, elt_type ),
     54forall( otype elt_type | writeable( elt_type ),
     55                otype iterator_type | iterator( iterator_type, elt_type ),
    5656                dtype os_type | ostream( os_type ) )
    5757void write_all( iterator_type begin, iterator_type end, os_type *os );
    5858
    59 forall( type elt_type | writeable( elt_type ),
    60                 type iterator_type | iterator( iterator_type, elt_type ),
     59forall( otype elt_type | writeable( elt_type ),
     60                otype iterator_type | iterator( iterator_type, elt_type ),
    6161                dtype os_type | ostream( os_type ) )
    6262void write_all( elt_type begin, iterator_type end, os_type *os ) {
  • src/examples/new.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan 25 23:33:55 2016
    13 // Update Count     : 2
     12// Last Modified On : Tue Mar  8 22:13:20 2016
     13// Update Count     : 4
    1414//
    1515
    16 forall( type T )
     16forall( otype T )
    1717void f( T *t ) {
    1818        t--;
  • src/examples/prolog.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 18:11:18 2016
    13 // Update Count     : 2
     12// Last Modified On : Tue Mar  8 22:09:39 2016
     13// Update Count     : 5
    1414//
    1515
    16 extern "C" { extern int printf( const char *fmt, ... ); }
     16#include <fstream>
    1717
    18 void printResult( int x ) { printf( "int\n" ); }
    19 void printResult( double x ) { printf( "double\n" ); }
    20 void printResult( char * x ) { printf( "char*\n" ); }
     18void printResult( int x ) { sout | "int" | endl; }
     19void printResult( double x ) { sout | "double" | endl; }
     20void printResult( char * x ) { sout | "char*" | endl; }
    2121
    2222void is_arithmetic( int x ) {}
     
    2525void is_integer( int x ) {}
    2626
    27 trait ArithmeticType( type T ) {
     27trait ArithmeticType( otype T ) {
    2828        void is_arithmetic( T );
    2929};
    3030
    31 trait IntegralType( type T | ArithmeticType( T ) ) {
     31trait IntegralType( otype T | ArithmeticType( T ) ) {
    3232        void is_integer( T );
    3333};
    3434
    35 forall( type T | IntegralType( T ) | { void printResult( T ); } )
     35forall( otype T | IntegralType( T ) | { void printResult( T ); } )
    3636void hornclause( T param ) {
    3737        printResult( param );
  • src/examples/quad.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  1 08:24:56 2016
    13 // Update Count     : 7
     12// Last Modified On : Tue Mar  8 22:07:02 2016
     13// Update Count     : 8
    1414//
    1515
    1616#include <fstream>
    1717
    18 forall( type T | { T ?*?( T, T ); } )
     18forall( otype T | { T ?*?( T, T ); } )
    1919T square( T t ) {
    2020        return t * t;
    2121}
    2222
    23 forall( type U | { U square( U ); } )
     23forall( otype U | { U square( U ); } )
    2424U quad( U u ) {
    2525        return square( square( u ) );
  • src/examples/simplePoly.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:31:17 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue Mar  8 22:06:41 2016
     13// Update Count     : 3
    1414//
    1515
    16 forall( type T, type U | { T f( T, U ); } )
     16forall( otype T, otype U | { T f( T, U ); } )
    1717T q( T t, U u ) {
    1818        return f( t, u );
  • src/examples/simpler.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:31:48 2015
    13 // Update Count     : 1
     12// Last Modified On : Tue Mar  8 22:06:30 2016
     13// Update Count     : 2
    1414//
    1515
    16 forall( type T ) T id( T, T );
     16forall( otype T ) T id( T, T );
    1717
    1818int main() {
  • src/examples/specialize.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:32:26 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue Mar  8 22:06:17 2016
     13// Update Count     : 3
    1414//
    1515
     
    3939}
    4040
    41 forall( type T ) T f( T t )
     41forall( otype T ) T f( T t )
    4242{
    4343        printf( "in f; sizeof T is %d\n", sizeof( T ) );
  • src/examples/square.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb 17 12:21:58 2016
    13 // Update Count     : 26
     12// Last Modified On : Tue Mar  8 22:05:48 2016
     13// Update Count     : 27
    1414//
    1515
    1616#include <fstream>
    1717
    18 forall( type T | { T ?*?( T, T ); } )
     18forall( otype T | { T ?*?( T, T ); } )
    1919T square( T t ) {
    2020        return t * t;
  • src/examples/sum.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 18:12:01 2016
    13 // Update Count     : 194
     12// Last Modified On : Fri Mar  4 15:06:47 2016
     13// Update Count     : 196
    1414//
    1515
    1616#include <fstream>
    1717
    18 trait sumable( type T ) {
     18trait sumable( otype T ) {
    1919        const T 0;
    2020        T ?+?( T, T );
     
    2424}; // sumable
    2525
    26 forall( type T | sumable( T ) )
     26forall( otype T | sumable( T ) )
    2727T sum( unsigned int n, T a[] ) {
    2828        T total = 0;                                                                            // instantiate T, select 0
  • src/examples/twice.c

    r4040425 rb63e376  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb 17 12:23:25 2016
    13 // Update Count     : 13
     12// Last Modified On : Tue Mar  8 22:04:58 2016
     13// Update Count     : 16
    1414//
    1515
    1616#include <fstream>
    1717
    18 forall( type T | { T ?+?( T, T ); T ?++( T * ); [T] ?+=?( T *, T ); } )
     18forall( otype T | { T ?+?( T, T ); T ?++( T * ); [T] ?+=?( T *, T ); } )
    1919T twice( const T t ) {
    2020        return t + t;
     
    2727        char ?++( char *op ) { char temp = *op; *op += 1; return temp; }
    2828
    29         sout | twice( 'a' ) | ' ' | twice( 1 ) | ' ' | twice( 3.2 ) | endl;
     29        sout | twice( 'a' ) | ' ' | twice( 1 ) | twice( 3.2 ) | endl;
    3030}
    3131
Note: See TracChangeset for help on using the changeset viewer.