Table of Contents
A new feature in CG-3 is handling of enclosures by defining pairs of parentheses. Any enclosure found will be omitted from the window on first run, then put back in the window and all rules are re-run on the new larger window. This continues until all enclosures have been put back one-by-one.
The idea is that by omitting the enclosures their noise cannot disrupt disambiguation, thus providing an easy way to write clean grammars that do not have to have special tests for parentheses all over the place.
Example is adapted from the ./test/T_Parentheses/ regression test.
Given the following sentence:
There once were (two [three] long red (more like maroon (dark earthy red]), actually) cars {trucks}.
...and given the following parenthesis wordform pairs:
PARENTHESES = ("<(>" "<)>") ("<[>" "<]>") ("<{>" "<}>") ;
...results in the sentence being run in the order of:
1: There once were (two long red cars. 2: There once were (two [three] long red cars. 3: There once were (two [three] long red (more like maroon, actually) cars. 4: There once were (two [three] long red (more like maroon (dark earthy red]), actually) cars. 5: There once were (two [three] long red (more like maroon (dark earthy red]), actually) cars {trucks}.
The example has 2 unmatched parenthesis in the words (two and red] which are left in untouched as they are not really enclosing anything.
Note that enclosures are put back in the window left-to-right and only one at the time. The depth of enclosure has no effect on the order of resurrection. This may seem unintuitive, but it was the most efficient way of handling it.
Also of note is that all rules in all sections will be re-run each time an enclosure is resurrected. This includes BEFORE-SECTIONS and AFTER-SECTIONS. So in the above example, all of those are run 5 times.
In a contextual test you can jump to the leftward parenthesis of the currently active enclosure with the L position. It is only valid from within the enclosure.
(L (*) LINK 1* (V) BARRIER _RIGHT_)
In a contextual test you can jump to the rightward parenthesis of the currently active enclosure with the R position. It is only valid from within the enclosure.
(R (*) LINK -1* (V) BARRIER _LEFT_)
A magic tag that represents the active enclosure's leftward parenthesis wordform. This tag is only valid when an enclosure is active and only exactly on the leftward parenthesis cohort. Useful for preventing scanning tests from crossing it with a barrier.
A magic tag that represents the active enclosure's rightward parenthesis wordform. This tag is only valid when an enclosure is active and only exactly on the rightward parenthesis cohort. Useful for preventing scanning tests from crossing it with a barrier.
This tag is only valid when an enclosure is hidden away and only on cohorts that own hidden cohorts. Useful for preventing scanning tests from crossing hidden enclosures with a barrier.