yml2.py
changeset 14 d937e9d7c4fe
parent 0 76005e62091d
child 20 c936066cff62
equal deleted inserted replaced
13:57c1866bd87b 14:d937e9d7c4fe
     1 # YML 2.5.3 language definition
     1 # YML 2.5.6 language definition
     2 
     2 
     3 # written by VB.
     3 # written by VB.
     4 
     4 
     5 import re
     5 import re
     6 from pyPEG import keyword, _and, _not
     6 from pyPEG import keyword, _and, _not
    75 def python():       return [r(r"!!.*?!!", re.S), r(r"!.*")]
    75 def python():       return [r(r"!!.*?!!", re.S), r(r"!.*")]
    76 def operator():     return 0, keyword("define"), keyword("operator"), literal, keyword("as"), r(r".*")
    76 def operator():     return 0, keyword("define"), keyword("operator"), literal, keyword("as"), r(r".*")
    77 def constant():     return 0, keyword("define"), [pointer, symbol], "=", literal, 0, [";", "."]
    77 def constant():     return 0, keyword("define"), [pointer, symbol], "=", literal, 0, [";", "."]
    78 def in_ns():        return keyword("in"), xmlSymbol, [_decl, ("{", -2, _decl, "}")]
    78 def in_ns():        return keyword("in"), xmlSymbol, [_decl, ("{", -2, _decl, "}")]
    79 _decl = keyword("decl"), listing(decl), [";", "."]
    79 _decl = keyword("decl"), listing(decl), [";", "."]
    80 def textsection():  return r(r'(\|\|(\>*).*?\|\|(\>*))|(\>\>.*?\>\>)', re.S)
    80 def textsection():  return r(r'(\|\|(\>*).*?\|\|(\>*))', re.S)
       
    81 def textsectionu(): return r(r'(\>\>.*?\>\>)', re.S)
    81 def include():      return keyword("include"), 0, reverse, 0, [ktext, kxml], filename, 0, [";", "."]
    82 def include():      return keyword("include"), 0, reverse, 0, [ktext, kxml], filename, 0, [";", "."]
    82 def func():         return _func, 0, content
    83 def func():         return _func, 0, content
    83 def funclist():     return listing(func)
    84 def funclist():     return listing(func)
    84 _cmd = funclist, 0, [";", "."]
    85 _cmd = funclist, 0, [";", "."]
    85 _inner = [include, textsection, pythonCall, _cmd, quote, lineQuote, tagQuote, pyExp]
    86 _inner = [include, textsection, textsectionu, pythonCall, _cmd, quote, lineQuote, tagQuote, pyExp]
    86 _cc = "{", -1, _inner, "}"
    87 _cc = "{", -1, _inner, "}"
    87 def content_plain(): return [ (_l, 0, _p, 0, _b, 0, _cc), (_p, 0, _b, 0, _cc), (_b, 0, _cc), _cc ]
    88 def content_plain(): return [ (_l, 0, _p, 0, _b, 0, _cc), (_p, 0, _b, 0, _cc), (_b, 0, _cc), _cc ]
    88 content_plain.__name__ = "content"
    89 content_plain.__name__ = "content"
    89 def func_plain():   return _func, 0, content_plain
    90 def func_plain():   return _func, 0, content_plain
    90 func_plain.__name__ = "func"
    91 func_plain.__name__ = "func"