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


Python scheme_tokens.tokenize_lines函数代码示例

本文整理汇总了Python中scheme_tokens.tokenize_lines函数的典型用法代码示例。如果您正苦于以下问题:Python tokenize_lines函数的具体用法?Python tokenize_lines怎么用?Python tokenize_lines使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: buffer_lines

def buffer_lines(lines, prompt="scm> ", show_prompt=False):
    """Return a Buffer instance iterating through LINES."""
    if show_prompt:
        input_lines = lines
    else:
        input_lines = LineReader(lines, prompt)
    return Buffer(tokenize_lines(input_lines))
开发者ID:carolinekim,项目名称:scheme,代码行数:7,代码来源:scheme_reader.py

示例2: run_tests

def run_tests(src_file = 'tests.scm'):
    """Run a read-eval loop that reads from src_file and collects outputs."""
    sys.stderr = sys.stdout = io.StringIO() # Collect output to stdout and stderr
    try:
        reader = TestReader(open(src_file).readlines())
        src = Buffer(tokenize_lines(reader))
        def next_line():
            src.current()
            return src
        read_eval_print_loop(next_line, create_global_frame())
    except BaseException as exc:
        sys.stderr = sys.__stderr__
        print("Tests terminated due to unhandled exception "
              "after line {0}:\n>>>".format(reader.line_number),
              file=sys.stderr)
        raise
    output = sys.stdout.getvalue().split('\n')
    sys.stdout = sys.__stdout__  # Revert stdout
    summarize(output, reader.expected_output)
开发者ID:ADanilychevJr,项目名称:Fall2012,代码行数:19,代码来源:scheme_test.py

示例3: read_line

def read_line(line):
    """Read a single string LINE as a Scheme expression."""
    return scheme_read(Buffer(tokenize_lines([line])))
开发者ID:carolinekim,项目名称:scheme,代码行数:3,代码来源:scheme_reader.py

示例4: buffer_input

def buffer_input(prompt="scm> "):
    """Return a Buffer instance containing interactive input."""
    return Buffer(tokenize_lines(InputReader(prompt)))
开发者ID:carolinekim,项目名称:scheme,代码行数:3,代码来源:scheme_reader.py

示例5: buffer_lines

def buffer_lines(lines, prompt="scm> "):
    """Return a Buffer instance iterating through LINES."""
    return Buffer(tokenize_lines(LineReader(lines, prompt)))
开发者ID:asingh16,项目名称:Scheme_Project,代码行数:3,代码来源:scheme_reader.py

示例6: buffer_input

def buffer_input(prompt="scm> "): # 从输入获取一行,然后将这一行数据传递给tokenize_lines
    # tokenize_lines处理之后,输出串token,传递个buffer,buffer可是一个可以迭代的对象,所以,你懂的!
    """Return a Buffer instance containing interactive input."""
    return Buffer(tokenize_lines(InputReader(prompt)))
开发者ID:lishuhuakai,项目名称:CS,代码行数:4,代码来源:scheme_reader.py

示例7: buffer_input

def buffer_input():
    return Buffer(tokenize_lines(InputReader('> ')))
开发者ID:kevinchau321,项目名称:cs61a,代码行数:2,代码来源:scheme_reader.py

示例8: Buffer

from scheme_reader import *
from buffer import Buffer, InputReader, LineReader
from scheme_tokens import tokenize_lines, DELIMITERS 

lines = ["(+ 1 ", "(+ 23 4)) ("]
src = Buffer(tokenize_lines(lines))
print(scheme_read(src))
print(repr(read_line("'hello")))
print(read_line("(car '(1 2))"))

print(repr(read_tail(Buffer(tokenize_lines([")"])))))
print(repr(read_tail(Buffer(tokenize_lines(["2 3)"])))))
print(repr(read_tail(Buffer(tokenize_lines(["2 (3 4))"])))))
print(repr(read_line("(1 . 2)")))
print(repr(read_line("(1 2 . 3)")))
print(repr(read_line("(1 . 2 3)")))
print(repr(scheme_read(Buffer(tokenize_lines(["(1", "2 .", "'(3 4))", "4"])))))

开发者ID:Arctangent1759,项目名称:Python_Scheme_Interpreter,代码行数:17,代码来源:mytests.py

示例9: scheme_repl

def scheme_repl(source, prompt, env, print_input=True):
    """Start a read-eval-print loop reading from SOURCE."""
    read_eval_print(Buffer(tokenize_lines(source)), prompt, env, print_input)
开发者ID:anjishnu,项目名称:Schemer,代码行数:3,代码来源:scheme.py


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