should have working version

This commit is contained in:
Anthony Scopatz 2015-03-07 13:24:44 -06:00
parent fe4bed77c5
commit 2e1096e716
2 changed files with 23 additions and 2 deletions

View file

@ -1,7 +1,6 @@
"""The xonsh installer."""
import os
import sys
import os, sys
try:
from setuptools import setup
HAVE_SETUPTOOLS = True
@ -11,7 +10,25 @@ except ImportError:
VERSION = '0.1'
TABLES = ['xonsh/lexer_table.py', 'xonsh/parser_table.py']
def clean_tables():
for f in TABLES:
if os.path.isfile(f):
os.remove(f)
print('Remove ' + f)
def build_tables():
print('Building lexer and parser tables.')
sys.path.insert(0, os.path.dirname(__file__))
from xonsh.parser import Parser
Parser(lexer_table='lexer_table', yacc_table='parser_table',
outputdir='xonsh')
sys.path.pop(0)
def main():
clean_tables()
build_tables()
with open('readme.rst', 'r') as f:
readme = f.read()
skw = dict(

View file

@ -105,7 +105,7 @@ class Parser(object):
def __init__(self, lexer_optimize=True, lexer_table='xonsh.lexer_table',
yacc_optimize=True, yacc_table='xonsh.parser_table',
yacc_debug=False):
yacc_debug=False, outputdir=None):
"""Parameters
----------
lexer_optimize : bool, optional
@ -118,6 +118,8 @@ class Parser(object):
Parser module used when optimized.
yacc_debug : debug, optional
Dumps extra debug info.
outputdir : str or None, optional
The directory to place generated tables within.
"""
self.lexer = lexer = Lexer(errfunc=self._lexer_errfunc)
lexer.build(optimize=lexer_optimize, lextab=lexer_table)
@ -212,6 +214,8 @@ class Parser(object):
tabmodule=yacc_table)
if not yacc_debug:
yacc_kwargs['errorlog'] = yacc.NullLogger()
if outputdir is not None:
yacc_kwargs['outputdir'] = outputdir
self.parser = yacc.yacc(**yacc_kwargs)
# Keeps track of the last token given to yacc (the lookahead token)