1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
2011-07-27 07:17:02 -07:00
|
|
|
(* OCaml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
2002-10-28 08:46:50 -08:00
|
|
|
(* raised when there are too many bindings (>= 254 memory cells) *)
|
2010-01-22 04:48:24 -08:00
|
|
|
exception Memory_overflow
|
2002-10-28 08:46:50 -08:00
|
|
|
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Representation of automata *)
|
|
|
|
|
2002-10-28 08:46:50 -08:00
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
type automata =
|
2002-10-28 08:46:50 -08:00
|
|
|
Perform of int * tag_action list
|
|
|
|
| Shift of automata_trans * (automata_move * memory_action list) array
|
1995-05-04 03:15:53 -07:00
|
|
|
and automata_trans =
|
|
|
|
No_remember
|
2002-10-28 08:46:50 -08:00
|
|
|
| Remember of int * tag_action list
|
1995-05-04 03:15:53 -07:00
|
|
|
and automata_move =
|
|
|
|
Backtrack
|
|
|
|
| Goto of int
|
2002-10-28 08:46:50 -08:00
|
|
|
and memory_action =
|
|
|
|
| Copy of int * int
|
|
|
|
| Set of int
|
|
|
|
|
|
|
|
and tag_action = SetTag of int * int | EraseTag of int
|
|
|
|
|
2007-01-29 08:44:16 -08:00
|
|
|
type ident = string * Syntax.location
|
1996-02-25 06:45:47 -08:00
|
|
|
|
|
|
|
(* Representation of entry points *)
|
2002-10-28 08:46:50 -08:00
|
|
|
type tag_base = Start | End | Mem of int
|
2010-01-22 04:48:24 -08:00
|
|
|
type tag_addr = Sum of (tag_base * int)
|
2002-10-28 08:46:50 -08:00
|
|
|
type ident_info =
|
|
|
|
| Ident_string of bool * tag_addr * tag_addr
|
|
|
|
| Ident_char of bool * tag_addr
|
2007-01-29 08:44:16 -08:00
|
|
|
|
|
|
|
type t_env = (ident * ident_info) list
|
1996-02-25 06:45:47 -08:00
|
|
|
|
2002-01-04 02:01:50 -08:00
|
|
|
type ('args,'action) automata_entry =
|
1996-02-25 06:45:47 -08:00
|
|
|
{ auto_name: string;
|
2002-10-28 08:46:50 -08:00
|
|
|
auto_args: 'args ;
|
|
|
|
auto_mem_size : int ;
|
|
|
|
auto_initial_state: int * memory_action list ;
|
|
|
|
auto_actions: (int * t_env * 'action) list }
|
1996-02-25 06:45:47 -08:00
|
|
|
|
|
|
|
(* The entry point *)
|
|
|
|
|
2002-01-04 02:01:50 -08:00
|
|
|
val make_dfa :
|
2002-10-28 08:46:50 -08:00
|
|
|
('args, 'action) Syntax.entry list ->
|
|
|
|
('args, 'action) automata_entry list * automata array
|