本文整理汇总了Python中pyparsing.Literal.setName方法的典型用法代码示例。如果您正苦于以下问题:Python Literal.setName方法的具体用法?Python Literal.setName怎么用?Python Literal.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyparsing.Literal
的用法示例。
在下文中一共展示了Literal.setName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Word
# 需要导入模块: from pyparsing import Literal [as 别名]
# 或者: from pyparsing.Literal import setName [as 别名]
quotedArg = ( dblQuotedString | sglQuotedString )
quotedArg.setParseAction(removeQuotes)
quotedArg.setName("quotedArg")
plainArgChars = printables.replace('#', '').replace('"', '').replace("'", "")
plainArg = Word(plainArgChars)
plainArg.setName("plainArg")
arguments = Group(ZeroOrMore(quotedArg | plainArg))
arguments = arguments.setResultsName('arguments')
arguments.setName("arguments")
# comment line.
comment = Literal('#') + restOfLine
comment = comment.suppress()
comment.setName('comment')
full_command = (
comment
| (command + arguments + Optional(comment))
)
full_command.setName('full_command')
###
command_list = [] # filled in by namespaces.init_global_dict().
### command/argument handling.
def process_args(args, globals_dict, locals_dict):
"""
示例2: get_parsing_expr
# 需要导入模块: from pyparsing import Literal [as 别名]
# 或者: from pyparsing.Literal import setName [as 别名]
def get_parsing_expr():
expr = Literal('[') + sts_type + "," + sts_type + Literal(']')
expr.setName('Interval')
return True, expr
示例3: operator
# 需要导入模块: from pyparsing import Literal [as 别名]
# 或者: from pyparsing.Literal import setName [as 别名]
def operator():
token = Literal("+") | Literal("-") | Literal("/") | Literal("*")
token.setName("operator")
token.setResultsName("operator")
return token