parser/c_compiler/main.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Thu, 16 Apr 2009 12:49:12 +0200
changeset 47 63adb261de90
parent 37 0fbbe329c3a2
child 48 b94d657a9acb
permissions -rw-r--r--
tree is a list :P * anyway, some changes here -> a struct T consumes sizeof(struct T) of memory -> actual wasn't really needed here. thrown away. committer: Markus Bröker <mbroeker@largo.homelinux.org>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     1
/**
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     2
 * test/demos/parser/c_compiler/main.c
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     3
 * Copyright (C) 2008 Markus Broeker
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     4
 */
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     5
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     6
#include <stdio.h>
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     7
#include <stdlib.h>
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     8
#include <string.h>
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
     9
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    10
#include <prototypes.h>
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    11
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    12
extern FILE *yyin;
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    13
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    14
void usage (char *cmd)
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    15
{
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    16
    printf ("Usage: %s <options> <source files>\n", cmd);
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    17
}
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    18
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    19
int main (int argc, char **argv)
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    20
{
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    21
    FILE *fp;
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    22
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    23
    if (argc < 2) {
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    24
        usage (argv[0]);
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    25
        return EXIT_SUCCESS;
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    26
    }
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    27
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    28
    if ((fp = fopen (argv[1], "r")) == NULL) {
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    29
        perror ("FOPEN");
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    30
        return EXIT_FAILURE;
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    31
    }
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    32
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    33
    yyin = fp;
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    34
    yyparse ();
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    35
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    36
    fclose (fp);
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    37
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    38
    return EXIT_SUCCESS;
0fbbe329c3a2 demos/parser
Markus Bröker <mbroeker@largo.localnet>
parents:
diff changeset
    39
}