/usr/lib/mlton/sml/mllpt-lib/ebnf.sml is in mlton-basis 20130715-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | (* ebnf.sml
*
* COPYRIGHT (c) 2006
* John Reppy (http://www.cs.uchicago.edu/~jhr)
* Aaron Turon (http://www.cs.uchicago.edu/~adrassi)
* All rights reserved.
*
* EBNF combinators used for ml-antlr.
*)
functor AntlrEBNF (S : sig
type strm
val getSpan : strm -> AntlrStreamPos.span
end) =
struct
fun optional (pred, parse, strm) =
if pred strm
then let
val (y, span, strm') = parse strm
in
(SOME y, span, strm')
end
else (NONE, S.getSpan strm, strm)
fun closure (pred, parse, strm) = let
fun iter (strm, (left, right), ys) =
if pred strm
then let
val (y, (_, right'), strm') = parse strm
in iter (strm', (left, right'), y::ys)
end
else (List.rev ys, (left, right), strm)
in
iter (strm, S.getSpan strm, [])
end
fun posclos (pred, parse, strm) = let
val (y, (left, _), strm') = parse strm
val (ys, (_, right), strm'') = closure (pred, parse, strm')
in
(y::ys, (left, right), strm'')
end
end
|