Stream Parser

From Gallium

Jump to: navigation, search

OCaml features a module implementing lazy destructive streams.

Then Stream Parsers provide a syntax to construct, and de-construct them.

Original syntax, for Stream Parsers

 caml-expression, e ::=
   | ...
   | [< <stream-item> ; ... ; <stream-item> >]
   | match <caml-expression> with parser |? <parser-case> | ... | <parser-case>
   | parser |? <parser-case> | ... | <parser-case>
 
 stream-item ::=
   | ' <caml-expression>  (* An atomic element of the stream *)
   | <caml-expression>    (* A flattened stream *)
 
 parser-case ::=
   | [< <stream-item-pattern> <stream-err>? ; ... ; <stream-item-pattern> <stream-err>? >]
 
 stream-item-pattern ::=
   | ' <caml-pattern> (when <caml-expression>)? (* A pattern to match an atomic element of the stream *)
   | <caml-pattern> = <caml-expression>         (* Invoke the parser and filter its result *)
   | <caml-pattern>                             (* Match the current stream *)
 
 stream-err ::=
   | ?? <caml-expression>   (* Error handling *)

Revised syntax, for Stream Parsers

Almost the same expect that it's backquote (`) instead of a quote ('), and [: ... :] instead of [< ... >].

Personal tools
Espace privé