Commits

Sébastien Ferré committed 4fdd04a

Add of the 'match' construct.

  • Participants
  • Parent commits 45e2163

Comments (0)

Files changed (1)

File dcg/pa_dcg.ml

       | "!"; e = expr LEVEL "top" ->
 	  <:patt< _ >>, <:expr< Dcg.set_context $e$ >>
       | s = str ->
-        <:patt< _ >>, <:expr< Matcher.look $s$ >>
+          <:patt< _ >>, <:expr< Matcher.look $s$ >>
       | x = ipatt; ff = binding ->
         x, ff x
       ] ];
 
   par:
     [ [ p = rule -> p
+      | "match"; regexp = expr LEVEL "top"; name_opt = OPT [ "as"; n = str -> n ] ->
+	  let name = match name_opt with Some n -> n | None -> regexp in
+	  <:expr< Matcher.get $name$ (Str.regexp $regexp$) Matcher.Token.repr >>
       | p = expr LEVEL "top" -> p
       ] ];