Ejemplo n.º 1
0
def parsespec(fname, outfname, debug=0):
    pylly_lextab.lineno = 1
    pylly_lextab.tabstop = 8
    pylly_lextab.codedata = ""
    pylly_lextab.curindent = [0]

    l = lexer.lexer(lexspec)
    l.setinput(fname)
    g = srgram.SRGram(gt.gramspec)
    p = glr.GLR(g)
    p.setlexer(l)

    from . import nfa
    gt.n = nfa.nfa()
    gt.globcode = ""
    gt.namedmachines = dict()
    gt.statenums = dict()
    gt.eofacts = []
    gt.statemachs = []
    gt.actions = [None]
    gt.relist = [None]

    try:
        tree = p.parse()
        if debug >= 10:
            glr.dottree(tree)
        helpers.proctree(tree, gt)
    except ParseError, e:
        raise SpecError("%s:%d: parse error at %r" %
                        (fname, pylly_lextab.lineno, e.str))
Ejemplo n.º 2
0
def parsespec(fname, outfname, debug = 0) :
	pylly_lextab.lineno = 1
	pylly_lextab.tabstop = 8
	pylly_lextab.codedata = ""
	pylly_lextab.curindent = [0]

	l = lexer.lexer(lexspec)
	l.setinput(fname)
	g = srgram.SRGram(gt.gramspec)
	p = glr.GLR(g)
	p.setlexer(l)

	from . import nfa
	gt.n = nfa.nfa()
	gt.globcode = ""
	gt.namedmachines = dict()
	gt.statenums = dict()
	gt.eofacts = []
	gt.statemachs = []
	gt.actions = [None]
	gt.relist = [None]

	try :
		tree = p.parse()
		if debug >= 10 :
			glr.dottree(tree)
		helpers.proctree(tree, gt)
	except ParseError,e :
		raise SpecError("%s:%d: parse error at %r" % (fname, pylly_lextab.lineno, e.str))
Ejemplo n.º 3
0
def parsespec(fname, outfname, debug = 0) :
	"""
	Parse the spec file, generate parsing tables and write it out.

	Debug levels less than 10 are for showing data about the parsed spec file
	levels 10 and higher are for showing internal data.
	"""
	l = lexer.lexer(pyggy_lextab.lexspec)
	l.setinput(fname)
	g = srgram.SRGram(gt.gramspec)
	p = glr.GLR(g)
	p.setlexer(l)

	try :
		tree = p.parse()
		# print the parse tree of the spec file
		if debug >= 11 :
			printcover = (debug >= 12)
			glr.dottree(tree, printcover)
		helpers.proctree(tree, gt)
	except ParseError,e :
		raise SpecError("%s:%d: parse error at %r" % (fname, pyggy_lextab.lineno, e.str))
Ejemplo n.º 4
0
def parsespec(fname, outfname, debug=0):
    """
	Parse the spec file, generate parsing tables and write it out.

	Debug levels less than 10 are for showing data about the parsed spec file
	levels 10 and higher are for showing internal data.
	"""
    l = lexer.lexer(pyggy_lextab.lexspec)
    l.setinput(fname)
    g = srgram.SRGram(gt.gramspec)
    p = glr.GLR(g)
    p.setlexer(l)

    try:
        tree = p.parse()
        # print the parse tree of the spec file
        if debug >= 11:
            printcover = (debug >= 12)
            glr.dottree(tree, printcover)
        helpers.proctree(tree, gt)
    except ParseError, e:
        raise SpecError("%s:%d: parse error at %r" %
                        (fname, pyggy_lextab.lineno, e.str))