linkchecker/GML/grammarspec.txt
2000-02-28 13:44:24 +00:00

49 lines
1.4 KiB
Text

# a GML parser
# Here is the GML grammar
# corrected from me because the original at
# http://www.uni-passau.de/Graphlet/GML had some errors
#
# corrections are
# (1) use instring* in string
# (2) add character,lowercase,uppercase definitions
# (3) skip whitespace definition, this is obvious
# (4) use digit+ in mantissa
#
# additions are
# (1) no empty list is allowed
# (2) either intpart or fraction of a real must contain a number
# (3) comments can be on a separate or at the end of the line
#
#
# gml: list
# list: (whitespace* key whitespace+ value)+
# value: integer | real | string | "[" list "]"
# key: character (character | digit)*
# integer: sign digit+
# real: sign (digit+ "." digit* | digit* "." digit+) mantissa
# string: """ instring* """
# sign: "+" | "-" |
# digit: "0"..."9"
# character: lowercase | uppercase
# lowercase: "a"..."z"
# uppercase: "A"..."Z"
# mantissa: ("E"|"e") sign digit+ |
# instring: <ASCII except "&" and """> | "&" character+ ";"
#
# Note that integers and reals can have prefixed zeros, e.g. 001 is 1
_class GMLBaseParser
_code import GML
_lex GML.GMLLexer()
# the grammar
"""
gml: list (feddich);
list: list keyvalue (gml_key_value)| keyvalue;
keyvalue: KEY value (key_value);
value: INTEGER |
REAL |
STRING |
LSQB list RSQB (gmllist);
"""