Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v1311
Fetching contributors…

Cannot retrieve contributors at this time

43 lines (35 sloc) 1.507 kb
(*
Copyright © 2011 MLstate
This file is part of OPA.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
(* A simple GML (Graph Modelling Language) parser
syntax from http://www.infosun.fim.uni-passau.de/Graphlet/GML/gml-tr.html
*)
types:{{
type gml = Int of int | Float of float | String of string | List of (string * gml) list
}}
+gml : {gml} <- list {{ List __1 }}
list <- (whitespace* key whitespace+ value whitespace* {{ __2, __4 }})*
value <- Integer {{ Int __1 }}
/ Real {{ Float __1 }}
/ String {{ String __1 }}
/ '[' list ']' {{ List __2 }}
key <- [a-zA-Z][a-zA-Z0-9]* $_
Integer <- (sign [0-9]+ $_) {{ int_of_string __1 }}
Real <- (sign [0-9]* '.' [0-9]* ( 'E' sign [0-9] ) $_) {{ float_of_string __1 }}
String <- '"' (instring* $_) '"' {{ __2 }}
sign <- ('+' / '-')? $_
instring <- ![&\"] . $_ / '&' [a-zA-Z]+ ';' $_ # html escapes (&nbsp;)
whitespace <- [ \t\n] $ / comment $
comment <- '#' (!EOL .)* (EOL / EOF) $
EOL <- [\n\r] $ / '\r\n' $
EOF <- !.
Jump to Line
Something went wrong with that request. Please try again.