hagus has asked for the wisdom of the Perl Monks concerning the following question:
At the moment I'm experimenting with AUTOSTUB to get the key_or_not_null bit working. In BNF it looks like:my $grammar = q{ startrule: create_table_syntax create_table_syntax: 'CREATE TABLE' '(' column_definition(s /,/) + ')' column_definition: column_name data_type column_attributes(?) column_name: /\w+/ data_type: "INT" | "VARCHAR" column_attributes: key_or_not_null key_or_not_null: primary(?) 'KEY' }
As I understand it, the square braces around PRIMARY indicate that it can be matched "zero or one" times. So I tried "primary"(?) in PRD grammar and that bombed. Now I'm trying primary(?) with AUTOSTUB turned on and that's bombing too. I really don't want to have to make a subrule that just says:<key_or_not_null_spec> ::= [PRIMARY] KEY | NOT NULL [WITH DEFAULT]
But I don't really like the idea of using AUTOSTUB either - it seems kludgy. Ideally I want to be able to say "match this literal string zero or one times". Should I use a regex? Or is there some PRD grammar wisdom that I'm missing?primary: 'primary'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parse::RecDescent and AUTOSTUB
by Abigail-II (Bishop) on Jan 29, 2004 at 09:24 UTC | |
by hagus (Monk) on Jan 29, 2004 at 23:21 UTC | |
by Abigail-II (Bishop) on Jan 29, 2004 at 23:24 UTC | |
by hagus (Monk) on Jan 29, 2004 at 23:57 UTC | |
|
Re: Parse::RecDescent and AUTOSTUB
by allolex (Curate) on Jan 29, 2004 at 15:25 UTC | |
|
Re: Parse::RecDescent and AUTOSTUB
by Stevie-O (Friar) on Jan 29, 2004 at 23:09 UTC |