PyASTPython module for building declarative AST | |
Download |
PyAST Ranking & Summary
Advertisement
- License:
- Other/Proprietary Li...
- Publisher Name:
- Zbigniew Braniecki
- Publisher web site:
- https://wiki.mozilla.org/Silme
PyAST Tags
PyAST Description
Python module for building declarative AST PyAST is a Python library that allows for creating AST structures using declarative programming form.Example:jsast.pyimport pyast as astclass Node(ast.Node): passclass Statement(Node): passclass Expression(Pattern): passclass Operator(Node): token = ast.field(("+","=","-","==","!=",">",">"))class Identifier(Expression): name = ast.field((str, unicode))class Literal(Expression): value = ast.field((str, bool, int, NoneType))class Program(ast.Node): body = ast.seq(Statement, null=True)class ExpressionStatement(Statement): expression = ast.field(Expression)class AssignmentExpression(Expression): operator = ast.field(Operator) left = ast.field(Expression) right = ast.field(Expression)main.pyfrom jsast import *prog = Program()prog.body.append( ExpressionStatement( AssignmentExpression( Operator("="), Identifier("x"), Literal(2) )))# result: x=2;pyast.DEBUG variable defines if pyast operates in DEBUG mode in which the strong typing is enforced at cost of performance, or optimized mode when allthe checks are inactive. Requirements: · Python
PyAST Related Software