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


Python pyparsing.col方法代码示例

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


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

示例1: read_include_contents

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def read_include_contents(s, l, t):
    include_file_ref = t.include_file_name
    include_echo = "/* {} */".format(pp.line(l, s).strip())

    # guard against recursive includes
    if include_file_ref not in seen:
        seen.add(include_file_ref)
        included_file_contents = Path(include_file_ref).read_text()
        return (
            include_echo
            + "\n"
            + include_directive.transformString(included_file_contents)
        )
    else:
        lead = " " * (pp.col(l, s) - 1)
        return "/* recursive include! */\n{}{}".format(lead, include_echo)


# attach include processing method as parse action (parse-time callback)
# to include_directive expression 
开发者ID:pyparsing,项目名称:pyparsing,代码行数:22,代码来源:include_preprocessor.py

示例2: testCompletePastIncludesWhenFileChangesAndCachingDisabled

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def testCompletePastIncludesWhenFileChangesAndCachingDisabled(self):
    includable = ["before = 1;"]
    def load_from_var(base, rel, env=None):
      return gcl.loads(includable[0], env=env)

    source = """
    inc = include 'inc.gcl';
    bar = inc.|
    """.strip()
    source, line, col = find_cursor(source)
    tree = gcl.reads(source, filename='input.gcl', allow_errors=True, loader=load_from_var)

    with framework.DisableCaching():
      completions = ast_util.find_completions_at_cursor(tree, 'input.gcl', line, col)
    self.assertTrue('before' in completions)

    includable[0] = "after = 2;"

    with framework.DisableCaching():
      completions = ast_util.find_completions_at_cursor(tree, 'input.gcl', line, col)
    self.assertTrue('after' in completions) 
开发者ID:rix0rrr,项目名称:gcl,代码行数:23,代码来源:test_astutil.py

示例3: mustMatchCols

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def mustMatchCols(startloc,endloc):
    return lambda s,l,t: startloc <= col(l,s) <= endloc

# helper to define values in a space-delimited table
# (change empty_cell_is_zero to True if a value of 0 is desired for empty cells) 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:7,代码来源:parseTabularData.py

示例4: mustMatchCols

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def mustMatchCols(startloc, endloc):
    return lambda s, l, t: startloc <= col(l, s) <= endloc


# helper to define values in a space-delimited table
# (change empty_cell_is_zero to True if a value of 0 is desired for empty cells) 
开发者ID:pyparsing,项目名称:pyparsing,代码行数:8,代码来源:parseTabularData.py

示例5: testScopeObjectHasLocation

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def testScopeObjectHasLocation(self):
    scope = readAndQueryScope('|henk = 5')
    self.assertEquals(1, scope['henk'].location.lineno)
    self.assertEquals(1, scope['henk'].location.col) 
开发者ID:rix0rrr,项目名称:gcl,代码行数:6,代码来源:test_astutil.py

示例6: readAndQueryScope

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def readAndQueryScope(source, **kwargs):
  source, line, col = find_cursor(source)
  tree = gcl.reads(source, filename='input.gcl', **kwargs)
  rootpath = tree.find_tokens(gcl.SourceQuery('input.gcl', line, col))
  return ast_util.enumerate_scope(rootpath) 
开发者ID:rix0rrr,项目名称:gcl,代码行数:7,代码来源:test_astutil.py

示例7: readAndAutocomplete

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def readAndAutocomplete(source, root_env=gcl.Environment({})):
  source, line, col = find_cursor(source)
  tree = gcl.reads(source, filename='input.gcl', allow_errors=True)
  return ast_util.find_completions_at_cursor(tree, 'input.gcl', line, col, root_env=root_env) 
开发者ID:rix0rrr,项目名称:gcl,代码行数:6,代码来源:test_astutil.py

示例8: readAndFindValue

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def readAndFindValue(source):
  source, line, col = find_cursor(source)
  tree = gcl.reads(source, filename='input.gcl', allow_errors=True)
  return ast_util.find_value_at_cursor(tree, 'input.gcl', line, col) 
开发者ID:rix0rrr,项目名称:gcl,代码行数:6,代码来源:test_astutil.py

示例9: col

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def col(self):
    return p.col(self.start_offset, self.string) 
开发者ID:rix0rrr,项目名称:gcl,代码行数:4,代码来源:ast.py

示例10: end_col

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def end_col(self):
    assert self.end_offset is not None
    return p.col(self.end_offset, self.string) 
开发者ID:rix0rrr,项目名称:gcl,代码行数:5,代码来源:ast.py

示例11: contains

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def contains(self, q):
    return (q.filename == self.filename
        and (q.line > self.lineno or (q.line == self.lineno and q.col >= self.col))
        and (q.line < self.end_lineno or (q.line == self.end_lineno and q.col < self.end_col))) 
开发者ID:rix0rrr,项目名称:gcl,代码行数:6,代码来源:ast.py

示例12: __repr__

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def __repr__(self):
    return 'SourceLocation(%r, %r:%r, %r:%r)' % (self.filename, self.lineno, self.col, self.end_lineno, self.end_col) 
开发者ID:rix0rrr,项目名称:gcl,代码行数:4,代码来源:ast.py

示例13: __init__

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def __init__(self, filename, line, col):
    self.filename = filename
    self.line = line
    self.col = col 
开发者ID:rix0rrr,项目名称:gcl,代码行数:6,代码来源:ast.py

示例14: find_offset

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def find_offset(s, line, col):
  c_line = 1
  c_col = 1
  for i in range(len(s)):
    if (c_line == line and c_col >= col) or c_line > line:
      return i
    if s[i] == '\n':
      c_col = 1
      c_line += 1
    else:
      c_col += 1
  return len(s) 
开发者ID:rix0rrr,项目名称:gcl,代码行数:14,代码来源:ast.py

示例15: reads

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import col [as 别名]
def reads(s, filename, loader, implicit_tuple, allow_errors):
  """Load but don't evaluate a GCL expression from a string."""
  try:
    the_context.filename = filename
    the_context.loader = loader

    grammar = make_grammar(allow_errors=allow_errors)
    root = grammar.start_tuple if implicit_tuple else grammar.start

    return root.parseWithTabs().parseString(s, parseAll=True)[0]
  except (p.ParseException, p.ParseSyntaxException) as e:
    loc = SourceLocation(s, find_offset(s, e.lineno, e.col))
    raise exceptions.ParseError(the_context.filename, loc, e.msg) 
开发者ID:rix0rrr,项目名称:gcl,代码行数:15,代码来源:ast.py


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