src/antlr3cyclicdfa.c(3)
π NAME π
src/antlr3cyclicdfa.c β okay so this is the page for it, bestie, and it lives in the ANTLR3C manual, section 3. Yes it's a whole C source file getting its own manual page. Iconic behaviour honestly. π
β¨ SYNOPSIS β¨
#include <antlr3defs.h>
#include <antlr3cyclicdfa.h>
π Functions
ANTLR3_API ANTLR3_INT32 antlr3dfapredict (void *ctx, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_INT_STREAM is, pANTLR3_CYCLIC_DFA cdfa)β reads the input stream and predicts which alternative is gonna win, using this DFA (which is the covering regular approximation to the underlying CFL, no big deal). Slay.ANTLR3_API ANTLR3_INT32 antlr3dfaspecialStateTransition (void *ctx, pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, pANTLR3_CYCLIC_DFA dfa, ANTLR3_INT32 s)β the default special state implementation, periodt.ANTLR3_API ANTLR3_INT32 antlr3dfaspecialTransition (void *ctx, pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, pANTLR3_CYCLIC_DFA dfa, ANTLR3_INT32 s)static void noViableAlt (pANTLR3_BASE_RECOGNIZER rec, pANTLR3_CYCLIC_DFA cdfa, ANTLR3_UINT32 s)β support functions for traversing cyclic DFA states as laid out in static initialized structures by the code generator. The lore.
π¦ Function Documentation π¦
β ANTLR3_API ANTLR3_INT32 antlr3dfapredict (void * ctx, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_INT_STREAM is, pANTLR3_CYCLIC_DFA cdfa)
So what it does: from the input stream, it predicts what alternative will succeed using this DFA (which represents the covering regular approximation to the underlying CFL). It returns an alternative number 1..n. And if something goes wrong? It throws an exception upon error. π No soft launch, just vibes.
References:
ANTLR3_INT_STREAM_struct::_LAANTLR3_CYCLIC_DFA_struct::acceptANTLR3_TOKEN_EOFANTLR3_TRUEANTLR3_INT_STREAM_struct::consumeANTLR3_CYCLIC_DFA_struct::eofANTLR3_CYCLIC_DFA_struct::eotANTLR3_RECOGNIZER_SHARED_STATE_struct::errorANTLR3_INT_STREAM_struct::markmark()ANTLR3_CYCLIC_DFA_struct::minnoViableAlt()ANTLR3_INT_STREAM_struct::rewindANTLR3_CYCLIC_DFA_struct::specialANTLR3_CYCLIC_DFA_struct::specialStateTransitionANTLR3_BASE_RECOGNIZER_struct::stateANTLR3_CYCLIC_DFA_struct::transition
π ANTLR3_API ANTLR3_INT32 antlr3dfaspecialStateTransition (void * ctx, pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, pANTLR3_CYCLIC_DFA dfa, ANTLR3_INT32 s)
Default special state implementation. That's it. That's the whole description. Short king energy. π
πΈ ANTLR3_API ANTLR3_INT32 antlr3dfaspecialTransition (void * ctx, pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, pANTLR3_CYCLIC_DFA dfa, ANTLR3_INT32 s)
(no description given, bestie β it's just sitting there being a function. mysterious. we love that for it. π)
π§ void noViableAlt (pANTLR3_BASE_RECOGNIZER rec, pANTLR3_CYCLIC_DFA cdfa, ANTLR3_UINT32 s) β [static]
These are the support functions for traversing cyclic DFA states as laid out in static initialized structures by the code generator. A DFA implemented as a set of transition tables, fr fr.
Okay so here's the tea π΅: any state that has a semantic predicate edge is special; those states are generated with if-then-else structures in a ->specialStateTransition() which is generated by the cyclicDFA template.
And now the numbers part, because we're nothing if not precise:
- There are at most 32767 states (16-bit signed short). Could get away with byte sometimes but would have to generate different types and the simulation code too. So. Trade-offs. β¨
- For a point of reference, the Java lexer's Tokens rule DFA has 326 states roughly.
References:
ANTLR3_NO_VIABLE_ALT_EXCEPTIONANTLR3_TRUEANTLR3_RECOGNIZER_SHARED_STATE_struct::backtrackingANTLR3_EXCEPTION_struct::decisionNumANTLR3_CYCLIC_DFA_struct::decisionNumberANTLR3_CYCLIC_DFA_struct::descriptionANTLR3_RECOGNIZER_SHARED_STATE_struct::exceptionANTLR3_BASE_RECOGNIZER_struct::exConstructANTLR3_RECOGNIZER_SHARED_STATE_struct::failedANTLR3_EXCEPTION_struct::messageANTLR3_BASE_RECOGNIZER_struct::stateANTLR3_EXCEPTION_struct::stateANTLR3_EXCEPTION_struct::type
Referenced by: antlr3dfapredict()
π«Ά Author π«Ά
Generated automatically by Doxygen for ANTLR3C from the source code. Not a human author, just the machine doing its little thing. π€π
And that's the whole page, bestie! Version 3.3.1, dated Tue Jul 29 2025 00:00:00, and yeah β it's src/antlr3cyclicdfa.c(3) if you need to cite it. Byeee π
β¨π
π¦ where this page comes from
- fedora 43: antlr3-C-devel 1:3.4-3.5.3.14.fc43 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms