TOC Toolkit API - v0.1.0
    Preparing search index...

    toc-toolkit/machines/pushdown

    Converts between checked pushdown machines and context-free grammars. Each conversion returns the result with construction frames, and the grammar direction keeps the source transition of every production.

    • Grammar to PDA. Builds a one-control machine that accepts by empty stack. It expands each variable by a production and matches each terminal. (cfgToPda, buildCfgPda)
    • LL(1) grammar to DPDA. Stores one consumed lookahead in the control and expands the original productions through a conflict-free predictive table. An overlapping predictive cell returns its variable and lookahead. (ll1ToDpda, PredictiveTable)
    • LR(1) grammar to DPDA. Runs shifts and original-production reductions from a conflict-free canonical table. An overlapping action cell returns its state and lookahead. (lr1ToDpda, ShiftReduceTable)
    • DPDA completion and complement. Resolves finite epsilon head dependencies, replaces epsilon divergence by virtual halts, and completes input reads. Annotated stack suffixes and a prefix acceptance component retain acceptance reached between reads. Inverting that component complements over the declared input alphabet. (completeDpda, complementDpda)
    • PDA to grammar by productive returns. Protects the original stack bottom, normalizes every transition to pop one symbol and push at most two, and saturates the triples of control, stack symbol and control that a run can return through. It keeps only the reachable productive grammar. (pdaToCfg, buildPdaGrammar, buildPdaGrammarBounded)
    • Frame explanation. Describes a construction frame in words. (explainPushdownFrame)
    • Normalized PDA. A machine with dense ids that pops exactly one symbol on each step, printed as text. (dumpNormalPda)
    • Summary meanings. Records what each return variable of the grammar stands for. (SummaryMeaning)
    • Production origins. Records the source transition of each production. (productionOriginDecoder)
    • Construction frames. The retained steps of a conversion. (PushdownFrame)
    • Conversion results. The machine, the grammar and the frames that a conversion returns. (PushdownMachine, PdaGrammarResult, PdaToCfgResult, CfgToPdaResult)
    • Decoders. Read a machine, a frame, a summary meaning and a production origin back from plain data. (pushdownMachineDecoder, pushdownFrameDecoder, summaryMeaningDecoder, productionOriginDecoder, expandFrameDecoder, keepFrameDecoder, matchFrameDecoder, normalizeFrameDecoder, protectFrameDecoder, pushdownIssueDecoder, startFrameDecoder, summarizeFrameDecoder)
    • Deterministic table issues. Retain the conflicting variable or state and lookahead, and decode the issue from plain data. (DeterministicIssue, DeterministicIssueCode, deterministicIssueDecoder)
    • Enumerations. Name the closed sets of strings that the types and the wire data of the package use. (PushdownFrameKind, PushdownIssueCode)

    A missing conflict lookahead denotes end of input.

    The deterministic constructions keep the input alphabet unchanged. A read step stores its lookahead in the control. Expansions and reductions then use epsilon steps while that lookahead is held, and a match or shift returns to the reading control. Each control and stack top has at most one applicable epsilon step or one read for each input symbol, so the checked output is a DPDA.

    End-of-input reductions define a regular set of parser stacks. Saturation begins with the exact accepting stacks and adds the predecessors of every original end reduction. A finite run of end reductions gives a predecessor path by induction on its length. Each added edge also has such a run by induction on the saturation steps. The saturated language therefore contains exactly the stacks from which the parser accepts at end of input.

    Each stack symbol stores the finite predecessor summary of the suffix beneath it. A push computes the new summaries, and a pop exposes the saved one. The reading control is accepting exactly when its current summary admits end-of-input acceptance. Reading another symbol continues parsing from that control, so acceptance observes the entire word without an extra input marker. LL end acceptance computes the least nullable set from original productions. Conservative table supersets cannot make a nonnullable stack accept.