Ejemplo n.º 1
0
 def setup_class(self):
     self.parser = get_parser()
     self.lexer = get_lexer()
     self.space = Space()
     self.space.setup_builtins(*default_builtins(self.space))
     self.interpreter = Interpreter()
     self.space.setup(self.interpreter)
Ejemplo n.º 2
0
 def setup_class(self):
     self.parser = get_parser()
     self.lexer = get_lexer()
     self.space = Space()
     builtins, core_mods, not_builtins = default_builtins(self.space)
     builtins.append(magic_log)
     self.space.setup_builtins(builtins, core_mods, not_builtins)
     self.space.log = []
     self.interpreter = Interpreter()
     self.space.setup(self.interpreter)
Ejemplo n.º 3
0
 def test_program(self):
     tokens = [x.name for x in get_lexer().lex("function name () {}")]
     assert tokens == [
         'FUNCTION', 'IDENTIFIER', 'LEFT_PAREN', 'RIGHT_PAREN',
         'LEFT_CURLY_BRACE', 'RIGHT_CURLY_BRACE'
     ]
Ejemplo n.º 4
0
 def test_one_plus_two(self):
     tokens = [x.name for x in get_lexer().lex('1+1')]
     assert tokens == ['INTEGER', 'PLUS', 'INTEGER']
Ejemplo n.º 5
0
 def setup_class(self):
     self.parser = get_parser()
     self.lexer = get_lexer()
Ejemplo n.º 6
0
 def setup_class(self):
     self.parser = get_parser()
     self.lexer = get_lexer()
Ejemplo n.º 7
0
Archivo: main.py Proyecto: fijal/quill
    assert i >= 0
    head, tail = p[:i], p[i:]
    if head and head != '/' * len(head):
        head = head.rstrip('/')
    return head, tail


def main(argv):
    if len(argv) != 2:
        print __doc__
        return 1
    return run_code(argv[1])


parser = get_parser()
lexer = get_lexer()
space = Space()
space.setup_builtins(*default_builtins(space))


def format_parser_error(pe):
    print "Error parsing input file %s, line %d: %s" % (pe.filename, pe.lineno,
        pe.msg)
    print "  " + pe.line
    print "  " + " " * pe.start_colno + "^" * (pe.end_colno - pe.start_colno)


def parse_name(fname):
    name = path_split(fname)[-1]
    p = name.rfind(".")
    if p > 0:
Ejemplo n.º 8
0
    assert i >= 0
    head, tail = p[:i], p[i:]
    if head and head != '/' * len(head):
        head = head.rstrip('/')
    return head, tail


def main(argv):
    if len(argv) != 2:
        print __doc__
        return 1
    return run_code(argv[1])


parser = get_parser()
lexer = get_lexer()
space = Space()
space.setup_builtins(*default_builtins(space))


def format_parser_error(pe):
    print "Error parsing input file %s, line %d: %s" % (pe.filename, pe.lineno,
        pe.msg)
    print "  " + pe.line
    print "  " + " " * pe.start_colno + "^" * (pe.end_colno - pe.start_colno)


def parse_name(fname):
    name = path_split(fname)[-1]
    p = name.rfind(".")
    if p > 0:
Ejemplo n.º 9
0
 def test_program(self):
     tokens = [x.name for x in get_lexer().lex('', "def name () {}")]
     assert tokens == [
         'DEF', 'IDENTIFIER', 'LEFT_PAREN', 'RIGHT_PAREN',
         'LEFT_CURLY_BRACE', 'RIGHT_CURLY_BRACE'
     ]
Ejemplo n.º 10
0
 def test_keyword_varname(self):
     tokens = [x.name for x in get_lexer().lex('', '1 + varfoo')]
     assert tokens == ['INTEGER', 'PLUS', 'IDENTIFIER']
     tokens = [x.name for x in get_lexer().lex('', '1 + let')]
     assert tokens == ['INTEGER', 'PLUS', 'LET']
Ejemplo n.º 11
0
 def test_one_plus_two(self):
     tokens = [x.name for x in get_lexer().lex('', '1+1')]
     assert tokens == ['INTEGER', 'PLUS', 'INTEGER']
Ejemplo n.º 12
0
 def test_program(self):
     tokens = [x.name for x in get_lexer().lex('', "def name () {}")]
     assert tokens == ['DEF', 'IDENTIFIER', 'LEFT_PAREN', 'RIGHT_PAREN',
                       'LEFT_CURLY_BRACE', 'RIGHT_CURLY_BRACE']
Ejemplo n.º 13
0
 def test_keyword_varname(self):
     tokens = [x.name for x in get_lexer().lex('', '1 + varfoo')]
     assert tokens == ['INTEGER', 'PLUS', 'IDENTIFIER']
     tokens = [x.name for x in get_lexer().lex('', '1 + let')]
     assert tokens == ['INTEGER', 'PLUS', 'LET']