sentenceParserAux.ml 1.44 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
(******************************************************************************)
(*                                                                            *)
(*                                   Menhir                                   *)
(*                                                                            *)
(*                       François Pottier, Inria Paris                        *)
(*              Yann Régis-Gianas, PPS, Université Paris Diderot              *)
(*                                                                            *)
(*  Copyright Inria. All rights reserved. This file is distributed under the  *)
(*  terms of the GNU General Public License version 2, as described in the    *)
(*  file LICENSE.                                                             *)
(*                                                                            *)
(******************************************************************************)

14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
open Grammar

type terminals =
  Terminal.t list

type sentence =
  Nonterminal.t option * terminals

type located_sentence =
  Positions.positions * sentence

type comment =
  string

type 'a or_comment =
29
| Thing of 'a
30 31
| Comment of comment

POTTIER Francois's avatar
POTTIER Francois committed
32 33 34 35 36 37
let or_comment_iter f = function
  | Thing s ->
      f s
  | Comment _ ->
      ()

38
let or_comment_map f = function
39 40
  | Thing s ->
      Thing (f s)
41 42 43
  | Comment c ->
      Comment c

44 45
let unThing = function
  | Thing x ->
46 47 48
      [ x ]
  | Comment _ ->
      []