meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
choice_points [2020/09/27 00:01] – [Semantic Lookahead] revusky | choice_points [2020/10/27 18:12] – revusky | ||
---|---|---|---|
Line 7: | Line 7: | ||
* The expansions within a //choice construct//, | * The expansions within a //choice construct//, | ||
- | (Perhaps needless to say, all of the above constructs | + | (Perhaps needless to say, all of these constructs arbitrarily combine and nest within one another to an arbitrary level of complexity.) |
- | I think the simplest way to think about the above cases (for most people, anyway) is just in terms of their analogues in a procedural programming language. The first three cases are effectively binary choices, a choice between entering the expansion inside the parentheses and jumping directly to what follows it. In all of these cases, the expansion within the parentheses is a choice point. The last case is a choice between n options and each of the expansions is a choice point. | + | I think the simplest way to think about the above cases (for most people, anyway) is just in terms of their analogues in a procedural programming language. The first three cases are effectively binary choices, a choice between entering the expansion inside the parentheses and jumping directly to what follows it. In all of these cases, the expansion within the parentheses is a choice point. The last case is a choice between n options and each of those n sub-expansions is a choice point in the grammar. |
- | ==== Zero Or More ==== | + | ==== Zero Or One ==== |
- | A //zero-or-more// is a single (non-looping) choice. If the enclosed expansion matches, we enter it, and if not, we jump directly to whatever follows it. So, if we write: | + | A //zero-or-one// is a single (non-looping) choice. If the enclosed expansion matches, we enter it, and if not, we jump directly to whatever follows it. So, if we write: |
< | < | ||
Line 83: | Line 83: | ||
.... | .... | ||
else | else | ||
- | | + | |
</ | </ | ||
Line 104: | Line 104: | ||
Now, to be clear, looking ahead one token might be sufficient or not in any given spot, but if we don't specify any extra information, | Now, to be clear, looking ahead one token might be sufficient or not in any given spot, but if we don't specify any extra information, | ||
- | //We enter an expansion at a choice point if the next token is in that expansion' | + | //We enter an expansion at a choice point if the next token is in that expansion' |
- | Again, no need to be intimidated by the lingo. An expansion' | + | Again, no need to be intimidated by the lingo. An expansion' |
- | //If the next token is **not** in an expansion' | + | //If the next token is **not** in an expansion' |
Now, regardless, it may be the case that more than one of the expansions at a given choice point matches this condition. Well, in that case, we have a secondary rule: //the first one gets it//. And this is really no different, by the way, from how if-elseif-else in a procedural programming language works. | Now, regardless, it may be the case that more than one of the expansions at a given choice point matches this condition. Well, in that case, we have a secondary rule: //the first one gets it//. And this is really no different, by the way, from how if-elseif-else in a procedural programming language works. |