Duke Leto Presentations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

21 lines
620 B

CREATE OR REPLACE FUNCTION is_inventory(text) RETURNS integer
LANGUAGE plperl6 AS $q$
($item) {
# This grammar needs a 'my' because the default
# is 'our' i.e. package scope
my grammar Inventory {
regex product { \d+ }
regex quantity { \d+ }
regex color { \S+ }
regex description { \N* }
rule TOP { ^^ <product> <quantity>
[
| <description> '(' \s* <color> \s* ')'
| <color> <description>
]
$$
}
}
return ?Inventory.parse($item);
}
$q$;