schrodinger.application.desmond.antlr3.dfa module

ANTLR3 runtime package

class schrodinger.application.desmond.antlr3.dfa.DFA(recognizer, decisionNumber, eot, eof, min, max, accept, special, transition)

Bases: object

@brief A DFA implemented as a set of transition tables.

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 cyclicDFA template.

__init__(recognizer, decisionNumber, eot, eof, min, max, accept, special, transition)

From the input stream, predict what alternative will succeed using this DFA (representing the covering regular approximation to the underlying CFL). Return an alternative number 1..n. Throw an exception upon error.

noViableAlt(s, input)

A hook for debugging interface

specialStateTransition(s, input)
classmethod unpack(string)

@brief Unpack the runlength encoded table data.

Terence implemented packed table initializers, because Java has a size restriction on .class files and the lookup tables can grow pretty large. The generated of the Java.g example would be about 15MB with uncompressed array initializers.

Python does not have any size restrictions, but the compilation of such large source files seems to be pretty memory hungry. The memory consumption of the python process grew to >1.5GB when importing a 15MB lexer, eating all my swap space and I was to impacient to see, if it could finish at all. With packed initializers that are unpacked at import time of the lexer module, everything works like a charm.