Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 43 lines (35 sloc) 1.536 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
6fac5ce @Aqua-Ye [cleanup] ocamllib: typo on Opa
Aqua-Ye authored
4 This file is part of Opa.
fccc685 Initial open-source release
MLstate authored
5
6fac5ce @Aqua-Ye [cleanup] ocamllib: typo on Opa
Aqua-Ye authored
6 Opa is free software: you can redistribute it and/or modify it under the
fccc685 Initial open-source release
MLstate authored
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
6fac5ce @Aqua-Ye [cleanup] ocamllib: typo on Opa
Aqua-Ye authored
10 Opa is distributed in the hope that it will be useful, but WITHOUT ANY
fccc685 Initial open-source release
MLstate authored
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
6fac5ce @Aqua-Ye [cleanup] ocamllib: typo on Opa
Aqua-Ye authored
16 along with Opa. If not, see <http://www.gnu.org/licenses/>.
fccc685 Initial open-source release
MLstate authored
17 *)
18 (* A simple GML (Graph Modelling Language) parser
19 syntax from http://www.infosun.fim.uni-passau.de/Graphlet/GML/gml-tr.html
20 *)
21
22 types:{{
23 type gml = Int of int | Float of float | String of string | List of (string * gml) list
24 }}
25
26 +gml : {gml} <- list {{ List __1 }}
27 list <- (whitespace* key whitespace+ value whitespace* {{ __2, __4 }})*
28 value <- Integer {{ Int __1 }}
29 / Real {{ Float __1 }}
30 / String {{ String __1 }}
31 / '[' list ']' {{ List __2 }}
32
33 key <- [a-zA-Z][a-zA-Z0-9]* $_
34 Integer <- (sign [0-9]+ $_) {{ int_of_string __1 }}
35 Real <- (sign [0-9]* '.' [0-9]* ( 'E' sign [0-9] ) $_) {{ float_of_string __1 }}
36 String <- '"' (instring* $_) '"' {{ __2 }}
37 sign <- ('+' / '-')? $_
38 instring <- ![&\"] . $_ / '&' [a-zA-Z]+ ';' $_ # html escapes (&nbsp;)
39 whitespace <- [ \t\n] $ / comment $
40 comment <- '#' (!EOL .)* (EOL / EOF) $
41 EOL <- [\n\r] $ / '\r\n' $
42 EOF <- !.
Something went wrong with that request. Please try again.