Changeset b63e376 for src/examples
- Timestamp:
- Mar 8, 2016, 10:24:43 PM (10 years ago)
- 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
- Location:
- src/examples
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/fstream_test.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 15:12:21201613 // Update Count : 5 112 // Last Modified On : Sun Mar 6 20:58:29 2016 13 // Update Count : 54 14 14 // 15 15 … … 28 28 int i, j, k; 29 29 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; 31 31 } 32 32 -
src/examples/huge.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 27 18:15:34 201513 // Update Count : 112 // Last Modified On : Tue Mar 8 22:16:32 2016 13 // Update Count : 2 14 14 // 15 15 16 int huge( int n, forall( type T ) T (*f)( T ) ) {16 int huge( int n, forall( otype T ) T (*f)( T ) ) { 17 17 if ( n <= 0 ) 18 18 return f( 0 ); -
src/examples/identity.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Feb 29 23:40:45201613 // Update Count : 1 212 // Last Modified On : Tue Mar 8 22:15:08 2016 13 // Update Count : 13 14 14 // 15 15 16 16 #include <fstream> 17 17 18 forall( type T )18 forall( otype T ) 19 19 T identity( T t ) { 20 20 return t; -
src/examples/includes.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 21 13:54:09 201513 // Update Count : 32 212 // Last Modified On : Wed Mar 2 23:28:02 2016 13 // Update Count : 328 14 14 // 15 15 … … 43 43 #include <ctype.h> 44 44 #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> 47 47 #include <dirent.h> 48 48 #include <dis-asm.h> … … 56 56 #include <err.h> 57 57 #include <errno.h> 58 #if 0 58 59 #include <error.h> 60 #endif 61 #include <eti.h> 62 #include <evdns.h> 63 #include <event.h> 64 #include <evhttp.h> 59 65 #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"64 66 #include <evrpc.h> 65 67 #include <evutil.h> 66 68 #include <execinfo.h> 67 #include <expat.h> // enum / contains "type" and "context"69 #include <expat.h> 68 70 #include <expat_config.h> 69 71 #include <expat_external.h> … … 74 76 #include <fmtmsg.h> 75 77 #include <fnmatch.h> 76 #include <form.h> // contains "type"78 #include <form.h> 77 79 #include <fpu_control.h> 78 80 #include <fstab.h> … … 81 83 #include <ftw.h> 82 84 #include <gconv.h> 83 //#include <gcrypt.h> // enum / contains "type"85 //#include <gcrypt.h> 84 86 //#include <gcrypt-module.h> 85 87 #include <getopt.h> … … 107 109 #include <limits.h> 108 110 #include <locale.h> 109 #include <math.h> // contains "type"111 #include <math.h> 110 112 #include <ncurses.h> 111 113 #include <setjmp.h> -
src/examples/it_out.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 18:11:00201613 // Update Count : 512 // Last Modified On : Tue Mar 8 22:14:39 2016 13 // Update Count : 8 14 14 // 15 15 … … 21 21 }; 22 22 23 trait writeable( type T ) {23 trait writeable( otype T ) { 24 24 forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, T ); 25 25 }; … … 36 36 }; 37 37 38 trait readable( type T ) {38 trait readable( otype T ) { 39 39 forall( dtype is_type | istream( is_type ) ) is_type * ?<<?( is_type *, T ); 40 40 }; … … 43 43 forall( dtype is_type | istream( is_type ) ) is_type * ?>>?( is_type *, int* ); 44 44 45 trait iterator( type iterator_type,type elt_type ) {45 trait iterator( otype iterator_type, otype elt_type ) { 46 46 iterator_type ?++( iterator_type* ); 47 47 iterator_type ++?( iterator_type* ); … … 52 52 }; 53 53 54 forall( type elt_type | writeable( elt_type ),55 type iterator_type | iterator( iterator_type, elt_type ),54 forall( otype elt_type | writeable( elt_type ), 55 otype iterator_type | iterator( iterator_type, elt_type ), 56 56 dtype os_type | ostream( os_type ) ) 57 57 void write_all( iterator_type begin, iterator_type end, os_type *os ); 58 58 59 forall( type elt_type | writeable( elt_type ),60 type iterator_type | iterator( iterator_type, elt_type ),59 forall( otype elt_type | writeable( elt_type ), 60 otype iterator_type | iterator( iterator_type, elt_type ), 61 61 dtype os_type | ostream( os_type ) ) 62 62 void write_all( elt_type begin, iterator_type end, os_type *os ) { -
src/examples/new.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 25 23:33:55201613 // Update Count : 212 // Last Modified On : Tue Mar 8 22:13:20 2016 13 // Update Count : 4 14 14 // 15 15 16 forall( type T )16 forall( otype T ) 17 17 void f( T *t ) { 18 18 t--; -
src/examples/prolog.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 18:11:18201613 // Update Count : 212 // Last Modified On : Tue Mar 8 22:09:39 2016 13 // Update Count : 5 14 14 // 15 15 16 extern "C" { extern int printf( const char *fmt, ... ); } 16 #include <fstream> 17 17 18 void printResult( int x ) { printf( "int\n" ); }19 void printResult( double x ) { printf( "double\n" ); }20 void printResult( char * x ) { printf( "char*\n" ); }18 void printResult( int x ) { sout | "int" | endl; } 19 void printResult( double x ) { sout | "double" | endl; } 20 void printResult( char * x ) { sout | "char*" | endl; } 21 21 22 22 void is_arithmetic( int x ) {} … … 25 25 void is_integer( int x ) {} 26 26 27 trait ArithmeticType( type T ) {27 trait ArithmeticType( otype T ) { 28 28 void is_arithmetic( T ); 29 29 }; 30 30 31 trait IntegralType( type T | ArithmeticType( T ) ) {31 trait IntegralType( otype T | ArithmeticType( T ) ) { 32 32 void is_integer( T ); 33 33 }; 34 34 35 forall( type T | IntegralType( T ) | { void printResult( T ); } )35 forall( otype T | IntegralType( T ) | { void printResult( T ); } ) 36 36 void hornclause( T param ) { 37 37 printResult( param ); -
src/examples/quad.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 1 08:24:56201613 // Update Count : 712 // Last Modified On : Tue Mar 8 22:07:02 2016 13 // Update Count : 8 14 14 // 15 15 16 16 #include <fstream> 17 17 18 forall( type T | { T ?*?( T, T ); } )18 forall( otype T | { T ?*?( T, T ); } ) 19 19 T square( T t ) { 20 20 return t * t; 21 21 } 22 22 23 forall( type U | { U square( U ); } )23 forall( otype U | { U square( U ); } ) 24 24 U quad( U u ) { 25 25 return square( square( u ) ); -
src/examples/simplePoly.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 27 18:31:17 201513 // Update Count : 212 // Last Modified On : Tue Mar 8 22:06:41 2016 13 // Update Count : 3 14 14 // 15 15 16 forall( type T,type U | { T f( T, U ); } )16 forall( otype T, otype U | { T f( T, U ); } ) 17 17 T q( T t, U u ) { 18 18 return f( t, u ); -
src/examples/simpler.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 27 18:31:48 201513 // Update Count : 112 // Last Modified On : Tue Mar 8 22:06:30 2016 13 // Update Count : 2 14 14 // 15 15 16 forall( type T ) T id( T, T );16 forall( otype T ) T id( T, T ); 17 17 18 18 int main() { -
src/examples/specialize.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 27 18:32:26 201513 // Update Count : 212 // Last Modified On : Tue Mar 8 22:06:17 2016 13 // Update Count : 3 14 14 // 15 15 … … 39 39 } 40 40 41 forall( type T ) T f( T t )41 forall( otype T ) T f( T t ) 42 42 { 43 43 printf( "in f; sizeof T is %d\n", sizeof( T ) ); -
src/examples/square.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 17 12:21:58 201613 // Update Count : 2 612 // Last Modified On : Tue Mar 8 22:05:48 2016 13 // Update Count : 27 14 14 // 15 15 16 16 #include <fstream> 17 17 18 forall( type T | { T ?*?( T, T ); } )18 forall( otype T | { T ?*?( T, T ); } ) 19 19 T square( T t ) { 20 20 return t * t; -
src/examples/sum.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 18:12:01201613 // Update Count : 19 412 // Last Modified On : Fri Mar 4 15:06:47 2016 13 // Update Count : 196 14 14 // 15 15 16 16 #include <fstream> 17 17 18 trait sumable( type T ) {18 trait sumable( otype T ) { 19 19 const T 0; 20 20 T ?+?( T, T ); … … 24 24 }; // sumable 25 25 26 forall( type T | sumable( T ) )26 forall( otype T | sumable( T ) ) 27 27 T sum( unsigned int n, T a[] ) { 28 28 T total = 0; // instantiate T, select 0 -
src/examples/twice.c
r4040425 rb63e376 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 17 12:23:25201613 // Update Count : 1 312 // Last Modified On : Tue Mar 8 22:04:58 2016 13 // Update Count : 16 14 14 // 15 15 16 16 #include <fstream> 17 17 18 forall( type T | { T ?+?( T, T ); T ?++( T * ); [T] ?+=?( T *, T ); } )18 forall( otype T | { T ?+?( T, T ); T ?++( T * ); [T] ?+=?( T *, T ); } ) 19 19 T twice( const T t ) { 20 20 return t + t; … … 27 27 char ?++( char *op ) { char temp = *op; *op += 1; return temp; } 28 28 29 sout | twice( 'a' ) | ' ' | twice( 1 ) | ' ' |twice( 3.2 ) | endl;29 sout | twice( 'a' ) | ' ' | twice( 1 ) | twice( 3.2 ) | endl; 30 30 } 31 31
Note:
See TracChangeset
for help on using the changeset viewer.