diff options
author | Walter Bender <walter@sugarlabs.org> | 2013-11-08 13:36:05 (GMT) |
---|---|---|
committer | Walter Bender <walter@sugarlabs.org> | 2013-11-08 13:36:05 (GMT) |
commit | 34d13acd6453f0bfea8ac0c55eec4b737bddea5c (patch) | |
tree | be70abb167ff8ae798cdedb3d23f8b33645a0bf1 /util/ast_extensions.py | |
parent | 5c0fb4a31b17e085a90649fca47a37c53b8c7c83 (diff) |
refactor handling of extra code in python export
Diffstat (limited to 'util/ast_extensions.py')
-rw-r--r-- | util/ast_extensions.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/util/ast_extensions.py b/util/ast_extensions.py index 3335afb..d46bdb0 100644 --- a/util/ast_extensions.py +++ b/util/ast_extensions.py @@ -24,6 +24,23 @@ import ast +class ExtraCode(ast.stmt): + """Adds extra content to a primitive needed in Python code, e.g., + changes to the turtle (e.g., prim_turtle) require the addition of + turtle = turtles.get_active_turtle() + Extends the Python abstract grammar by the following: stmt + = ExtraContent(string text) | ... """ + + _fields = ('text') + + def __init__(self, text="", lineno=1, col_offset=0): + """ text -- the textual content of the comment, i.e. everything + directly following the hashtag until the next newline """ + self.text = text + self.lineno = lineno + self.col_offset = col_offset + + class Comment(ast.stmt): """ An inline comment, starting with a hashtag (#). Extends the Python abstract grammar by the following: |