Basics:
Wrap sub-matches in %% example:
%emails% from %date%
This will look for " from " in the query, assign what is left of " from " to a variable emails , and what is right of " from " to a variable date and then call the function defined for that rule, or return the data.
Also, in order to differentiate types of the same name, you can optionally put a : and then the name of a variable you would like it mapped to. For example:
%number:x% + %number:y%
return vars.x + vars.y
Still might consider removing the vars variable and mapping the values directly into the environment:
return x + y
this would only cause an issue if you wanted use a name for a variable that is also a keyword. At this point, thats a pretty minor thing... I'll leave this with a vars table for now. If it gets tedious later, I can change it.
Old Problems:
what about a match like this:
'%number% + %number%'
what are the vars going to be mapped to in this case when the type number occurs more than once. There are a couple possible solutions I see at this point:
- require user to use instead '%number1% + %number2%'
- results in slightly less readable matches
- very obvious which number is going to be assigned to which variable
- allow '%number% + %number%', but map to vars.number1 and vars.number2
- allow '%number% + %number%', but map to vars.number[1] and vars.number[2]
- allow extra names: '%number:num1% + %number:num2%' or 'copy(%memory location:src%, %memory location:dest%
- this makes it very clear which variables are mapped to what rather than just getting var1, var2, etc.
- This is the one implemented