Compiling lex.yy.c with a token in static array?
So, copying the code from [Introduction to Compiler Construction in Unix][iccu] I wind up with the snippet:

<!-- language: c -->

    /* snipped */
    static struct rwtable {               /* reserved word table */
        char *rw_name;                    /* representation */
        int rw_yylex;                     /* yylex() value */
        } rwtable[] = {                   /* sorted */
            "break",                          token(BREAK),
            "continue",                       token(CONTINUE),
            "else",                           token(ELSE),
            "if",                             token(IF),
            "int",                            token(INT),
            "return",                         token(RETURN),
            "while",                          token(WHILE)
        };
    /* snipped */

When I lex the code everything seems fine

<!-- language: bash -->

    $ lex -v samplec.l 
    scanner options: -XvI8 -Cem
    94/2000 NFA states
    38/1000 DFA states (125 words)
    16 rules
    Compressed tables always back-up
    Beginning-of-line patterns used
    1/40 start conditions
    60 epsilon states, 27 double epsilon states
    10/100 character classes needed 144/500 words of storage, 0 reused
    105 state/nextstate pairs created
    62/43 unique/duplicate transitions
    40/1000 base-def entries created
    69/2000 (peak 60) nxt-chk entries created
    2/2500 (peak 30) template nxt-chk entries created
    0 empty table entries
    3 protos created
    2 templates created, 3 uses
    15/256 equivalence classes created
    1/256 meta-equivalence classes created
    2 (1 saved) hash collisions, 27 DFAs equal
    0 sets of reallocations needed
    489 total table entries needed

But, when I compile and link it fails:

<!-- language: bash -->

    $ gcc -DDEBUG lex.yy.c -ll -o lexi
    samplec.l:75: error: initializer element is not constant
    samplec.l:75: error: (near initialization for ‘rwtable[0].rw_yylex’)
    # etc for each token(T)

What's up?

[iccu]: http://www.amazon.com/Introduction-Compiler-Construction-Prentice-Hall-software/dp/0134743962 "Amazon"

Compiling lex.yy.c with a token in static array?
===

So, copying the code from [Introduction to Compiler Construction in Unix][iccu] I wind up with the snippet:

<!-- language: c -->

    /* snipped */
    static struct rwtable {               /* reserved word table */
        char *rw_name;                    /* representation */
        int rw_yylex;                     /* yylex() value */
        } rwtable[] = {                   /* sorted */
            "break",                          token(BREAK),
            "continue",                       token(CONTINUE),
            "else",                           token(ELSE),
            "if",                             token(IF),
            "int",                            token(INT),
            "return",                         token(RETURN),
            "while",                          token(WHILE)
        };
    /* snipped */

When I lex the code everything seems fine

<!-- language: bash -->

    $ lex -v samplec.l 
    scanner options: -XvI8 -Cem
    94/2000 NFA states
    38/1000 DFA states (125 words)
    16 rules
    Compressed tables always back-up
    Beginning-of-line patterns used
    1/40 start conditions
    60 epsilon states, 27 double epsilon states
    10/100 character classes needed 144/500 words of storage, 0 reused
    105 state/nextstate pairs created
    62/43 unique/duplicate transitions
    40/1000 base-def entries created
    69/2000 (peak 60) nxt-chk entries created
    2/2500 (peak 30) template nxt-chk entries created
    0 empty table entries
    3 protos created
    2 templates created, 3 uses
    15/256 equivalence classes created
    1/256 meta-equivalence classes created
    2 (1 saved) hash collisions, 27 DFAs equal
    0 sets of reallocations needed
    489 total table entries needed

But, when I compile and link it fails:

<!-- language: bash -->

    $ gcc -DDEBUG lex.yy.c -ll -o lexi
    samplec.l:75: error: initializer element is not constant
    samplec.l:75: error: (near initialization for ‘rwtable[0].rw_yylex’)
    # etc for each token(T)

What's up?

[iccu]: http://www.amazon.com/Introduction-Compiler-Construction-Prentice-Hall-software/dp/0134743962 "Amazon"
