Table of Contents
CG-3 is not very strict with how a contextual position looks. Elements such as ** and C can be anywhere before or after the offset number, and even the - for negative offsets does not have to be near the number.
Examples of valid positions:
*-1 1**- W*2C 0**> cC CsW
NEGATE is similar to, yet not the same as, NOT. Where NOT will invert the result of only the immediately following test, NEGATE will invert the result of the entire LINK'ed chain that follows. NEGATE is thus usually used at the beginning of a test. VISLCG emulated the NEGATE functionality for tests that started with NOT.
(**1 SetG CBARRIER (Verb))
These options allows a test to find matching cohorts in any window currently in the buffer. The buffer size can be adjusted with the --num-windows cmdline flag and defaults to 2. Meaning, 2 windows on either side of the current one is preserved, so a total of 5 would be in the buffer at any time.
Allowing a test to span beyond boundaries in either direction is denoted by 'W'. One could also allow all tests to behave in this manner with the --always-span cmdline flag.
By default, linked tests continue from the immediately preceding test. These options affect behavior.
# Look right for (third), then from there look right for (seventh), # then jump back to (target) and from there look right for (fifth) SELECT (target) (1* (third) LINK 1* (seventh) LINK 1*x (fifth)) ; # Look right for (fourth), then from there look right for (seventh) and set that as the mark, # then from there look left for (fifth), then jump back to (seventh) and from there look left for (sixth) SELECT (target) (1* (fourth) LINK 1*X (seventh) LINK -1* (fifth) LINK -1*x (sixth)) ;
'X' sets the mark to the currently active cohort of the test's target. If no test sets X then the mark defaults to the cohort from the rule's target. See also magic set _MARK_.
'x' jumps back to the previously set mark (or the rule's target if no mark is set), then proceeds from there.
'A' sets the cohort to be attached or related against to the currently active cohort of the test's target. See also magic set _ATTACHTO_.
By default, removed reading are not visible to tests. These options allow tests to look at deleted and delayed readings.
'D' allows the current test (and any barrier) to look at readings that have previously been deleted by SELECT/REMOVE/IFF. Delayed readings are not part of 'D', but can be combined as 'Dd' to look at both.
'd' allows the current test (and any barrier) to look at readings that have previously been deleted by SELECT/REMOVE/IFF DELAYED. Deleted readings are not part of 'd', but can be combined as 'Dd' to look at both.
By default, linked scanning tests are allowed to scan past the point of origin. These options affect behavior.
The --no-pass-origin (or -o in short form) changes the default mode to not allow passing the origin, and defines the origin as the target of the currently active rule. This is equivalent to adding 'O' to the first test of each contextual test of all rules.
'O' sets the point of origin to the parent of the contextual test, and disallows itself and all linked tests to pass this point of origin. The reason it sets it to the parent is that otherwise there is no way to mark the rule's target as the desired origin.
# Will not pass the (origin) cohort when looking for (right): SELECT (origin) IF (-1*O (left) LINK 1* (right)) ; # Will not pass the (origin) cohort when looking for (left): SELECT (something) IF (-1* (origin) LINK 1*O (right) LINK -1* (left)) ;
'o' allows the contextual test and all its linked tests to pass the point of origin, even in --no-pass-origin mode. Used to counter 'O'.
# Will pass the (origin) cohort when looking for (right), but not when looking for (middle): SELECT (origin) IF (-1*O (left) LINK 1* (middle) LINK 1*o (right)) ;
Usually a '*' or '**' test scans in only one direction, denoted by the value of the offset; if offset is positive it will scan rightwards, and if negative leftwards. In CG-3 the magic offset '0' will scan in both directions; first one to the left, then one to the right, then two to the left, then two to the right, etc. This makes it easy to find the nearest neighbor that matches. In earlier versions of CG this could be approximated with two seperate rules, and you had to scan entirely in one direction, then come back and do the other direction.
Caveat: (NOT 0* V) will probably not work as you expect; it will be true if either direction doesn't find set V. What you want instead is (NEGATE 0* V) or split into (NOT -1* V) (NOT 1* V).
(0* (someset)) (0**W (otherset))
CG-3 also introduces the p, c, cc, and s positions. See the section about those in the Dependencies chapter.
CG-3 also introduces the r:rel and r:* positions. See the section about those in the Relations chapter.