当前位置: 首页>>代码示例>>Python>>正文


Python ParserElement.setDefaultWhitespaceChars方法代码示例

本文整理汇总了Python中pyparsing.ParserElement.setDefaultWhitespaceChars方法的典型用法代码示例。如果您正苦于以下问题:Python ParserElement.setDefaultWhitespaceChars方法的具体用法?Python ParserElement.setDefaultWhitespaceChars怎么用?Python ParserElement.setDefaultWhitespaceChars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyparsing.ParserElement的用法示例。


在下文中一共展示了ParserElement.setDefaultWhitespaceChars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: defineParsers

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
def defineParsers():
    #Enable a fast parsing mode with caching.
    ParserElement.enablePackrat()
    #end of line terminates statements, so it is not regular whitespace
    ParserElement.setDefaultWhitespaceChars('\t ')

    func_call = Forward() #forward declaration because this is a recursive rule   

    #The "terminal" rules
    symbol = Word(alphas+'_-', alphanums+'_-') .setParseAction(action_symbol)
    q_symbol = quotedString                    .setParseAction(action_q_symbol)
    bracket_term = Literal("(").suppress() - func_call \
                   + Literal(")").suppress()
    word = symbol | q_symbol | bracket_term
    
    #The function call
    #Parse: "foo | bar | baz" or "foo"
    pipeline = (word + ZeroOrMore("|" - word)) .setParseAction(action_pipeline) 
    #Parse "foo|bar op1 op2 op3"
    func_call << (pipeline - ZeroOrMore(word)) .setParseAction(action_func_call)
    
    #High level structure of program
    line = LineEnd() | func_call - LineEnd() #empty line or function call
    program = ZeroOrMore(line) + StringEnd() #multiple lines are a program
    
    #define the comments
    program.ignore('%' + restOfLine)
    #no tab expansion
    program.parseWithTabs()   
    #return additional func_call parser to make testing more easy
    return program, func_call
开发者ID:eike-welk,项目名称:freeode,代码行数:33,代码来源:simple_config_lang.py

示例2: hwdb_grammar

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
def hwdb_grammar():
    ParserElement.setDefaultWhitespaceChars('')

    prefix = Or(category + ':' + Or(conn) + ':'
                for category, conn in TYPES.items())
    matchline = Combine(prefix + Word(printables + ' ' + '®')) + EOL
    propertyline = (
        White(' ', exact=1).suppress()
        + Combine(UDEV_TAG
                  - '='
                  - Word(alphanums + '_=:@*.! ')
                  - Optional(pythonStyleComment))
        + EOL
    )
    propertycomment = White(' ', exact=1) + pythonStyleComment + EOL

    group = (
        OneOrMore(matchline('MATCHES*') ^ COMMENTLINE.suppress())
        - OneOrMore(propertyline('PROPERTIES*') ^ propertycomment.suppress())
        - (EMPTYLINE ^ stringEnd()).suppress()
    )
    commentgroup = OneOrMore(COMMENTLINE).suppress() - EMPTYLINE.suppress()

    grammar = OneOrMore(group('GROUPS*') ^ commentgroup) + stringEnd()

    return grammar
开发者ID:ybakos,项目名称:libinput,代码行数:28,代码来源:parse_hwdb.py

示例3: read_sets_java

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
def read_sets_java(string):
    from pyparsing import nestedExpr, alphas, Word, nums, ParserElement, delimitedList
    ParserElement.setDefaultWhitespaceChars(" ,")
    element = Word(alphas + nums).setParseAction(parse_elem_java) 
    elements = delimitedList(element)
    setofsets = nestedExpr("[", "]", content=elements).setParseAction(lambda x: frozenset(x[0]))
    return setofsets.parseString(string).asList()[0]
开发者ID:VeraLiconaResearchGroup,项目名称:MHSGenerationAlgorithms,代码行数:9,代码来源:sethelper.py

示例4: parser

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
def parser():
    global _parser
    if _parser is None:
        ParserElement.setDefaultWhitespaceChars("")
        lbrack, rbrack, lbrace, rbrace, lparen, rparen = map(Literal, "[]{}()")

        reMacro = Combine("\\" + oneOf(list("dws")))
        escapedChar = ~ reMacro + Combine("\\" + oneOf(list(printables)))
        reLiteralChar = "".join(c for c in printables if c not in r"\[]{}().*?+|") + " \t"

        reRange = Combine(lbrack + SkipTo(rbrack, ignore=escapedChar) + rbrack)
        reLiteral = (escapedChar | oneOf(list(reLiteralChar)))
        reDot = Literal(".")
        repetition = (
                      (lbrace + Word(nums).setResultsName("count") + rbrace) |
                      (lbrace + Word(nums).setResultsName("minCount") + "," + Word(nums).setResultsName("maxCount") + rbrace) |
                      oneOf(list("*+?"))
                      )

        reRange.setParseAction(handle_range)
        reLiteral.setParseAction(handle_literal)
        reMacro.setParseAction(handle_macro)
        reDot.setParseAction(handle_dot)

        reTerm = (reLiteral | reRange | reMacro | reDot)
        reExpr = operatorPrecedence(reTerm, [
                (repetition, 1, opAssoc.LEFT, handle_repetition),
                (None, 2, opAssoc.LEFT, handle_sequence),
                (Suppress('|'), 2, opAssoc.LEFT, handle_alternative),
            ])

        _parser = reExpr

    return _parser
开发者ID:Bernie,项目名称:spyne,代码行数:36,代码来源:invregexp.py

示例5: property_grammar

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
def property_grammar():
    ParserElement.setDefaultWhitespaceChars(' ')

    dpi_setting = (Optional('*')('DEFAULT') + INTEGER('DPI') + Suppress('@') + INTEGER('HZ'))('SETTINGS*')
    mount_matrix_row = SIGNED_REAL + ',' + SIGNED_REAL + ',' + SIGNED_REAL
    mount_matrix = (mount_matrix_row + ';' + mount_matrix_row + ';' + mount_matrix_row)('MOUNT_MATRIX')

    props = (('MOUSE_DPI', Group(OneOrMore(dpi_setting))),
             ('MOUSE_WHEEL_CLICK_ANGLE', INTEGER),
             ('MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL', INTEGER),
             ('MOUSE_WHEEL_CLICK_COUNT', INTEGER),
             ('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', INTEGER),
             ('ID_INPUT_TRACKBALL', Literal('1')),
             ('POINTINGSTICK_SENSITIVITY', INTEGER),
             ('POINTINGSTICK_CONST_ACCEL', REAL),
             ('ID_INPUT_TOUCHPAD_INTEGRATION', Or(('internal', 'external'))),
             ('XKB_FIXED_LAYOUT', STRING),
             ('XKB_FIXED_VARIANT', STRING),
             ('ACCEL_MOUNT_MATRIX', mount_matrix),
            )
    fixed_props = [Literal(name)('NAME') - Suppress('=') - val('VALUE')
                   for name, val in props]
    kbd_props = [Regex(r'KEYBOARD_KEY_[0-9a-f]+')('NAME')
                 - Suppress('=') -
                 ('!' ^ (Optional('!') - Word(alphanums + '_')))('VALUE')
                ]
    abs_props = [Regex(r'EVDEV_ABS_[0-9a-f]{2}')('NAME')
                 - Suppress('=') -
                 Word(nums + ':')('VALUE')
                ]

    grammar = Or(fixed_props + kbd_props + abs_props) + EOL

    return grammar
开发者ID:tsmock,项目名称:systemd,代码行数:36,代码来源:parse_hwdb.py

示例6: property_grammar

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
def property_grammar():
    ParserElement.setDefaultWhitespaceChars(' ')

    model_props = [
        Regex(r'LIBINPUT_MODEL_[_0-9A-Z]+')('NAME') -
        Suppress('=') - (Literal('1'))('VALUE')
    ]

    dimension = INTEGER('X') + Suppress('x') + INTEGER('Y')

    crange = INTEGER('X') + Suppress(':') + INTEGER('Y')
    vprops = (
        ('LIBINPUT_ATTR_SIZE_HINT', Group(dimension('SETTINGS*'))),
        ('LIBINPUT_ATTR_RESOLUTION_HINT', Group(dimension('SETTINGS*'))),
        ('LIBINPUT_ATTR_PRESSURE_RANGE', Group(crange('SETTINGS*'))),
        ('LIBINPUT_ATTR_TOUCH_SIZE_RANGE', Group(crange('SETTINGS*'))),
        ('LIBINPUT_ATTR_TPKBCOMBO_LAYOUT', Or(('below'))),
        ('LIBINPUT_ATTR_LID_SWITCH_RELIABILITY',
         Or(('reliable', 'write_open'))),
        ('LIBINPUT_ATTR_KEYBOARD_INTEGRATION', Or(('internal', 'external'))),
    )
    value_props = [Literal(name)('NAME') - Suppress('=') - val('VALUE') for
                   name, val in vprops]

    tprops = (
        ('LIBINPUT_ATTR_PALM_PRESSURE_THRESHOLD', INTEGER('X')),
        ('LIBINPUT_ATTR_PALM_SIZE_THRESHOLD', INTEGER('X')),
    )
    typed_props = [Literal(name)('NAME') - Suppress('=') - val
                   for name, val in tprops]

    grammar = Or(model_props + value_props + typed_props)

    return grammar
开发者ID:ybakos,项目名称:libinput,代码行数:36,代码来源:parse_hwdb.py

示例7: property_grammar

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
def property_grammar():
    ParserElement.setDefaultWhitespaceChars(' ')

    setting = Optional('*')('DEFAULT') + INTEGER('DPI') + Suppress('@') + INTEGER('HZ')
    props = (('MOUSE_DPI', Group(OneOrMore(setting('SETTINGS*')))),
             ('MOUSE_WHEEL_CLICK_ANGLE', INTEGER),
             ('MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL', INTEGER),
             ('ID_INPUT_TRACKBALL', Literal('1')),
             ('POINTINGSTICK_SENSITIVITY', INTEGER),
             ('POINTINGSTICK_CONST_ACCEL', REAL),
             ('ID_INPUT_TOUCHPAD_INTEGRATION', Or(('internal', 'external'))),
    )
    fixed_props = [Literal(name)('NAME') - Suppress('=') - val('VALUE')
                   for name, val in props]
    kbd_props = [Regex(r'KEYBOARD_KEY_[0-9a-f]+')('NAME')
                 - Suppress('=') -
                 ('!' ^ (Optional('!') - Word(alphanums + '_')))('VALUE')
                 ]
    abs_props = [Regex(r'EVDEV_ABS_[0-9a-f]{2}')('NAME')
                 - Suppress('=') -
                 Word(nums + ':')('VALUE')
                 ]

    grammar = Or(fixed_props + kbd_props + abs_props)

    return grammar
开发者ID:bkylerussell,项目名称:systemd,代码行数:28,代码来源:parse_hwdb.py

示例8: __init__

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
    def __init__(self):
        from pyparsing import (ParserElement, StringEnd, LineEnd, Literal,
                               pythonStyleComment, ZeroOrMore, Suppress,
                               Optional, Combine, OneOrMore, Regex, oneOf,
                               QuotedString, Group, ParseException)

        ParserElement.setDefaultWhitespaceChars("\t ")

        EOF = StringEnd()
        EOL = ~EOF + LineEnd() # EOL must not match on EOF

        escape = Literal("\\")
        comment = pythonStyleComment
        junk = ZeroOrMore(comment | EOL).suppress()

        ## word (i.e: single argument string)
        word = Suppress(escape + EOL + Optional(comment)) \
        | Combine(OneOrMore( escape.suppress() + Regex(".") |
                             QuotedString("'", escChar='\\', multiline=True) |
                             QuotedString('"', escChar='\\', multiline=True) |
                             Regex("[^ \t\r\n\f\v\\\\$&<>();\|\'\"`]+") |
                             Suppress(escape + EOL) ))

        ## redirector (aka bash file redirectors, such as "2>&1" sequences)
        fd_src = Regex("[0-2]").setParseAction(lambda t: int(t[0]))
        fd_dst = Suppress("&") + fd_src
        # "[n]<word" || "[n]<&word" || "[n]<&digit-"
        fd_redir = (Optional(fd_src, 0) + Literal("<")
                    |Optional(fd_src, 1) + Literal(">"))\
                   +(word | (fd_dst + Optional("-")))
        # "&>word" || ">&word"
        full_redir = (oneOf("&> >&") + word)\
                     .setParseAction(lambda t:("&" ,">", t[-1]))
        # "<<<word" || "<<[-]word"
        here_doc = Regex("<<(<|-?)") + word
        # "[n]>>word"
        add_to_file = Optional(fd_src | Literal("&"), 1) + \
                      Literal(">>") + word
        # "[n]<>word"
        fd_bind = Optional(fd_src, 0) + Literal("<>") + word

        redirector = (fd_redir | full_redir | here_doc
                      | add_to_file | fd_bind)\
                     .setParseAction(lambda token: tuple(token))

        ## single command (args/redir list)
        command = Group(OneOrMore(redirector | word))

        ## logical operators (section splits)
        semicolon = Suppress(";") + junk
        connector = (oneOf("&& || |") + junk) | semicolon

        ## pipeline, aka logical block of interconnected commands
        pipeline = junk + Group(command +
                                ZeroOrMore(connector + command) +
                                Optional(semicolon))

        # define object attributes
        self.LEXER = pipeline.ignore(comment) + EOF
        self.parseException = ParseException
开发者ID:0x0mar,项目名称:phpsploit,代码行数:62,代码来源:lexer.py

示例9: _parse_items

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
 def _parse_items(self, source):
     ParserElement.setDefaultWhitespaceChars(' \t\r')
     EOL = LineEnd().suppress()
     comment = Literal('#') + Optional( restOfLine ) + EOL
     string = CharsNotIn("\n")
     line = Group(
         Word(alphanums + '-')('key') + Literal(':').suppress() + Optional(Combine(string + ZeroOrMore(EOL + Literal(' ') + string)))("value") + EOL
     )
     group = ZeroOrMore(line)
     group.ignore(comment)
     return group.parseString(source, True)
开发者ID:centrumholdings,项目名称:citools,代码行数:13,代码来源:control.py

示例10: pythonVar

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
    def pythonVar(self):
        if not self._pythonVar:
            from pyparsing import (ParserElement, Word, alphas, alphanums,
                                   Literal, Suppress, FollowedBy)
            _ws = ' \t'
            ParserElement.setDefaultWhitespaceChars(_ws)
            ident = Word(alphas+"_", alphanums+"_")
            lparen = Literal("(")
            dot = Literal(".")
            dollar = Literal("$")

            self._pythonVar = Suppress(dollar) + ident + ~FollowedBy((dot+ident) | lparen)
            self._pythonVar.setParseAction(self.onPythonVar)
        return self._pythonVar
开发者ID:David-Bess,项目名称:medicare-demo,代码行数:16,代码来源:pysoc.py

示例11: set_delimiters

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
 def set_delimiters(self, delimiter):
     """Lets you change the delimiter that is used to identify field
     boundaries.
     
     delimiter: str
         A string containing characters to be used as delimiters. The
         default value is ' \t'. which means that spaces and tabs are not
         taken as data but instead mark the boundaries. Note that the
         parser is smart enough to recognize characters within quotes as
         non-delimiters."""
     
     self.delimiter = delimiter
     if delimiter != "columns":
         ParserElement.setDefaultWhitespaceChars(str(delimiter))
开发者ID:akhi28,项目名称:OpenMDAO-Framework,代码行数:16,代码来源:filewrap.py

示例12: parser

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
def parser():
    global _parser
    if _parser is None:
        ParserElement.setDefaultWhitespaceChars("")
        
        lbrack = Literal("[")
        rbrack = Literal("]")
        lbrace = Literal("{")
        rbrace = Literal("}")
        lparen = Literal("(")
        rparen = Literal(")")
        
        reMacro = Suppress("\\") + oneOf(list("dwsZ"))
        escapedChar = ~reMacro + Combine("\\" + oneOf(list(printables)))
        reLiteralChar = "".join(c for c in string.printable if c not in r"\[]{}().*?+|")

        reRange = Combine(lbrack.suppress() + SkipTo(rbrack,ignore=escapedChar) + rbrack.suppress())
        reLiteral = ( escapedChar | oneOf(list(reLiteralChar)) )
        reDot = Literal(".")
        repetition = (
            ( lbrace + Word(nums).setResultsName("count") + rbrace ) |
            ( lbrace + Word(nums).setResultsName("minCount")+","+ Word(nums).setResultsName("maxCount") + rbrace ) |
            oneOf(list("*+?"))
            )
        reExpr = Forward()
        reGroup = (lparen.suppress() +
                   Optional(Literal("?").suppress() + oneOf(list(":P"))).setResultsName("option") +
                   reExpr.setResultsName("expr") +
                   rparen.suppress())

        reTerm = ( reLiteral | reRange | reMacro | reDot | reGroup )
        reExpr << operatorPrecedence( reTerm,
            [
            (repetition, 1, opAssoc.LEFT, create(Repetition)),
            (None, 2, opAssoc.LEFT, create(Sequence)),
            (Suppress('|'), 2, opAssoc.LEFT, create(Alternation)),
            ]
            )

        reGroup.setParseAction(create(Group))
        reRange.setParseAction(create(Range))
        reLiteral.setParseAction(create(Character))
        reMacro.setParseAction(create(Macro))
        reDot.setParseAction(create(Dot))
        
        _parser = reExpr
        
    return _parser
开发者ID:GunioRobot,项目名称:pycucumber,代码行数:50,代码来源:regex_parser.py

示例13: pn_from_sis

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
def pn_from_sis(filename):
    """Loads a PN in SIS format."""
    # definition of PN grammar
    ParserElement.setDefaultWhitespaceChars(" \t")
    id = Word(alphanums+"_\"':-")
    #place = Literal("p") + Word(nums)
    number = Word(nums).setParseAction(lambda tokens: int(tokens[0]))
    newlines = Suppress(OneOrMore(LineEnd()))
    modelName = ".model" + id("modelName") + newlines
    signalNames = ZeroOrMore( Suppress(oneOf(".inputs .outputs .dummy")) + OneOrMore( id ) + newlines)("signals")
    arc = id + ZeroOrMore(Group(id + Optional(Suppress("(")+number+Suppress(")"), default=1))) + newlines
    graph = Literal(".graph") + Suppress(OneOrMore(LineEnd())) + OneOrMore(Group(arc))("arcs")
    capacity_list = ZeroOrMore(Group(id+Suppress("=")+number))
    capacity = ".capacity" + capacity_list("capacities") + newlines
    marking_list = ZeroOrMore(Group(id+Optional(Suppress("=")+number,default=1)))
    marking = ".marking"+Suppress("{") + marking_list("marking") + Suppress("}") + newlines
    pn = Optional(newlines) + Optional(modelName) + signalNames + graph + Optional(capacity) + marking + ".end"
    pn.ignore(pythonStyleComment)
    net = PetriNet(filename=filename, format='sis')
    ast = pn.parseFile( filename )
    for t in ast.signals:
        net.add_transition( t )
    #net.name = ast.modelName
    net.set_name(ast.modelName)
    #net.signals.update( ast.signals )
#    tuplelist = [ (m[0],m[1]) for m in ast.capacities ]
#    net.capacities = dict( tuplelist )
#    net.initial_marking = dict( [ (m[0],m[1]) for m in ast.marking ] )
    #print ast.arcs
    transitions = set(net.get_transitions())
    for a in ast.arcs:
        #print a[0]
        if a[0] not in transitions:
            # it's a place
            p = net.add_place(a[0])
            for t in a[1:]:
                net.add_edge(p,t[0],t[1])
        else:
            for t in a[1:]:
                p = net.add_place(t[0])
                net.add_edge(a[0],p,t[1])
    for m in ast.marking:
        net.set_initial_marking(m[0],m[1])
    for m in ast.capacities:
        net.set_capacity(m[0],m[1])
    net.to_initial_marking()
    return net
开发者ID:andycsoto,项目名称:pmlab,代码行数:49,代码来源:utils.py

示例14: rfc2822

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
def rfc2822():
    global _rfc2822
    if _rfc2822 is None:
        ParserElement.setDefaultWhitespaceChars("")
        
        CRLF = Literal("\r\n")
        ATEXT = Regex("[a-zA-Z0-9!#$%&'*+\-/=\?^_`{|}~]")
        TEXT = Regex("[\x01-\x09\x0b\x0c\x0e-\x7f]")
        QTEXT = Regex("[\x01-\x08\x0b\x0c\x0d-\x1f\x21\x23-\x5b\x5d-\x7f]")
        LOWASCII = Regex("[\x00-\x7f]")
        DTEXT = Regex("[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x5e-\x7f]")
        WSP = Regex("[\x20\x09]")
        CTEXT = Regex("[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x27\x2a-\x5b\x5d-\x7f]")

        obsQp = r"\\" + LOWASCII
        quotedPair = (r"\\" + TEXT) | obsQp

        obsFWS = OneOrMore(WSP) + ZeroOrMore(CRLF + OneOrMore(WSP))
        FWS = (Optional(ZeroOrMore(WSP) + CRLF) + OneOrMore(WSP)) | obsFWS
        comment = Forward()
        ccontent = CTEXT | quotedPair | comment
        comment << "(" + ZeroOrMore(Optional(FWS) + ccontent) + Optional(FWS) + ")"
        CFWS = ZeroOrMore(Optional(FWS) + comment) + ((Optional(FWS) + comment) | FWS)

        atom = Optional(CFWS) + OneOrMore(ATEXT) + Optional(CFWS)
        dotAtomText = OneOrMore(ATEXT) + ZeroOrMore("." + OneOrMore(ATEXT))
        dotAtom = Optional(CFWS) + dotAtomText + Optional(CFWS)

        qcontent = QTEXT | quotedPair
        quotedString = Optional(CFWS) + '"' + ZeroOrMore(Optional(FWS) + qcontent) + Optional(FWS) + '"'

        word = atom | quotedString
        obsLocalPart = word + ZeroOrMore("." + word)

        localPart = dotAtom | quotedString | obsLocalPart

        dcontent = DTEXT | quotedPair
        domainLiteral = Optional(CFWS) + "[" + ZeroOrMore(Optional(FWS) + dcontent) + Optional(FWS) + "]" + Optional(CFWS)

        obsDomain = atom + ZeroOrMore("." + atom)

        domain = dotAtom | domainLiteral | obsDomain

        addrSpec = localPart + "@" + domain
        _rfc2822 = addrSpec
    return _rfc2822
开发者ID:green-span,项目名称:green-mail,代码行数:48,代码来源:util.py

示例15: property_grammar

# 需要导入模块: from pyparsing import ParserElement [as 别名]
# 或者: from pyparsing.ParserElement import setDefaultWhitespaceChars [as 别名]
def property_grammar():
    ParserElement.setDefaultWhitespaceChars(' ')

    model_props = [Regex(r'LIBINPUT_MODEL_[_0-9A-Z]+')('NAME')
                   - Suppress('=') -
                   (Literal('1'))('VALUE')
                  ]

    dimension = INTEGER('X') + Suppress('x') + INTEGER('Y')
    sz_props = (
            ('LIBINPUT_ATTR_SIZE_HINT', Group(dimension('SETTINGS*'))),
            ('LIBINPUT_ATTR_RESOLUTION_HINT', Group(dimension('SETTINGS*'))),
            )
    size_props = [Literal(name)('NAME') - Suppress('=') - val('VALUE')
                   for name, val in sz_props]

    grammar = Or(model_props + size_props);

    return grammar
开发者ID:jiixyj,项目名称:libinput,代码行数:21,代码来源:parse_hwdb.py


注:本文中的pyparsing.ParserElement.setDefaultWhitespaceChars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。