Define#
define is a keyword to define a macro. It is similar to copying and pasting: before compiling, the variable ${name} is replaced by the expression
Syntax:
define: Name = expression;
Where name is the name that we want to call the define. Expression can be anything: characters, tokens, rules.
Usage: ${Name}
Example:
define: DayPattern = ((0|1|2)?([:digit:])|3(0|1));
define: MonthPattern = ((0)?([:digit:])|1(0|1|2));
define: YearPattern = ((19|20)?([:digit:]){2});
rule : {
<'${DayPattern}(\.|-|\/)${MonthPattern}(\.|-|\/)${YearPattern}'>
} = Date;
You can put any expression in a define, it does not need to be a string:
define: Props = (<Prop>)+ ;
rule:
{
${Props}
} = Propers;
"I saw John Smith
Propers -> John Smith