module Kwparse:sig
..end
This parser uses a two-stack shift-reduce machine.
See the Tutorial below.
Author(s): Keith Waclena
exception Syntax of string
val syntax : string -> 'a
Syntax
type
srae =
| |
Shift |
| |
Reduce |
| |
Accept |
| |
Err of |
LEX.table
module type LEX =sig
..end
module type TRACE =sig
..end
module Make:
Lex
and a tracer T
and returning a parser implementation.
TRACE
.
Pass it your LEX
implementation.
module NoTrace:
LEX.table
.
This is optional; you can implement your LEX.table
however you
like: pattern matching, actual 2-dimensional array, etc. However,
for more than 3-5 opertors, enumerations are excessively large;
opdefs
is much more convenient.
type
associativity =
| |
Nonassoc |
| |
Leftassoc |
| |
Rightassoc |
opdef
(currently ignored)type 'a
opdef = {
|
lexeme : |
(* |
An operator lexeme
| *) |
|
prec : |
(* |
The operator's precedence: lower precedences bind more tightly (sorry, but I think that's most useful)
| *) |
|
arity : |
(* |
The operator's arity, i.e. how many arguments does it take (currently ignored)
| *) |
|
assoc : |
(* |
The operator's associativity (currently ignored)
| *) |
opdef
val opdef : 'a -> pre:int -> ari:int -> associativity -> 'a opdef
val opdefs : 'a -> 'a opdef list -> 'a -> 'a -> srae
LEX.table
.LEX.table
implementationeof
: the EOF lexemespec
: a list of opdef records including all Operator lexemes
Coming soon!