yml2.py
changeset 28 e9a51b1d5587
parent 23 f2e8837da4e9
child 31 d3dddb80d1f5
equal deleted inserted replaced
27:0cdfe84ef643 28:e9a51b1d5587
     1 # YML 2.5.9 language definition
     1 # YML 2.5.10 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
    49 
    49 
    50 _xmlSymbol = u"(" + NameStartChar + u")(" + NameChar + u")*"
    50 _xmlSymbol = u"(" + NameStartChar + u")(" + NameChar + u")*"
    51 xmlSymbol = r(_xmlSymbol)
    51 xmlSymbol = r(_xmlSymbol)
    52 aliasSymbol = r(ur"-|(" + _xmlSymbol + ur")")
    52 aliasSymbol = r(ur"-|(" + _xmlSymbol + ur")")
    53 
    53 
    54 literal = [r(r'""".*?"""', re.S), r(r"'''.*?'''", re.S), r(r"""-?\d+\.\d*|-?\.\d+|-?\d+|".*?"|'.*?'""")]
    54 literal = [r(r'""".*?"""', re.S), r(r"'''.*?'''", re.S), r(r"""0x[a-f0-9]+|-?\d+\.\d*|-?\.\d+|-?\d+|".*?"|'.*?'""")]
    55 filename = [("'", r(r"[^']*"), "'"), ('"', r(r'[^"]*'), '"'), r(r"[^\s;]+")]
    55 filename = [("'", r(r"[^']*"), "'"), ('"', r(r'[^"]*'), '"'), r(r"[^\s;]+")]
    56 ws = r(r"\s+", re.U)
    56 ws = r(r"\s+", re.U)
    57 
    57 
    58 def pyExp():        return "!", r(r"(!=|\\!|[^!])+"), "!"
    58 def pyExp():        return "!", r(r"(!=|\\!|[^!])+"), "!"
    59 value = [literal, pyExp]
    59 value = [literal, pyExp]