[antlr-interest] In C how do I determine if a parameter is present
Jim Idle
jimi at temporal-wave.com
Fri Dec 31 17:08:50 PST 2010
Don't use the $db, either declare a Boolean and set in an action, or just
use two actions:
^(table=id
( db = id { action when present }
| {action when not present}
)
)
Look at the generated code to see why comparing to NULL (should not use 0
these days) faults. The return type is a struct, not a pointer. See
antlr.markmail.org for why there are not initializations on things.
Jim
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Jeffrey Newman
> Sent: Friday, December 31, 2010 4:52 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] In C how do I determine if a parameter is
> present
>
>
> Hi,
> I'm trying to determine if db is present.
> I have not figured out how to do this.
> The java exmple in the book (like I have below) says missing an
> attribute.
> I tired text and it faults (start is invalid).
>
> Some body please help.
>
> thanks
>
> Jeffrey
>
>
>
> // DROP TABLE
> drop_table_stmt
> : ^(DROP_TABLE ^(OPTIONS EXISTS?) ^(table = id db = id?))
>
> {
> if ($db == 0) {
> sprintf(buffer, "Walker: Drop Table (table name:
\%s",
>
$table.text->chars);
> }
> else {
> sprintf(buffer, "Walker: Drop Table (table name:
\%s db
> name: \%s",
>
$table.text->chars, $db.text-
> >chars);
> }
> debug(buffer);
> }
> ;
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address
More information about the antlr-interest
mailing list