Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 1e4be4f6cca2c9a2bfc532dbed99ff6a > files > 30

aikido-1.40-6mdv2010.0.i586.rpm

/*
 test program for the Aikido C parser example
 */


#include <stdio.h>
#include <stdlib.h>

void factorial (int n) {
    if (n <= 1) {
        return 1 ;
    }
    return n * factorial (n - 1) ;
}

void print_factorials (int n) {
    int i ;
    for (i = 0 ; i < n ; i++) {
        printf ("factorial %d = %d\n", i, factorial (i)) ;
    }
}

enum PointType {
   TYPE1, TYPE2 
} ;

struct Point {
   enum PointType t ;
   int x, y ;
} ;

typedef struct Point Point ;

Point *makePoint (int x, int y) {
    Point *p = (Point *)malloc (sizeof (Point)) ;
    p->x = x ;
    p->y = y ;
    p->t = TYPE2 ;
    return p ;
}