meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lookbehind [2020/09/25 10:41] – revusky | contextual_predicates [2023/03/03 14:23] (current) – revusky | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | A //lookbehind | + | A //contextual |
The easiest way to describe this is with some actual examples. | The easiest way to describe this is with some actual examples. | ||
- | Probably the most typical usage will be to guarantee that a production is not // | + | ==== Specifying that a production is non-reentrant ==== |
+ | |||
+ | Probably the most typical usage will be to guarantee that a production is not // | ||
< | < | ||
Line 11: | Line 13: | ||
</ | </ | ||
- | First of all, the tilde " | + | First of all, the tilde " |
+ | |||
+ | The above sort of predicate will probably be the most commonly used pattern. However, more complex conditions can be formed. | ||
+ | |||
+ | ==== Scanning Forward vs. Backward, Ellipsis and Wild-card | ||
+ | |||
+ | Note that the elements in a //contextual | ||
- | In the above example, the ellipsis " | + | In the above example, the ellipsis " |
< | < | ||
- | [ SCAN ~\.\Foo => Foo] | + | [ SCAN ~\.\Bar => Foo] |
</ | </ | ||
- | this would mean that we enter the '' | + | this would mean that we enter the '' |
Or alternatively, | Or alternatively, | ||
- | [ SCAN \.\Bar => Foo ] | + | < |
+ | [ SCAN \.\Bar => Foo ] | ||
+ | </ | ||
- | would mean that we enter the '' | + | would mean that we enter the '' |
- | So, consider the following predicate: | + | Now, consider the following predicate |
< | < | ||
Line 33: | Line 43: | ||
</ | </ | ||
- | This means that we enter the Baz production only if the root production is a '' | + | This means that we enter the Baz production only if the root production is a '' |
+ | |||
+ | ==== Optional Ending Slash ==== | ||
If the predicate begins with a forward slash, it may end // | If the predicate begins with a forward slash, it may end // | ||
Line 53: | Line 65: | ||
</ | </ | ||
+ | ==== Summary ==== | ||
- | ===== Recap ===== | + | A //contextual |
- | + | ||
- | A //lookbehind | + | |
An ellipsis " | An ellipsis " | ||
Line 66: | Line 77: | ||
</ | </ | ||
- | The above would mean that we check that we aren't already inside a '' | + | The above would mean that we check that we aren't already inside a '' |
Or alternatively, | Or alternatively, | ||
< | < | ||
- | ( SCAN ~\...\Foo " | + | ( SCAN ~\...\Foo " |
</ | </ | ||
- | In the above we specify that Foo must is // | + | In the above we specify that Foo must be // |
- | NB. If you have a '' | + | NB. If you have a '' |
- | Also note that numerical lookahead and syntactic lookahead | + | Note also that // |