Skip to content

Commit 0fb0768

Browse files
committed
Fix bison debug arg. Trace always on. Removes parser dir with debug flag.
1 parent 6aebc05 commit 0fb0768

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/bison/__init__.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919

2020
from __future__ import absolute_import
2121
from __future__ import print_function
22+
23+
import shutil
2224
import sys
2325
import traceback
2426

2527
from bison_ import ParserEngine
26-
from os import makedirs
28+
from os import makedirs, removedirs
2729

2830
from .node import BisonNode
2931
from .convert import bisonToPython
@@ -54,7 +56,7 @@ class BisonParser(object):
5456
# override these if you need to
5557

5658
# Command and options for running yacc/bison, except for filename arg
57-
bisonCmd = ['bison', '-d']
59+
bisonCmd = ['bison', '-d', '--debug']
5860

5961
bisonFile = 'tmp.y'
6062
bisonCFile = 'tmp.tab.c'
@@ -135,7 +137,11 @@ def __init__(self, **kw):
135137
- defaultNodeClass - the class to use for creating parse nodes, default
136138
is self.defaultNodeClass (in this base class, BisonNode)
137139
"""
140+
self.debug = kw.get('debug', 0)
141+
138142
self.buildDirectory = './pybison-' + type(self).__name__ + '/'
143+
if self.debug:
144+
shutil.rmtree(self.buildDirectory)
139145
makedirs(self.buildDirectory, exist_ok=True)
140146

141147
# setup
@@ -162,10 +168,6 @@ def __init__(self, **kw):
162168
if self.verbose:
163169
self.bisonCmd.append('--verbose')
164170

165-
self.debug = kw.get('debug', 0)
166-
if self.debug:
167-
self.bisonCmd.append('--debug')
168-
169171
if 'keepfiles' in kw:
170172
self.keepfiles = kw['keepfiles']
171173

0 commit comments

Comments
 (0)