dae0e4e8df4c8ae0726cc216f3cda1e30235d299
1 # Based on GardenSnake - a parser generator demonstration program
2 # GardenSnake was released into the Public Domain by Andrew Dalke.
4 # Portions of this work are derived from Python's Grammar definition
5 # and may be covered under the Python copyright and license
7 # Andrew Dalke / Dalke Scientific Software, LLC
8 # 30 August 2006 / Cape Town, South Africa
10 # Modifications for inclusion in PLY distribution
11 from pprint
import pprint
12 from ply
import lex
, yacc
15 from soc
.decoder
.power_decoder
import create_pdecode
16 from soc
.decoder
.pseudo
.lexer
import IndentLexer
17 from soc
.decoder
.orderedset
import OrderedSet
19 # I use the Python AST
20 #from compiler import ast
26 def Assign(autoassign
, assignname
, left
, right
, iea_mode
):
28 print("Assign", left
, right
)
29 if isinstance(left
, ast
.Name
):
30 # Single assignment on left
31 # XXX when doing IntClass, which will have an "eq" function,
32 # this is how to access it
33 # eq = ast.Attribute(left, "eq") # get eq fn
34 # return ast.Call(eq, [right], []) # now call left.eq(right)
35 return ast
.Assign([ast
.Name(left
.id, ast
.Store())], right
)
36 elif isinstance(left
, ast
.Tuple
):
37 # List of things - make sure they are Name nodes
39 for child
in left
.getChildren():
40 if not isinstance(child
, ast
.Name
):
41 raise SyntaxError("that assignment not supported")
42 names
.append(child
.name
)
43 ass_list
= [ast
.AssName(name
, 'OP_ASSIGN') for name
in names
]
44 return ast
.Assign([ast
.AssTuple(ass_list
)], right
)
45 elif isinstance(left
, ast
.Subscript
):
46 res
= ast
.Assign([left
], right
)
48 if autoassign
and isinstance(ls
, ast
.Slice
):
49 # hack to create a variable pre-declared based on a slice.
50 # dividend[0:32] = (RA)[0:32] will create
52 # dividend[0:32] = (RA)[0:32]
53 # the declaration makes the slice-assignment "work"
54 lower
, upper
, step
= ls
.lower
, ls
.upper
, ls
.step
55 print ("lower, upper, step", repr(lower
), repr(upper
), step
)
56 if not isinstance(lower
, ast
.Constant
) or \
57 not isinstance(upper
, ast
.Constant
):
59 qty
= ast
.Num(upper
.value
-lower
.value
)
60 keywords
= [ast
.keyword(arg
='repeat', value
=qty
)]
62 right
= ast
.Call(ast
.Name("concat", ast
.Load()), l
, keywords
)
63 declare
= ast
.Assign([ast
.Name(assignname
, ast
.Store())], right
)
66 # XXX HMMM probably not needed...
68 if isinstance(ls
, ast
.Slice
):
69 lower
, upper
, step
= ls
.lower
, ls
.upper
, ls
.step
70 print("slice assign", lower
, upper
, step
)
72 ls
= (lower
, upper
, None)
74 ls
= (lower
, upper
, step
)
76 return ast
.Call(ast
.Name("selectassign", ast
.Load()),
77 [left
.value
, ls
, right
], [])
80 raise SyntaxError("Can't do that yet")
83 # I implemented INDENT / DEDENT generation as a post-processing filter
85 # The original lex token stream contains WS and NEWLINE characters.
86 # WS will only occur before any other tokens on a line.
88 # I have three filters. One tags tokens by adding two attributes.
89 # "must_indent" is True if the token must be indented from the
90 # previous code. The other is "at_line_start" which is True for WS
91 # and the first non-WS/non-NEWLINE on a line. It flags the check so
92 # see if the new line has changed indication level.
95 # No using Python's approach because Ply supports precedence
97 # comparison: expr (comp_op expr)*
98 # arith_expr: term (('+'|'-') term)*
99 # term: factor (('*'|'/'|'%'|'//') factor)*
100 # factor: ('+'|'-'|'~') factor | power
101 # comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
103 def make_le_compare(arg
):
105 return ast
.Call(ast
.Name("le", ast
.Load()), (left
, right
), [])
108 def make_ge_compare(arg
):
110 return ast
.Call(ast
.Name("ge", ast
.Load()), (left
, right
), [])
113 def make_lt_compare(arg
):
115 return ast
.Call(ast
.Name("lt", ast
.Load()), (left
, right
), [])
118 def make_gt_compare(arg
):
120 return ast
.Call(ast
.Name("gt", ast
.Load()), (left
, right
), [])
123 def make_eq_compare(arg
):
125 return ast
.Call(ast
.Name("eq", ast
.Load()), (left
, right
), [])
128 def make_ne_compare(arg
):
130 return ast
.Call(ast
.Name("ne", ast
.Load()), (left
, right
), [])
142 "<=": make_le_compare
,
143 ">=": make_ge_compare
,
144 "<": make_lt_compare
,
145 ">": make_gt_compare
,
146 "=": make_eq_compare
,
147 "!=": make_ne_compare
,
156 def check_concat(node
): # checks if the comparison is already a concat
157 print("check concat", node
)
158 if not isinstance(node
, ast
.Call
):
160 print("func", node
.func
.id)
161 if node
.func
.id != 'concat':
163 if node
.keywords
: # a repeated list-constant, don't optimise
168 # identify SelectableInt pattern [something] * N
169 # must return concat(something, repeat=N)
170 def identify_sint_mul_pattern(p
):
171 if p
[2] != '*': # multiply
173 if not isinstance(p
[3], ast
.Constant
): # rhs = Num
175 if not isinstance(p
[1], ast
.List
): # lhs is a list
178 if len(l
) != 1: # lhs is a list of length 1
180 return True # yippee!
183 def apply_trailer(atom
, trailer
):
184 if trailer
[0] == "TLIST":
185 # assume depth of one
186 atom
= apply_trailer(atom
, trailer
[1])
188 if trailer
[0] == "CALL":
189 #p[0] = ast.Expr(ast.Call(p[1], p[2][1], []))
190 return ast
.Call(atom
, trailer
[1], [])
191 # if p[1].id == 'print':
192 # p[0] = ast.Printnl(ast.Tuple(p[2][1]), None, None)
194 # p[0] = ast.CallFunc(p[1], p[2][1], None, None)
196 print("subscript atom", trailer
[1])
197 #raise AssertionError("not implemented %s" % p[2][0])
202 idx
= ast
.Slice(subs
[0], subs
[1], None)
203 return ast
.Subscript(atom
, idx
, ast
.Load())
205 ########## Parser (tokens -> AST) ######
210 # https://www.mathcs.emory.edu/~valerie/courses/fall10/155/resources/op_precedence.html
211 # python operator precedence
212 # Highest precedence at top, lowest at bottom.
213 # Operators in the same box evaluate left to right.
215 # Operator Description
216 # () Parentheses (grouping)
217 # f(args...) Function call
218 # x[index:index] Slicing
219 # x[index] Subscription
220 # x.attribute Attribute reference
223 # +x, -x Positive, negative
224 # *, /, % mul, div, remainder
225 # +, - Addition, subtraction
226 # <<, >> Bitwise shifts
230 # in, not in, is, is not, <, <=, >, >=, <>, !=, == comp, membership, ident
234 # lambda Lambda expression
240 ("left", "EQ", "NE", "GT", "LT", "LE", "GE", "LTU", "GTU"),
244 ("left", "PLUS", "MINUS"),
245 ("left", "MULT", "DIV", "MOD"),
249 def __init__(self
, form
, include_carry_in_write
=False):
250 self
.include_ca_in_write
= include_carry_in_write
252 form
= self
.sd
.sigforms
[form
]
254 formkeys
= form
._asdict
().keys()
255 self
.declared_vars
= set()
256 for rname
in ['RA', 'RB', 'RC', 'RT', 'RS']:
257 self
.gprs
[rname
] = None
258 self
.declared_vars
.add(rname
)
259 self
.available_op_fields
= set()
261 if k
not in self
.gprs
:
262 if k
== 'SPR': # sigh, lower-case to not conflict
264 self
.available_op_fields
.add(k
)
265 self
.op_fields
= OrderedSet()
266 self
.read_regs
= OrderedSet()
267 self
.uninit_regs
= OrderedSet()
268 self
.write_regs
= OrderedSet()
269 self
.special_regs
= OrderedSet() # see p_atom_name
271 # The grammar comments come from Python's Grammar/Grammar file
273 # NB: compound_stmt in single_input is followed by extra NEWLINE!
274 # file_input: (NEWLINE | stmt)* ENDMARKER
276 def p_file_input_end(self
, p
):
277 """file_input_end : file_input ENDMARKER"""
281 def p_file_input(self
, p
):
282 """file_input : file_input NEWLINE
286 if isinstance(p
[len(p
)-1], str):
290 p
[0] = [] # p == 2 --> only a blank line
297 # funcdef: [decorators] 'def' NAME parameters ':' suite
298 # ignoring decorators
300 def p_funcdef(self
, p
):
301 "funcdef : DEF NAME parameters COLON suite"
302 p
[0] = ast
.FunctionDef(p
[2], p
[3], p
[5], ())
304 # parameters: '(' [varargslist] ')'
305 def p_parameters(self
, p
):
306 """parameters : LPAR RPAR
307 | LPAR varargslist RPAR"""
312 p
[0] = ast
.arguments(args
=args
, vararg
=None, kwarg
=None, defaults
=[])
314 # varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] |
318 def p_varargslist(self
, p
):
319 """varargslist : varargslist COMMA NAME
326 # stmt: simple_stmt | compound_stmt
327 def p_stmt_simple(self
, p
):
328 """stmt : simple_stmt"""
329 # simple_stmt is a list
332 def p_stmt_compound(self
, p
):
333 """stmt : compound_stmt"""
336 # simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
337 def p_simple_stmt(self
, p
):
338 """simple_stmt : small_stmts NEWLINE
339 | small_stmts SEMICOLON NEWLINE"""
342 def p_small_stmts(self
, p
):
343 """small_stmts : small_stmts SEMICOLON small_stmt
347 elif isinstance(p
[1], list):
352 # small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt |
353 # import_stmt | global_stmt | exec_stmt | assert_stmt
354 def p_small_stmt(self
, p
):
355 """small_stmt : flow_stmt
358 if isinstance(p
[1], ast
.Call
):
359 p
[0] = ast
.Expr(p
[1])
360 elif isinstance(p
[1], ast
.Name
) and p
[1].id == 'TRAP':
361 # TRAP needs to actually be a function
362 name
= ast
.Name("self", ast
.Load())
363 name
= ast
.Attribute(name
, "TRAP", ast
.Load())
364 p
[0] = ast
.Call(name
, [], [])
368 # expr_stmt: testlist (augassign (yield_expr|testlist) |
369 # ('=' (yield_expr|testlist))*)
370 # augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' |
371 # '<<=' | '>>=' | '**=' | '//=')
372 def p_expr_stmt(self
, p
):
373 """expr_stmt : testlist ASSIGNEA testlist
374 | testlist ASSIGN testlist
376 print("expr_stmt", p
)
378 # a list of expressions
379 #p[0] = ast.Discard(p[1])
382 iea_mode
= p
[2] == '<-iea'
385 if isinstance(p
[1], ast
.Name
):
387 elif isinstance(p
[1], ast
.Subscript
):
388 if isinstance(p
[1].value
, ast
.Name
):
390 if name
in self
.gprs
:
391 # add to list of uninitialised
392 self
.uninit_regs
.add(name
)
393 autoassign
= name
not in self
.declared_vars
394 elif isinstance(p
[1], ast
.Call
) and p
[1].func
.id in ['GPR', 'SPR']:
395 print(astor
.dump_tree(p
[1]))
396 # replace GPR(x) with GPR[x]
398 p
[1] = ast
.Subscript(p
[1].func
, idx
, ast
.Load())
399 elif isinstance(p
[1], ast
.Call
) and p
[1].func
.id == 'MEM':
401 print(astor
.dump_tree(p
[1]))
402 p
[1].func
.id = "memassign" # change function name to set
403 p
[1].args
.append(p
[3])
406 print(astor
.dump_tree(p
[0]))
410 print(astor
.dump_tree(p
[1]))
411 print("expr assign", name
, p
[1])
412 if name
and name
in self
.gprs
:
413 self
.write_regs
.add(name
) # add to list of regs to write
414 p
[0] = Assign(autoassign
, name
, p
[1], p
[3], iea_mode
)
416 self
.declared_vars
.add(name
)
418 def p_flow_stmt(self
, p
):
419 "flow_stmt : return_stmt"
422 # return_stmt: 'return' [testlist]
423 def p_return_stmt(self
, p
):
424 "return_stmt : RETURN testlist"
425 p
[0] = ast
.Return(p
[2])
427 def p_compound_stmt(self
, p
):
428 """compound_stmt : if_stmt
436 def p_break_stmt(self
, p
):
437 """break_stmt : BREAK
441 def p_for_stmt(self
, p
):
442 """for_stmt : FOR atom EQ test TO test COLON suite
443 | DO atom EQ test TO test COLON suite
445 # auto-add-one (sigh) due to python range
447 end
= ast
.BinOp(p
[6], ast
.Add(), ast
.Constant(1))
448 it
= ast
.Call(ast
.Name("range", ast
.Load()), [start
, end
], [])
449 p
[0] = ast
.For(p
[2], it
, p
[8], [])
451 def p_while_stmt(self
, p
):
452 """while_stmt : DO WHILE test COLON suite ELSE COLON suite
453 | DO WHILE test COLON suite
456 p
[0] = ast
.While(p
[3], p
[5], [])
458 p
[0] = ast
.While(p
[3], p
[5], p
[8])
460 def p_switch_smt(self
, p
):
461 """switch_stmt : SWITCH LPAR atom RPAR COLON NEWLINE INDENT switches DEDENT
465 print(astor
.dump_tree(p
[1]))
468 current_cases
= [] # for deferral
469 for (case
, suite
) in p
[8]:
470 print("for", case
, suite
)
473 current_cases
.append(ast
.Num(c
))
475 if case
== 'default': # last
478 current_cases
.append(ast
.Num(c
))
479 print("cases", current_cases
)
480 compare
= ast
.Compare(switchon
, [ast
.In()],
481 [ast
.List(current_cases
, ast
.Load())])
483 cases
.append((compare
, suite
))
485 print("ended", case
, current_cases
)
486 if case
== 'default':
488 compare
= ast
.Compare(switchon
, [ast
.In()],
489 [ast
.List(current_cases
, ast
.Load())])
490 cases
.append((compare
, suite
))
491 cases
.append((None, suite
))
495 for compare
, suite
in cases
:
496 print("after rev", compare
, suite
)
498 assert len(res
) == 0, "last case should be default"
501 if not isinstance(res
, list):
503 res
= ast
.If(compare
, suite
, res
)
506 def p_switches(self
, p
):
507 """switches : switch_list switch_default
515 def p_switch_list(self
, p
):
516 """switch_list : switch_case switch_list
524 def p_switch_case(self
, p
):
525 """switch_case : CASE LPAR atomlist RPAR COLON suite
528 if isinstance(p
[6][0], ast
.Name
) and p
[6][0].id == 'fallthrough':
532 def p_switch_default(self
, p
):
533 """switch_default : DEFAULT COLON suite
535 p
[0] = ('default', p
[3])
537 def p_atomlist(self
, p
):
538 """atomlist : atom COMMA atomlist
541 assert isinstance(p
[1], ast
.Constant
), "case must be numbers"
543 p
[0] = [p
[1].value
] + p
[3]
547 def p_if_stmt(self
, p
):
548 """if_stmt : IF test COLON suite ELSE COLON if_stmt
549 | IF test COLON suite ELSE COLON suite
550 | IF test COLON suite
552 if len(p
) == 8 and isinstance(p
[7], ast
.If
):
553 p
[0] = ast
.If(p
[2], p
[4], [p
[7]])
555 p
[0] = ast
.If(p
[2], p
[4], [])
557 p
[0] = ast
.If(p
[2], p
[4], p
[7])
559 def p_suite(self
, p
):
560 """suite : simple_stmt
561 | NEWLINE INDENT stmts DEDENT"""
567 def p_stmts(self
, p
):
568 """stmts : stmts stmt
575 def p_comparison(self
, p
):
576 """comparison : comparison PLUS comparison
577 | comparison MINUS comparison
578 | comparison MULT comparison
579 | comparison DIV comparison
580 | comparison MOD comparison
581 | comparison EQ comparison
582 | comparison NE comparison
583 | comparison LE comparison
584 | comparison GE comparison
585 | comparison LTU comparison
586 | comparison GTU comparison
587 | comparison LT comparison
588 | comparison GT comparison
589 | comparison BITOR comparison
590 | comparison BITXOR comparison
591 | comparison BITAND comparison
595 | comparison APPEND comparison
600 p
[0] = ast
.Call(ast
.Name("ltu", ast
.Load()), (p
[1], p
[3]), [])
602 p
[0] = ast
.Call(ast
.Name("gtu", ast
.Load()), (p
[1], p
[3]), [])
604 l
= check_concat(p
[1]) + check_concat(p
[3])
605 p
[0] = ast
.Call(ast
.Name("concat", ast
.Load()), l
, [])
606 elif p
[2] in ['/', '%']:
607 # bad hack: if % or / used anywhere other than div/mod ops,
608 # do % or /. however if the argument names are "dividend"
609 # we must call the special trunc_div and trunc_rem functions
611 # actual call will be "dividend / divisor" - just check
613 if isinstance(l
, ast
.Name
) and l
.id == 'dividend':
618 # return "function trunc_xxx(l, r)"
619 p
[0] = ast
.Call(ast
.Name(fn
, ast
.Load()), (l
, r
), [])
621 # return "l {binop} r"
622 p
[0] = ast
.BinOp(p
[1], binary_ops
[p
[2]], p
[3])
623 elif p
[2] in ['<', '>', '=', '<=', '>=', '!=']:
624 p
[0] = binary_ops
[p
[2]]((p
[1], p
[3]))
625 elif identify_sint_mul_pattern(p
):
626 keywords
= [ast
.keyword(arg
='repeat', value
=p
[3])]
628 p
[0] = ast
.Call(ast
.Name("concat", ast
.Load()), l
, keywords
)
630 p
[0] = ast
.BinOp(p
[1], binary_ops
[p
[2]], p
[3])
632 if isinstance(p
[2], str) and p
[2] == '-':
633 p
[0] = ast
.UnaryOp(unary_ops
[p
[2]], p
[1])
635 p
[0] = ast
.UnaryOp(unary_ops
[p
[1]], p
[2])
639 # power: atom trailer* ['**' factor]
640 # trailers enables function calls (and subscripts).
641 # so this is 'trailerlist'
642 def p_power(self
, p
):
644 | atom trailerlist"""
648 print("power dump atom")
649 print(astor
.dump_tree(p
[1]))
650 print("power dump trailerlist")
651 print(astor
.dump_tree(p
[2]))
652 p
[0] = apply_trailer(p
[1], p
[2])
654 def p_atom_name(self
, p
):
657 if name
in self
.available_op_fields
:
658 self
.op_fields
.add(name
)
659 if self
.include_ca_in_write
:
660 if name
in ['CA', 'CA32']:
661 self
.write_regs
.add(name
)
662 if name
in ['CR', 'LR', 'CTR', 'TAR', 'FPSCR', 'MSR']:
663 self
.special_regs
.add(name
)
664 self
.write_regs
.add(name
) # and add to list to write
665 p
[0] = ast
.Name(id=name
, ctx
=ast
.Load())
667 def p_atom_number(self
, p
):
672 p
[0] = ast
.Constant(p
[1])
674 # '[' [listmaker] ']' |
676 def p_atom_listmaker(self
, p
):
677 """atom : LBRACK listmaker RBRACK"""
680 def p_listmaker(self
, p
):
681 """listmaker : test COMMA listmaker
685 p
[0] = ast
.List([p
[1]], ast
.Load())
687 p
[0] = ast
.List([p
[1]] + p
[3].nodes
, ast
.Load())
689 def p_atom_tuple(self
, p
):
690 """atom : LPAR testlist RPAR"""
693 print(astor
.dump_tree(p
[2]))
695 if isinstance(p
[2], ast
.Name
):
697 print("tuple name", name
)
698 if name
in self
.gprs
:
699 self
.read_regs
.add(name
) # add to list of regs to read
700 #p[0] = ast.Subscript(ast.Name("GPR", ast.Load()), ast.Str(p[2].id))
703 elif isinstance(p
[2], ast
.BinOp
):
704 if isinstance(p
[2].left
, ast
.Name
) and \
705 isinstance(p
[2].right
, ast
.Constant
) and \
706 p
[2].right
.value
== 0 and \
707 p
[2].left
.id in self
.gprs
:
709 self
.read_regs
.add(rid
) # add to list of regs to read
710 # create special call to GPR.getz
711 gprz
= ast
.Name("GPR", ast
.Load())
712 # get testzero function
713 gprz
= ast
.Attribute(gprz
, "getz", ast
.Load())
714 # *sigh* see class GPR. we need index itself not reg value
715 ridx
= ast
.Name("_%s" % rid
, ast
.Load())
716 p
[0] = ast
.Call(gprz
, [ridx
], [])
717 print("tree", astor
.dump_tree(p
[0]))
723 def p_trailerlist(self
, p
):
724 """trailerlist : trailer trailerlist
730 p
[0] = ("TLIST", p
[1], p
[2])
732 # trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
733 def p_trailer(self
, p
):
734 """trailer : trailer_arglist
739 def p_trailer_arglist(self
, p
):
740 "trailer_arglist : LPAR arglist RPAR"
741 p
[0] = ("CALL", p
[2])
743 def p_trailer_subscript(self
, p
):
744 "trailer_subscript : LBRACK subscript RBRACK"
745 p
[0] = ("SUBS", p
[2])
747 # subscript: '.' '.' '.' | test | [test] ':' [test]
749 def p_subscript(self
, p
):
750 """subscript : test COLON test
755 if isinstance(p
[3], ast
.Constant
):
756 end
= ast
.Constant(p
[3].value
+1)
758 end
= ast
.BinOp(p
[3], ast
.Add(), ast
.Constant(1))
763 # testlist: test (',' test)* [',']
764 # Contains shift/reduce error
766 def p_testlist(self
, p
):
767 """testlist : testlist_multi COMMA
772 # May need to promote singleton to tuple
773 if isinstance(p
[1], list):
777 # Convert into a tuple?
778 if isinstance(p
[0], list):
779 p
[0] = ast
.Tuple(p
[0])
781 def p_testlist_multi(self
, p
):
782 """testlist_multi : testlist_multi COMMA test
788 if isinstance(p
[1], list):
794 # test: or_test ['if' or_test 'else' test] | lambdef
795 # as I don't support 'and', 'or', and 'not' this works down to 'comparison'
801 # arglist: (argument ',')* (argument [',']| '*' test [',' '**' test]
803 # XXX INCOMPLETE: this doesn't allow the trailing comma
805 def p_arglist(self
, p
):
806 """arglist : arglist COMMA argument
813 # argument: test [gen_for] | test '=' test # Really [keyword '='] test
814 def p_argument(self
, p
):
818 def p_error(self
, p
):
819 # print "Error!", repr(p)
823 class GardenSnakeParser(PowerParser
):
824 def __init__(self
, lexer
=None, debug
=False, form
=None, incl_carry
=False):
825 self
.sd
= create_pdecode()
826 PowerParser
.__init
__(self
, form
, incl_carry
)
829 lexer
= IndentLexer(debug
=0)
831 self
.tokens
= lexer
.tokens
832 self
.parser
= yacc
.yacc(module
=self
, start
="file_input_end",
833 debug
=debug
, write_tables
=False)
835 def parse(self
, code
):
836 # self.lexer.input(code)
837 result
= self
.parser
.parse(code
, lexer
=self
.lexer
, debug
=self
.debug
)
838 return ast
.Module(result
)
841 ###### Code generation ######
843 #from compiler import misc, syntax, pycodegen
845 class GardenSnakeCompiler(object):
846 def __init__(self
, debug
=False, form
=None, incl_carry
=False):
847 self
.parser
= GardenSnakeParser(debug
=debug
, form
=form
,
848 incl_carry
=incl_carry
)
850 def compile(self
, code
, mode
="exec", filename
="<string>"):
851 tree
= self
.parser
.parse(code
)
855 #misc.set_filename(filename, tree)
856 return compile(tree
, mode
="exec", filename
="<string>")
858 gen
= pycodegen
.ModuleCodeGenerator(tree
)