예제 #1
0
파일: test_ast.py 프로젝트: kephale/hy
    def _compile_string(s):
        hy_s = HyString(s)

        code = hy_compile([hy_s], __name__, filename='<string>', source=s)
        # We put hy_s in a list so it isn't interpreted as a docstring.

        # code == ast.Module(body=[ast.Expr(value=ast.List(elts=[ast.Str(s=xxx)]))])
        return code.body[0].value.elts[0].s
예제 #2
0
파일: test_ast.py 프로젝트: oskarkv/hy
    def _compile_string(s):
        hy_s = HyString(s)

        code = hy_compile([hy_s], "__main__")
        # We put hy_s in a list so it isn't interpreted as a docstring.

        # code == ast.Module(body=[ast.Expr(value=ast.List(elts=[ast.Str(s=xxx)]))])
        return code.body[0].value.elts[0].s
예제 #3
0
파일: test_ast.py 프로젝트: zenhack/hy
    def _compile_string(s):
        hy_s = HyString(s)
        hy_s.start_line = hy_s.end_line = 0
        hy_s.start_column = hy_s.end_column = 0

        code = hy_compile([hy_s], "__main__")

        # code == ast.Module(body=[ast.Expr(value=ast.Str(s=xxx))])
        return code.body[0].value.s
from hy import HyExpression, HyInteger, HyKeyword, HyString, HySymbol
positionX = 1
positionY = 2
positionZ = 3
HyExpression([])
HyExpression([] + [HyInteger(1)] + [HyInteger(2)] + [HyInteger(3)] +
             [HyInteger(4)])
HyExpression([] + [HyString('prvni')] + [HyString('druhy')] +
             [HyString('treti')])
HyExpression([] + [HyKeyword('\ufdd0:prvni')] + [HyKeyword('\ufdd0:druhy')] +
             [HyKeyword('\ufdd0:treti')])
HyExpression([] + [HySymbol('positionX')] + [HySymbol('positionY')] +
             [HySymbol('positionZ')])
HyExpression([] + [
    HyExpression(
        [] + [HySymbol('quote')] +
        [HyExpression([] + [HyKeyword('\ufdd0:x')] + [HyKeyword('\ufdd0:y')])])
] + [
    HyExpression(
        [] + [HySymbol('quote')] +
        [HyExpression([] + [HyKeyword('\ufdd0:z')] + [HyKeyword('\ufdd0:w')])])
])
[]
[1, 2, 3, 4]
['prvni', 'druhy', 'treti']
['\ufdd0:prvni', '\ufdd0:druhy', '\ufdd0:treti']
[positionX, positionY, positionZ]
()
1, 2, 3, 4
'prvni', 'druhy', 'treti'
'\ufdd0:prvni', '\ufdd0:druhy', '\ufdd0:treti'