File: xml_parser.mly

package info (click to toggle)
xml-light 2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 212 kB
  • ctags: 352
  • sloc: ml: 1,691; makefile: 171
file content (96 lines) | stat: -rw-r--r-- 2,049 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
%{(*
 * Xml Light, an small Xml parser/printer with DTD support.
 * Copyright (C) 2003 Nicolas Cannasse (ncannasse@motion-twin.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library has the special exception on linking described in file
 * README.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301 USA
 *)	
%}
%token NEXT OR
%token <string>IDENT
%token PCDATA
%token STAR QUESTION PLUS
%token OPEN CLOSE
%token END

%right STAR QUESTION PLUS

%start dtd_element
%type <Dtd.dtd_child> dtd_element
%%

dtd_element:
	| dtd_full_seq END
		{ $1 }
;
dtd_full_seq:
	| dtd_seq CLOSE dtd_op
		{ $3 $1 }
	| dtd_seq CLOSE
		{ $1 }
;
dtd_seq:
	| dtd_item NEXT dtd_children
		{ Dtd.DTDChildren ($1 :: $3) }
	| dtd_item OR dtd_choice
		{ Dtd.DTDChoice ($1 :: $3) }
	| dtd_item
		{ $1 }
;
dtd_children:
	| dtd_item NEXT dtd_children
		{ $1 :: $3 }
	| dtd_item
		{ [$1] }
;
dtd_choice:
	| dtd_item OR dtd_choice
		{ $1 :: $3 }
	| dtd_item
		{ [$1] }
;
dtd_item:
	| OPEN dtd_full_seq
		{ $2 }
	| dtd_member
		{ $1 }
;
dtd_member:
	| IDENT dtd_op
		{ $2 (Dtd.DTDTag $1) }
	| PCDATA dtd_op
		{ $2 Dtd.DTDPCData }
	| IDENT
		{ Dtd.DTDTag $1 }
	| PCDATA
		{ Dtd.DTDPCData }
;
dtd_op:
	| dtd_op_item dtd_op
		{ (fun x -> $2 ($1 x)) }
	| dtd_op_item 
		{ $1 }
;
dtd_op_item:
	| STAR
		{ (fun x -> Dtd.DTDZeroOrMore x) }
	| QUESTION
		{ (fun x -> Dtd.DTDOptional x) }
	| PLUS
		{ (fun x -> Dtd.DTDOneOrMore x) }
;