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 08:28] – [Recap] revusky | contextual_predicates [2023/03/03 14:23] (current) – revusky | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | The '' | + | A // |
- | Probably the most typical usage will be to guarantee that a production is not // | + | The easiest way to describe this is with some actual examples. |
+ | |||
+ | ==== Specifying that a production is non-reentrant ==== | ||
+ | |||
+ | Probably the most typical usage will be to guarantee that a production is not // | ||
< | < | ||
Line 9: | Line 13: | ||
</ | </ | ||
- | First of all, the tilde " | + | First of all, the tilde " |
- | In the above example, the ellipsis " | + | 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 // | ||
+ | |||
+ | 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 31: | 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 '' |
- | If the predicate begins with a forward slash, it may end // | + | ==== Optional Ending Slash ==== |
+ | |||
+ | If the predicate begins with a forward slash, it may end // | ||
< | < | ||
Line 51: | Line 65: | ||
</ | </ | ||
+ | ==== Summary ==== | ||
+ | |||
+ | A // | ||
+ | |||
+ | An ellipsis " | ||
+ | |||
+ | A //lookahead predicate// can be combined with other conditions in a '' | ||
+ | |||
+ | < | ||
+ | ( SCAN 2 ~\...\Foo => Foo )* | ||
+ | </ | ||
+ | |||
+ | The above would mean that we check that we aren't already inside a '' | ||
+ | |||
+ | Or alternatively, | ||
+ | |||
+ | < | ||
+ | ( SCAN ~\...\Foo " | ||
+ | </ | ||
- | ===== Recap ===== | + | In the above we specify that Foo must be // |
- | A //lookbehind predicate// starts optionally with a tilde " | + | NB. If you have a '' |
+ | Note also that // | ||