OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [lcc/] [tst/] [init.c] - Blame information for rev 206

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 hellwig
 
2
typedef struct { int codes[3]; char name[6]; } Word;
3
 
4
Word words[] = {
5
        1, 2, 3, "if",
6
        { { 4, 5 }, { 'f', 'o', 'r' } },
7
        6, 7, 8, {"else"},
8
        { { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', },
9
        { 0 },
10
}, *wordlist = words;
11
 
12
int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };
13
int *y[] = { x[0], x[1], x[2], 0 };
14
 
15
 
16
main()
17
{
18
        int i, j;
19
 
20
        for (i = 0; y[i]; i++) {
21
                for (j = 0; y[i][j]; j++)
22
                        printf(" %d", y[i][j]);
23
                printf("\n");
24
        }
25
        f();
26
        g(wordlist);
27
        return 0;
28
}
29
 
30
f() {
31
        static char *keywords[] = {"if", "for", "else", "while", 0, };
32
        char **p;
33
 
34
        for (p = keywords; *p; p++)
35
                printf("%s\n", *p);
36
}
37
 
38
g(p)
39
Word *p;
40
{
41
        int i;
42
 
43
        for ( ; p->codes[0]; p++) {
44
                for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++)
45
                        printf("%d ", p->codes[i]);
46
                printf("%s\n", p->name);
47
        }
48
        h();
49
}
50
 
51
h()
52
{
53
        int i;
54
 
55
        for (i = 0; i < sizeof(words)/sizeof(Word); i++)
56
                printf("%d %d %d %s\n", words[i].codes[0],
57
                        words[i].codes[1], words[i].codes[2],
58
                        &words[i].name[0]);
59
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.