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'
In reply to Parse::RecDescent and AUTOSTUB by hagus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |