Marpa

Artifact [3a1a1e4786]
Login

Artifact [3a1a1e4786]

Artifact 3a1a1e4786f1370d3c5d9c262d6daf2a7882395e9785305a8fbd256bf033328e:


/* Runtime for C-engine (RTC). Declarations. (Engine: Lexer gating)
 * - - -- --- ----- -------- ------------- ---------------------
 * (c) 2017-2018 Andreas Kupries
 */

#ifndef MARPATCL_RTC_GATE_H
#define MARPATCL_RTC_GATE_H

/*
 * - - -- --- ----- -------- ------------- ---------------------
 * Requirements
 */

#include <byteset.h>
#include <stack.h>
#include <rtc.h>

/*
 * - - -- --- ----- -------- ------------- ---------------------
 * Structures
 */

typedef struct marpatcl_rtc_gate {
    int                  lastchar;   /* last character entered into the gate */
    int                  lastloc;    /* Location of the `lastchar` (byte offset) */
    int                  lastcloc;   /* Same, as char offset */
    int                  flushed;    /* Flushing state */
    marpatcl_rtc_stack_p history;    /* History of the current match attempt */
    marpatcl_rtc_stack_p pending;    /* Scratch stack for history replay */
    marpatcl_rtc_byteset acceptable; /* Set of acceptable byte (symbols) */
} marpatcl_rtc_gate;

/*
 * - - -- --- ----- -------- ------------- ---------------------
 * API - lifecycle, accessors, mutators
 *
 * init       - initialize a gate
 * free       - release gate state
 * enter      - push a single byte of input
 * eof        - signal the end of the input
 * acceptable - information from lexer about acceptable bytes
 * redo       - reset to and replay the last n bytes entered
 */

void marpatcl_rtc_gate_init       (marpatcl_rtc_p p);
void marpatcl_rtc_gate_free       (marpatcl_rtc_p p);
void marpatcl_rtc_gate_enter      (marpatcl_rtc_p p, unsigned char ch); /* location implied */
void marpatcl_rtc_gate_eof        (marpatcl_rtc_p p);
void marpatcl_rtc_gate_acceptable (marpatcl_rtc_p p);
void marpatcl_rtc_gate_redo       (marpatcl_rtc_p p, int n);
/* TODO: get-context, extend-context */

#endif

/*
 * - - -- --- ----- -------- ------------- ---------------------
 */

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */