From 2e893fd0df7dae8c4ae843d4a23acb098dd97aff Mon Sep 17 00:00:00 2001 From: filip <“filip.rabiega@gmail.com”> Date: Tue, 22 Apr 2025 18:38:38 +0200 Subject: added a functional parser --- lib/lexing/headers.ml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/lexing/headers.ml (limited to 'lib/lexing/headers.ml') diff --git a/lib/lexing/headers.ml b/lib/lexing/headers.ml new file mode 100644 index 0000000..2452eec --- /dev/null +++ b/lib/lexing/headers.ml @@ -0,0 +1,23 @@ +(* Types for lexing *) + +open Types + +(* Exceptions to aid control flow for lexer *) +exception Not_In_Alphabet of char +exception No_Transition of int * char + +(* Tagged Deterministice Finite Automaton *) +type tdfa = { + alphabet : char list; + start_state: int; + register_init : tok; (* initial contents of the single register for this TDFA *) + delta : int * char -> int * (tok -> tok) +} + +(* Description of a possible state that the TDFA could be in *) +type tdfa_state = { + state_id : int; (* current state *) + register : tok; (* contents of register *) + tokens : tok list; (* tokens emitted so far *) + to_parse : char list; (* characters left to parse *) +} -- cgit v1.2.3