19
19
20
20
from __future__ import absolute_import
21
21
from __future__ import print_function
22
+
23
+ import shutil
22
24
import sys
23
25
import traceback
24
26
25
27
from bison_ import ParserEngine
26
- from os import makedirs
28
+ from os import makedirs , removedirs
27
29
28
30
from .node import BisonNode
29
31
from .convert import bisonToPython
@@ -54,7 +56,7 @@ class BisonParser(object):
54
56
# override these if you need to
55
57
56
58
# Command and options for running yacc/bison, except for filename arg
57
- bisonCmd = ['bison' , '-d' ]
59
+ bisonCmd = ['bison' , '-d' , '--debug' ]
58
60
59
61
bisonFile = 'tmp.y'
60
62
bisonCFile = 'tmp.tab.c'
@@ -135,7 +137,11 @@ def __init__(self, **kw):
135
137
- defaultNodeClass - the class to use for creating parse nodes, default
136
138
is self.defaultNodeClass (in this base class, BisonNode)
137
139
"""
140
+ self .debug = kw .get ('debug' , 0 )
141
+
138
142
self .buildDirectory = './pybison-' + type (self ).__name__ + '/'
143
+ if self .debug :
144
+ shutil .rmtree (self .buildDirectory )
139
145
makedirs (self .buildDirectory , exist_ok = True )
140
146
141
147
# setup
@@ -162,10 +168,6 @@ def __init__(self, **kw):
162
168
if self .verbose :
163
169
self .bisonCmd .append ('--verbose' )
164
170
165
- self .debug = kw .get ('debug' , 0 )
166
- if self .debug :
167
- self .bisonCmd .append ('--debug' )
168
-
169
171
if 'keepfiles' in kw :
170
172
self .keepfiles = kw ['keepfiles' ]
171
173
0 commit comments