コード例 #1
0
def to_ast(s):
    print s
    tp = parse(s)
    print tp
    astb = ASTBuilder()
    astb.sourcename = "test"
    return astb.dispatch(tp)
コード例 #2
0
def to_ast(s):
    print s
    tp = parse(s)
    print tp
    astb = ASTBuilder()
    astb.sourcename = "test"
    return astb.dispatch(tp)
コード例 #3
0
ファイル: test_parser.py プロジェクト: rafaelcaricio/lang-js
 def test_get_pos(self):
     from js import operations
     from pypy.rlib.parsing.tree import Symbol
     astb = ASTBuilder()
     t = self.parse('6')
     assert isinstance(t, Symbol)
     pos = astb.get_pos(t)
     assert pos.lineno == 0
     t = self.parse('[1,]')
     assert not isinstance(t, Symbol)
     pos = astb.get_pos(t)
     assert pos.start == 0
コード例 #4
0
 def test_get_pos(self):
     from js import operations
     from rpython.rlib.parsing.tree import Symbol
     astb = ASTBuilder()
     t = self.parse('6')
     assert isinstance(t, Symbol)
     pos = astb.get_pos(t)
     assert pos.lineno == 0
     t = self.parse('[1,]')
     assert not isinstance(t, Symbol)
     pos = astb.get_pos(t)
     assert pos.start == 0
コード例 #5
0
 def to_ast(self, s):
     return ASTBuilder().dispatch(self.parse(s))