diff --git a/Help/markdown/NLP_PP_Stuff/Phrase_element_modifiers.md b/Help/markdown/NLP_PP_Stuff/Phrase_element_modifiers.md index 377ee4c..61c2d8c 100644 --- a/Help/markdown/NLP_PP_Stuff/Phrase_element_modifiers.md +++ b/Help/markdown/NLP_PP_Stuff/Phrase_element_modifiers.md @@ -24,6 +24,7 @@ Element modifiers that can be used in a rule's phrase are listed in the table be | [lookahead](../lookahead.md), [look](../look.md) | NONE | Designate the first lookahead element of a rule. The first node matching the lookahead element or to the right of it will be the locus where the rule matcher *continues* matching. WARNING: A reduce action such as *singler* or *noop* should be used to ensure that the lookahead node and nodes to its right are not included in the current rule reduction. | | [layers](../layers.md), [layer](../layer.md), [attrs](../attrs.md), [attr](../attr.md) | LIST | Layer additional attributes for the element in the parse tree, as "mini-reductions". Use the names in the list to name nodes. Note: each node that matched current rule element will be layered. (These modifiers can also be used as suggested element modifiers.) | | [recurse](../RECURSE.md), [nest](../nest.md), [passes](../passes.md), [pass](../pass.md) | LIST | Invoke a recursive rules pass on nodes that matched the current rule element. E.g., *_tag <- \< _xWILD [****nest=(tagrules)****] \> @@. *(See RECURSE Region.) | +| var, varz, vareq, varne, vargt, varlt, regexp, regexpi, uppercase, lowercase, cap, length, lengthr, numrange, unknown, debug | NONE, VALUE or LIST | A [PRE Action](../PRE.md) on this element, written as a key: the same as that action in a PRE region with this element's number as its range. E.g., *_np <- _det _xWILD [plus match=(_noun _adj) ****vareq=("pos" "noun")****] @@*. See [Conditions on the Element Itself](../PRE.md). **NEW 4.2.26** | | **WARNING**: Don't write rules with _xANY [max=0]. They won't work, because _xANY is not implemented as a wildcard. The nearly equivalent _xANY _xWILD works. More generally, matching with MIN and MAX is *greedy*, and no *backup* is implemented. So the rule _a <- _b [min=1 max=3] _c [s] @@ fails on the phrase **_b _b(subnode _c**), because the repeating _b element greedily gobbles up the second _b node. The rule matcher will not back up to find that the rule can be made to work. Unrestricted _xWILD is the **only** rule element that is "backup-aware". | | --- | diff --git a/Help/markdown/PRE.md b/Help/markdown/PRE.md index 68a461f..7828060 100644 --- a/Help/markdown/PRE.md +++ b/Help/markdown/PRE.md @@ -43,6 +43,29 @@ This matches `one two three` when neither `two` nor the spaces around it has a ` **NEW 4.2.20**: before this version, a wildcard with a PRE Action did not stop at the next rule element. It ran past it, so a rule like the second example never matched. +## Conditions on the Element Itself + +A PRE Action can also be written as a key on the rule element it applies to, so there is no range to keep in step with the element's position. The key is the action's name, and its value is the action's arguments: a single value, or a list in parentheses for several. An action with no arguments is written by name alone. + +``` +@RULES +_np <- _det _xWILD [plus match=(_noun _adj) vareq=("pos" "noun") varz="num"] @@ +``` + +means the same as + +``` +@PRE +<2,2> vareq("pos", "noun"); +<2,2> varz("num"); +@RULES +_np <- _det _xWILD [plus match=(_noun _adj)] @@ +``` + +Every PRE Action can be written this way: **var**, **varz**, **vareq**, **varne**, **vargt**, **varlt**, **regexp**, **regexpi**, **uppercase**, **lowercase**, **cap**, **length**, **lengthr**, **numrange**, **unknown** and **debug**. For example, `_xALPHA [cap]`, `_xNUM [numrange=(5 10)]`, `_xALPHA [regexp="t*"]`. Conditions on an element and a PRE region on the same rule both apply. A wildcard with a condition behaves as described under PRE Actions on a Wildcard. + +**NEW 4.2.26** + ## See Also [Grammar Region](NLP_PP_Stuff/Grammar_Region.md)