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


Python Combine.setResultsName方法代码示例

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


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

示例1: receiver_input_rule

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
        def receiver_input_rule():
            path = Combine(ZeroOrMore(word + ".") + word)
            input = path.setResultsName("input")

            operator = oneOf(operators.keys()).setResultsName("operator")
            value = path.setResultsName("value")
            comparison = operator + value

            is_or_was = Word("is") | Word("was")

            condition = Group(input + is_or_was.setResultsName("temporal") + comparison)
            res = ZeroOrMore(condition + _and) + condition
            conditions = Group(res).setResultsName("conditions")

            return Optional("always").setResultsName("always_fire_rule") + when + conditions + then + actions
开发者ID:abultman,项目名称:PiAutomator,代码行数:17,代码来源:RuleParser.py

示例2: make_enewick_parser

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
def make_enewick_parser():
    # atoms
    lparen = Literal("(").suppress()
    rparen = Literal(")").suppress()
    colon = Literal(":").suppress()
    # semicolon = Literal(";").suppress()
    comma = Literal(",").suppress()
    point = Literal(".")
    e = CaselessLiteral("E")
    sharp = Literal("#").suppress()

    # terminal
    name = Word(
        alphanums + alphas8bit + "_" + "-" + "." + "+" + "&" + "/" + "~" + "{" + "}" + "*" + "'" + '"' + "\\" + "?"
    )
    string = Word(alphas)
    fnumber = Combine(
        Word("+-" + nums, nums) + Optional(point + Optional(Word(nums))) + Optional(e + Word("+-" + nums, nums))
    ).setParseAction(cvtReal)
    number = Combine(Word(nums)).setParseAction(cvtInt)

    label = (
        Optional(name).setResultsName("label")
        + Optional(sharp + Optional(string).setResultsName("type") + number.setResultsName("tag"))
        + Optional(colon + fnumber).setResultsName("length")
    )

    subtree = Forward()
    subtreelist = Forward()
    subtree << Group(((lparen + subtreelist + rparen).setResultsName("subtree") | label) + Optional(label))
    subtreelist << subtree + Optional(comma + subtreelist)

    tree = subtree + Word(";").suppress()

    return tree.parseString
开发者ID:paurullan,项目名称:phylonets,代码行数:37,代码来源:enewick.py

示例3: expression

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
    def expression(self):
        from pyparsing import Suppress,Combine,Optional,oneOf,OneOrMore,Word,nums,Group,alphas,alphanums,Literal,SkipTo,empty,lineEnd
        cvtInt = lambda toks: int(toks[0])
        cvtReal = lambda toks: float(toks[0])
        cvtTuple = lambda toks : tuple(toks.asList())
        nameJoin = lambda toks : "".join([tok.replace("#","") for tok in toks[0]])
        #lambda toks: " ".join([str(t) for t in toks[0]])
        
        # define punctuation as suppressed literals
        lparen,rparen,lbrack,rbrack,lbrace,rbrace,colon = map(Suppress,"()[]{}:")

        integer = Combine(Optional(oneOf("+ -")) + Word(nums))\
            .setName("integer")\
            .setParseAction( cvtInt )
        real = Combine(Optional(oneOf("+ -")) + Word(nums) + "." +
                       Optional(Word(nums)) +
                       Optional(oneOf("e E")+Optional(oneOf("+ -")) +Word(nums))).setName("real").setParseAction( cvtReal )

        # TREE DEFINITION
        # ((seq2: 0.537243, seq1: 0.000004): 0.255741, seq3: 0.281503);
        tree_w_branches = (
            OneOrMore(Word("():,."+alphas+nums))+Literal(";")
            ).setParseAction(lambda tokens: " ".join(tokens[:-1])+";")

        # SITE PROBABILITIES
        # site Freq Data:
        # 1    1    AAA: A(0.978) A(1.000)
        site_prob = (
            integer.setResultsName("site",listAllMatches=True) + 
            integer.setResultsName("freq",listAllMatches=True) + 
            Word(alphas+"-").setResultsName("extant",listAllMatches=True) + colon + 
            Group(OneOrMore(Group(Word(alphas,exact=1)+lparen+real+rparen))).setResultsName("probability",listAllMatches=True) +
            lineEnd
            )

        # ANCESTRAL SEQUENCES
        # seq1       ACC
        # node #4    ACC
        # Optional # character with node # needs to be joined into a single name
        sequence =  (
                     Group(Word(alphanums)+
                           Optional(Combine(Literal("#")+Word(nums)))).setParseAction(nameJoin).setResultsName("name",listAllMatches=True)+
                           Word(alphas+"- ").setResultsName("sequence", listAllMatches=True)+lineEnd
                    )
                     
        
        return (SkipTo(Literal("Ancestral reconstruction by AAML."),include=True).suppress() +
                tree_w_branches.setResultsName("tree") +
                SkipTo(Literal("site")+Literal("Freq")+Literal("Data:"), include=True,).suppress()+
                Group(OneOrMore(site_prob)).setResultsName("sites")+
                SkipTo(Literal("List of extant and reconstructed sequences")+Word(nums)+Word(nums), include=True).suppress()+
                Group(OneOrMore(sequence)).setResultsName("sequences")+
                SkipTo(Literal("for a site."),include=True).suppress()+
                Group(OneOrMore(real)).setResultsName("probability")+
                empty
                )
开发者ID:bsmithers,项目名称:hpf,代码行数:58,代码来源:paml.py

示例4: _get_handbrake_title_pattern

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
    def _get_handbrake_title_pattern(self):
        title = Literal("+ title").suppress()
        integer = Word("0123456789")
        time = Combine(integer + ":" + integer + ":" + integer)
        duration = Literal("+ duration:").suppress()
        subtitle = Literal("+ subtitle tracks:")
        iso = Literal('(iso639-2:').suppress() + Word(alphas)
        subtitle_track = Literal("+").suppress() + Group(integer + SkipTo(iso).suppress() + iso) + restOfLine.suppress()

        title_num = integer.setResultsName("title")
        duration_num = time.setResultsName("duration")
        subtitles = Group(ZeroOrMore(subtitle_track)).setResultsName("subtitles")

        pattern = title + title_num + \
            SkipTo(duration).suppress() + \
            duration + duration_num + \
            SkipTo(subtitle).suppress() + subtitle.suppress() + subtitles
            
        return pattern
开发者ID:jeffreyparker,项目名称:brakejob,代码行数:21,代码来源:brakejob.py

示例5: getLogLineBNF

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
def getLogLineBNF():
    global logLineBNF
    
    if logLineBNF is None:
        integer = Word( nums )
        ipAddress = delimitedList( integer, ".", combine=True )
        
        timeZoneOffset = Word("+-",nums)
        month = Word(string.uppercase, string.lowercase, exact=3)
        serverDateTime = Combine( Suppress("[") + 
                                Combine( integer + "/" + month + "/" + integer +
                                        ":" + integer + ":" + integer + ":" + integer + ' '  + timeZoneOffset) + 
                                Suppress("]") )
                         
        logLineBNF = ( ipAddress.setResultsName("ipAddr") + 
                       Suppress("-") +
                       ("-" | Word( alphas+nums+"@._" )).setResultsName("auth") +
                       serverDateTime.setResultsName("timestamp") + 
                       dblQuotedString.setResultsName("cmd").setParseAction(getCmdFields) +
                       (integer | "-").setResultsName("statusCode") + 
                       (integer | "-").setResultsName("numBytesSent")  + 
                       dblQuotedString.setResultsName("referrer").setParseAction(removeQuotes) +
                       dblQuotedString.setResultsName("clientSfw").setParseAction(removeQuotes) )
    return logLineBNF
开发者ID:meastim,项目名称:ajaxlogsbrowser,代码行数:26,代码来源:apachehttpd_log2pg.py

示例6: L

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
NIL = L('"-"')
NIL.setName("Nil")
NIL.setParseAction(lambda s, l, t: NilValue)

PRIORITY = LANGLE + Word(srange("[0-9]"), min=1, max=3) + RANGLE  # 191 Max
PRIORITY = PRIORITY.setResultsName("priority")
PRIORITY.setName("Priority")
PRIORITY.setParseAction(lambda s, l, t: int(t[0]))

TIMESTAMP = Word(printables)
TIMESTAMP = TIMESTAMP.setResultsName("timestamp")
TIMESTAMP.setName("Timestamp")

HOSTNAME = Combine(NIL | Word(printables))
HOSTNAME = HOSTNAME.setResultsName("hostname")
HOSTNAME.setName("Hostname")

APPNAME = Word("".join(set(printables) - {"["}))
APPNAME = APPNAME.setResultsName("appname")
APPNAME.setName("AppName")

PROCID = Combine(LBRACKET + Word("".join(set(printables) - {"]"})) + RBRACKET)
PROCID = PROCID.setResultsName("procid")
PROCID.setName("ProcID")

HEADER = PRIORITY + TIMESTAMP + SP + HOSTNAME + SP + APPNAME + PROCID

MESSAGE = restOfLine.setResultsName("message")
MESSAGE.setName("Message")
开发者ID:pypa,项目名称:linehaul,代码行数:31,代码来源:parser.py

示例7: OneOrMore

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
            + ":=" + OneOrMore(matrix_row).setResultsName('data')
    matrix_data.setParseAction(MatrixData)

    tr_matrix_data = Suppress("(tr)") + matrix_data
    tr_matrix_data.setParseAction(mark_transposed)

    set_slice_component = number | symbol | '*'
    set_slice_record = LPAREN + NotAny('tr') + delimitedList(set_slice_component) + RPAREN
    set_slice_record.setParseAction(SliceRecord)

    _set_record = set_slice_record | matrix_data | tr_matrix_data | Suppress(":=")
    set_record = simple_data | _set_record
    non_dimen_set_record = non_dimen_simple_data | _set_record

    set_def_stmt = "set" + symbol + Optional(subscript_domain) + \
            Optional("dimen" + integer.setResultsName('dimen')) + END
    set_def_stmt.setParseAction(SetDefStmt)

    set_member = LBRACKET + delimitedList(data) + RBRACKET

    set_stmt = "set" + symbol + Optional(set_member).setResultsName("member") + \
            Group(non_dimen_set_record + ZeroOrMore(Optional(Suppress(',')) + set_record)) \
            .setResultsName("records") + END
    set_stmt.setParseAction(SetStmt)

    subscript = single

    param_data = data | '.'
    plain_data = param_data | subscript + ZeroOrMore(Optional(Suppress(',')) +
                                               subscript) + param_data
    # should not match a single (tr)
开发者ID:Jonathanzc,项目名称:pulp,代码行数:33,代码来源:amply.py

示例8: Literal

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
colon = Literal(":")
rfc3164_date = Word(nums, min=4, max=4) + dash + Word(nums, min=2, max=2) + dash + Word(nums, min=2, max=2)
rfc3164_time = Word(nums, min=2, max=2) + colon + Word(nums, min=2, max=2) + colon + Word(nums, min=2, max=2) + \
    Optional(Literal(".") + Word(nums, min=1, max=6))
rfc3164_timenumoffset = Or("+", "-") + Word(nums, min=2, max=2) + colon + Word(nums, min=2, max=2)
rfc3164_timeoffset = Literal("Z") | rfc3164_timenumoffset
rfc3164_timestamp = Combine(rfc3164_date + Literal("T") + rfc3164_time + rfc3164_timeoffset)

timestamp = NilValue | rfc3164_timestamp
hostname = NilValue | Word(printables, min=1, max=255)
appname = NilValue | Word(printables, min=1, max=48)
procname = NilValue | Word(printables, min=1, max=128).setParseAction(maybeToInt)
msgid = NilValue | Word(printables, min=1, max=32)

header = Group(
    pri.setResultsName('pri') + version.setResultsName('version') + SP +
    timestamp.setResultsName('timestamp') + SP + hostname.setResultsName('hostname') + SP +
    appname.setResultsName('appname') + SP + procname.setResultsName('procname') + SP +
    msgid.setResultsName('msgid')
)

sd_name = Word(NameAscii, min=1, max=32)
sd_id = sd_name
param_name = sd_name
sd_param = Group(
    param_name.setResultsName('param_name') + Suppress(Literal("=")) +
    QuotedString(quoteChar='"', escChar='\\', escQuote='\\').setResultsName('param_value')
)

sd_element = Group(
    Suppress("[") + sd_id.setResultsName('sd_id') + ZeroOrMore(SP + sd_param).setResultsName('sd_params') +
开发者ID:EasyPost,项目名称:syslog-rfc5424-parser,代码行数:33,代码来源:parser.py

示例9: Or

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
structured_data = Or([nilvalue, sd_elements.setResultsName("SD_ELEMENTS")])
structured_data = structured_data.setResultsName("STRUCTURED_DATA")
time_hour = Regex("0[0-9]|1[0-9]|2[0-3]")
time_minute = Regex("[0-5][0-9]")
time_second = time_minute
time_secfrac = Regex("\.[0-9]{1,6}")
time_numoffset = Or([Regex("\+"), Regex("-")]) + time_hour + ":" + time_minute
time_offset = Or([Regex("Z"), time_numoffset])
partial_time = time_hour + ":" + time_minute + ":" + time_second + Optional(time_secfrac)
full_time = partial_time + time_offset
date_mday = Regex("[0-9]{2}")
date_month = Regex("0[1-9]|1[0-2]")
date_fullyear = Regex("[0-9]{4}")
full_date = date_fullyear + "-" + date_month + "-" + date_mday
timestamp = Combine(Or([nilvalue, full_date + "T" + full_time]))
timestamp = timestamp.setResultsName("TIMESTAMP")
msgid = Or([nilvalue, CharsNotIn('= ]"', 1, 32)])
if SUPPORT_MISSING_VALUES:
    msgid = Optional(msgid)
msgid = msgid.setResultsName("MSGID")
procid = Or([nilvalue, CharsNotIn('= ]"', 1, 128)])
if SUPPORT_MISSING_VALUES:
    procid = Optional(procid)
procid = procid.setResultsName("PROCID")
app_name = Or([nilvalue, CharsNotIn('= ]"', 1, 48)])
if SUPPORT_MISSING_VALUES:
    app_name = Optional(app_name)
app_name = app_name.setResultsName("APP_NAME")
hostname = Or([nilvalue, CharsNotIn('= ]"', 1, 255)])
if SUPPORT_MISSING_VALUES:
    hostname = Optional(hostname)
开发者ID:AlekSi,项目名称:loggerglue,代码行数:33,代码来源:rfc5424.py

示例10: Grammar

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]

#.........这里部分代码省略.........
        self.allow_slice_list = True
        self.interval = {':': 'closed'}

    def _dialect__python_slice(self):
        self._dialect__slice_list()
        self.allow_slice_list = False

    def _dialect__dot_notation(self):
        self._dialect__slice_list()
        range_sep = Combine(Optional('.') + ':' + Optional('.'))
        self.range_sep = range_sep ^ '..'
        self.interval = {':': 'closed', '.:': 'left-open', ':.': 'right-open',
                         '.:.': 'open', '..': 'open'}

    def _dialect__double_dot(self):
        self._dialect__slice_list()
        self.range_sep = Combine('..' + Optional('.'))
        self.allow_stepped_interval = False
        self.interval = {'..': 'closed', '...': 'right-open'}

    def _dialect__unix_cut(self):
        self._dialect__slice_list()
        self.range_sep = '-'
        self.allow_relative_indices = False
        self.allow_stepped_interval = False

    def validate_separators(self):
        """
        Sepaarators can not be alphanumeric when headers are enabled, because
        of potential ambiguity.
        """
        for type_ in ['range', 'step', 'list']:
            try:
                sep = getattr(self, type_ + '_sep')
                if isinstance(sep, str):
                    self.sep.parseString(getattr(self, type_ + '_sep'))
                    setattr(self, type_ + '_sep', Literal(sep))
            except ParseException:
                mesg = ('{} separator can\'t contain alphanumeric or '
                        'underscore characters when headers are enabled.')
                raise ValueError(mesg.format(sep.title()))
        return True

    def _get_slice_item(self):
        index = endpoint = self.endpoint
        short_slice = Optional(endpoint) + self.range_sep + Optional(endpoint)
        if not self.allow_stepped_intervals:
            return Combine(index ^ short_slice)
        long_slice = short_slice + self.step_sep + Optional(self.stride)
        return Combine(index ^ short_slice ^ long_slice)

    def _get_slice_list(self):
        sep = Suppress(self.list_sep)
        slice_item = self._get_slice_item()
        return slice_item + ZeroOrMore(sep + slice_item) + Optional(sep)

    def _build_slice_grammar(self):
        to_int = lambda tok: int(tok[0])
        endpoint = self.endpoint.setResultsName
        range_sep = self.range_sep.setResultsName('range_sep')
        lower_bound = Optional(endpoint('start').setParseAction(to_int))
        upper_bound = Optional(endpoint('stop').setParseAction(to_int))
        stride = self.stride.setResultsName('step').setParseAction(to_int)
        short_slice = lower_bound + range_sep + upper_bound
        long_slice = short_slice + self.step_sep + Optional(stride)
        index = lower_bound
        if self.allow_stepped_intervals:
            return index ^ short_slice ^ long_slice
        return index ^ short_slice

    def _build_grammar(self):
        self.validate_separators()
        self._slice_grammar = self._build_slice_grammar() + pp.stringEnd
        self._text_grammar = (self._get_slice_list() if self.allow_slice_list
                              else self._get_slice_item()) + pp.stringEnd

    def parse_text(self, text):
        if self._grammar_update:
            self._build_grammar()
            self._grammar_update = False
        try:
            slices = self._text_grammar.parseString(text)
        except ParseException as error:
            info = {'text': text, 'column': error.column}
            raise InvalidSliceString(error.msg, info)
        return (dict(self._slice_grammar.parseString(i)) for i in slices)

    def parse(self, text):
        result = (self._get_interval_args(i) for i in self.parse_text(text))
        return result if self.allow_slice_list else next(result)

    def _get_interval_args(self, slice_):
        range_sep = slice_.get('range_sep')
        if range_sep:
            del slice_['range_sep']
            slice_['type_'] = self.interval.get(range_sep, 'closed')
        else:
            slice_['type_'] = 'closed'
            slice_['stop'] = slice_['start']
        return slice_
开发者ID:bpeterso2000,项目名称:sliced,代码行数:104,代码来源:grammar.py

示例11: Combine

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
integer = (
    Combine(Optional(_sign) + Word(nums)).setName("number").setResultsName("number")
)
boolean = (upkey("true") | upkey("false")).setName("bool")
binary = Combine("b" + quotedString)

value = Forward()
json_value = Forward()
string = quotedString.setResultsName("str")
json_primitive = (
    null.setResultsName("null") | number | string | boolean.setResultsName("bool")
)
set_primitive = (
    number.setResultsName("number")
    | quotedString.setResultsName("str")
    | binary.setResultsName("binary")
)
primitive = json_primitive | binary.setResultsName("binary")
_emptyset = Keyword("()").setResultsName("set")
set_ = (
    Suppress("(") + delimitedList(Group(set_primitive)) + Suppress(")")
).setResultsName("set")
list_ = (
    Suppress("[") + Optional(delimitedList(json_value)) + Suppress("]")
).setResultsName("list")
key_val = Group(quotedString.setResultsName("str")) + Suppress(":") + json_value
dict_ = (
    Suppress("{") + Optional(delimitedList(Group(key_val))) + Suppress("}")
).setResultsName("dict")
json_value <<= Group(json_primitive | list_ | dict_)
开发者ID:mathcamp,项目名称:dql,代码行数:32,代码来源:common.py

示例12: __init__

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
    def __init__(self, query):
        self._methods = {
            'and': self.evaluate_and,
            'or': self.evaluate_or,
            'not': self.evaluate_not,
            'parenthesis': self.evaluate_parenthesis,
            'quotes': self.evaluate_quotes,
            'word': self.evaluate_word,
        }

        self.line = ''
        self.query = query.lower() if query else ''

        if self.query:
            # TODO: Cleanup
            operator_or = Forward()
            operator_word = Group(Word(alphanums)).setResultsName('word')

            operator_quotes_content = Forward()
            operator_quotes_content << (
                (operator_word + operator_quotes_content) | operator_word
            )

            operator_quotes = Group(
                Suppress('"') + operator_quotes_content + Suppress('"')
            ).setResultsName('quotes') | operator_word

            operator_parenthesis = Group(
                (Suppress('(') + operator_or + Suppress(")"))
            ).setResultsName('parenthesis') | operator_quotes

            operator_not = Forward()
            operator_not << (Group(
                Suppress(Keyword('no', caseless=True)) + operator_not
            ).setResultsName('not') | operator_parenthesis)

            operator_and = Forward()
            operator_and << (Group(
                operator_not + Suppress(Keyword('and', caseless=True)) + operator_and
            ).setResultsName('and') | Group(
                operator_not + OneOrMore(~oneOf('and or') + operator_and)
            ).setResultsName('and') | operator_not)

            operator_or << (Group(
                operator_and + Suppress(Keyword('or', caseless=True)) + operator_or
            ).setResultsName('or') | operator_and)

            self._query_parser = operator_or.parseString(self.query)[0]
        else:
            self._query_parser = False

        time_cmpnt = Word(nums).setParseAction(lambda t: t[0].zfill(2))
        date = Combine((time_cmpnt + '-' + time_cmpnt + '-' + time_cmpnt) + ' ' + time_cmpnt + ':' + time_cmpnt)
        word = Word(printables)

        self._log_parser = (
            date.setResultsName('timestamp') +
            word.setResultsName('log_level') +
            word.setResultsName('plugin') +
            (
                White(min=16).setParseAction(lambda s, l, t: [t[0].strip()]).setResultsName('task') |
                (White(min=1).suppress() & word.setResultsName('task'))
            ) +
            restOfLine.setResultsName('message')
        )
开发者ID:Lukeid,项目名称:Flexget,代码行数:67,代码来源:server.py

示例13: Word

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
_sign = Word('+-', exact=1)
number = Combine(Optional(_sign) + Word(nums) +
                 Optional('.' + Optional(Word(nums)))) \
    .setName('number').setResultsName('number')
integer = Combine(Optional(_sign) + Word(nums)) \
    .setName('number').setResultsName('number')
boolean = (upkey('true') | upkey('false')).setName('bool')
binary = Combine('b' + quotedString)

value = Forward()
json_value = Forward()
string = quotedString.setResultsName('str')
json_primitive = (null.setResultsName('null') |
                  number | string |
                  boolean.setResultsName('bool'))
set_primitive = (number.setResultsName('number') |
                 quotedString.setResultsName('str') |
                 binary.setResultsName('binary'))
primitive = (json_primitive | binary.setResultsName('binary'))
_emptyset = Keyword('()').setResultsName('set')
set_ = (Suppress('(') + delimitedList(Group(set_primitive)) +
        Suppress(')')).setResultsName('set')
list_ = (Suppress('[') + Optional(delimitedList(json_value)) +
         Suppress(']')).setResultsName('list')
key_val = (Group(quotedString.setResultsName('str')) + Suppress(':') +
           json_value)
dict_ = (Suppress('{') + Optional(delimitedList(Group(key_val))) +
         Suppress('}')).setResultsName('dict')
json_value <<= Group(json_primitive | list_ | dict_)

ts_functions = Group(
开发者ID:alexanderlz,项目名称:dql,代码行数:33,代码来源:common.py

示例14: Regex

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
# pylint: disable=C0103
backtickString = Regex(r'`[^`]*`').setName("string enclosed in backticks")

and_, from_, into, in_, table_key, null, where_ = \
    map(upkey, ['and', 'from', 'into', 'in', 'table', 'null', 'where'])

var = Word(alphas, alphanums + '_-').setName('variable').setResultsName('var')
expr = Combine(Optional('m') + backtickString).setName('python expression').setResultsName('python')
table = var.setResultsName('table')
type_ = (upkey('string') |
         upkey('number') |
         upkey('binary'))\
    .setName('type').setResultsName('type')

_sign = Word('+-', exact=1)
num = Combine(Optional(_sign) + Word(nums) +
              Optional('.' + Optional(Word(nums)))).setName('number')

primitive = (null.setResultsName('null') |
             num.setResultsName('number') |
             quotedString.setResultsName('str') |
             Combine('b' + quotedString).setResultsName('binary'))
_emptyset = Keyword('()').setResultsName('set')
set_ = (Suppress('(') + delimitedList(Group(primitive)) +
        Suppress(')')).setResultsName('set')
value = Group(primitive | expr | set_ | _emptyset).setName('value')
# Wrap these in a group so they can be used independently
primitive = Group(primitive | expr).setName('primitive')
set_ = Group(set_ | _emptyset | expr).setName('set')
开发者ID:cce,项目名称:dql,代码行数:31,代码来源:common.py

示例15: Regex

# 需要导入模块: from pyparsing import Combine [as 别名]
# 或者: from pyparsing.Combine import setResultsName [as 别名]
time_hour = Regex('0[0-9]|1[0-9]|2[0-3]')
time_minute = Regex('[0-5][0-9]')
time_second = time_minute
time_secfrac = Regex('\.[0-9]{1,6}')
time_numoffset = Or([Regex('\+'), Regex('-')]) + \
                 time_hour + ':' + time_minute
time_offset = Or([Regex('Z'), time_numoffset])
partial_time = time_hour + ':' + time_minute + ':' + time_second + \
               Optional(time_secfrac)
full_time = partial_time + time_offset
date_mday = Regex('[0-9]{2}')
date_month = Regex('0[1-9]|1[0-2]')
date_fullyear = Regex('[0-9]{4}')
full_date = date_fullyear + '-' + date_month + '-' + date_mday
timestamp = Combine(Or([nilvalue, full_date + 'T' + full_time]))
timestamp = timestamp.setResultsName('TIMESTAMP')
msgid = Or([nilvalue, CharsNotIn('= ]"', 1, 32)])
if SUPPORT_MISSING_VALUES:
    msgid = Optional(msgid)
msgid = msgid.setResultsName('MSGID')
procid = Or([nilvalue,CharsNotIn('= ]"', 1, 128)])
if SUPPORT_MISSING_VALUES:
    procid = Optional(procid)
procid = procid.setResultsName('PROCID')
app_name = Or([nilvalue, CharsNotIn('= ]"', 1, 48)])
if SUPPORT_MISSING_VALUES:
    app_name = Optional(app_name)
app_name= app_name.setResultsName('APP_NAME')
hostname = Or([nilvalue, CharsNotIn('= ]"', 1, 255)])
if SUPPORT_MISSING_VALUES:
    hostname = Optional(hostname)
开发者ID:zenweasel,项目名称:loggerglue,代码行数:33,代码来源:rfc5424.py


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