Version française
Home     About     Download     Resources     Contact us    
Browse thread
sequence parser, revised syntax
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: dsb@p...
Subject: sequence parser, revised syntax
I have a noobie question about parsers.

The output of
  Grammar.Entry.print Pcaml.expr;;

contains several things that appear to be parsers
(this example in the revised syntax):

  | "let"; "module"; UIDENT; module_binding; "in"; SELF
  | "let"; OPT "rec"; LIST1 let_binding SEP "and"; "in"; SELF
  | "fun"; "["; LIST0 match_case SEP "|"; "]"
  | "fun"; ipatt; fun_def
  | "while"; SELF; "do"; "{"; sequence; "}"
  | "while"; SELF; "do"; LIST0 [ expr; ";" ]; warning_sequence; "done"
  | "object"; OPT class_self_patt; class_structure; "end" ]

but don't seem to be documented.  My current interest happens to be
sequence:

  open Pcaml;
  EXTEND
    expr: LEVEL "top" [
  [ "when"; test = expr; "do"; "{"; seq = sequence; "}"
    ->
      <:expr< if $test$ then ($list:seq$) else () >>
  ]];
  END;

but it doesn't seem to work:

  $ make stdlibr.cmo
  ocamlc -pp "camlp4r pa_extend.cmo q_MLast.cmo" \
          -I +camlp4 -c stdlibr.ml
  File "stdlibr.ml", line 20, characters 40-48:
  Unbound value Pcaml.sequence
  make: *** [stdlibr.cmo] Error 2

How are these parsers supposed to be used?

Thanks.
--Dan Bensen
www.prairienet.org/~dsb/