Removed some debugging prints.
[virt-top.git] / virt-df / virt_df_lvm2_parser.mly
1 /* 'df' command for virtual domains.  -*- text -*-
2    (C) Copyright 2007-2008 Richard W.M. Jones, Red Hat Inc.
3    http://libvirt.org/
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 /* Parser for LVM2 metadata.
21    ocamlyacc tutorial:
22    http://plus.kaist.ac.kr/~shoh/ocaml/ocamllex-ocamlyacc/ocamlyacc-tutorial/
23  */
24
25 %{
26   open Virt_df_lvm2_metadata
27 %}
28
29 %token LBRACE RBRACE                    /* { } */
30 %token LSQUARE RSQUARE                  /* [ ] */
31 %token EQ                               /* = */
32 %token COMMA                            /* , */
33 %token <string> STRING                  /* "string" */
34 %token <int64> INT                      /* an integer */
35 %token <float> FLOAT                    /* a float */
36 %token <string> IDENT                   /* a naked keyword/identifier */
37 %token EOF                              /* end of file */
38
39 %start input
40 %type <Virt_df_lvm2_metadata.metadata> input
41
42 %%
43
44 input   : lines EOF     { List.rev $1 }
45         ;
46
47 lines   : /* empty */   { [] }
48         | lines line    { $2 :: $1 }
49         ;
50
51 line    : /* empty */   /* These dummy entries get removed after parsing. */
52                         { ("", String "") }
53         | IDENT EQ value
54                         { ($1, $3) }
55         | IDENT LBRACE lines RBRACE
56                         { ($1, Metadata (List.rev $3)) }
57         ;
58
59 value   : STRING        { String $1 }
60         | INT           { Int $1 }
61         | FLOAT         { Float $1 }
62         | LSQUARE list RSQUARE
63                         { List (List.rev $2) }
64         ;
65
66 list    : /* empty */   { [] }
67         | value         { [$1] }
68         | list COMMA value
69                         { $3 :: $1 }
70         ;