diff options
author | Mike Gerwitz <mike.gerwitz@ryansg.com> | 2022-07-14 15:12:57 -0400 |
---|---|---|
committer | Mike Gerwitz <mike.gerwitz@ryansg.com> | 2022-07-14 15:12:57 -0400 |
commit | cf2cd882ca13d90a6953f49dcbec77a56deea08e (patch) | |
tree | ab284be1b562ed84443c8cf766d180ad2421161c /.gitlab-ci.yml | |
parent | 1fdfc0aa4debd74683b61bc278f1c65d6c45a974 (diff) | |
download | tame-main.tar.gz tame-main.tar.bz2 tame-main.zip |
tamer: xir::parse::ele: Introduce sum nonterminalsmain
This introduces `Nt := (A | ... | Z);`, where `Nt` is the name of the
nonterminal and `A ... Z` are the inner nonterminals---it produces a parser
that provides a choice between a set of nonterminals.
This is implemented efficiently by understanding the QName that is accepted
by each of the inner nonterminals and delegating that token immediately to
the appropriate parser. This is a benefit of using a parser generator macro
over parser combinators---we do not need to implement backtracking by
letting inner parsers fail, because we know ahead of time exactly what
parser we need.
This _does not_ verify that each of the inner parsers accept a unique QName;
maybe at a later time I can figure out something for that. However, because
this compiles into a `match`, there is no ambiguity---like a PEG parser,
there is precedence in the face of an ambiguous token, and the first one
wins. Consequently, tests would surely fail, since the latter wouldn't be
able to be parsed.
This also demonstrates how we can have good error suggestions for this
parsing framework: because the inner nonterminals and their QNames are known
at compile time, error messages simply generate a list of QNames that are
expected.
The error recovery strategy is the same as previously noted, and subject to
the same concerns, though it may be more appropriate here: it is desirable
for the inner parser to fail rather than retrying, so that the sum parser is
able to fail and, once the Kleene operator is introduced, retry on another
potential element. But again, that recovery strategy may happen to work in
some cases, but'll fail miserably in others (e.g. placing an unknown element
at the head of a block that expects a sequence of elements would potentially
fail the entire block rather than just the invalid one). But more to come
on that later; it's not critical at this point. I need to get parsing
completed for TAME's input language.
DEV-7145
Diffstat (limited to '.gitlab-ci.yml')
0 files changed, 0 insertions, 0 deletions