Staging
v0.8.1
https://github.com/python/cpython
Revision f85af612f8c109f52333ee2d106b0848bf6ab372 authored by Guido van Rossum on 14 April 2001, 16:45:14 UTC, committed by Guido van Rossum on 14 April 2001, 16:45:14 UTC
ZipFile.close() method that should be part of the preceding 'if'
block.  On some platforms (Mark noticed this on FreeBSD 4.2) doing a
flush() on a file open for reading is not allowed.
1 parent 3024bb6
Raw File
Tip revision: f85af612f8c109f52333ee2d106b0848bf6ab372 authored by Guido van Rossum on 14 April 2001, 16:45:14 UTC
Mark Favas points out that there's an 'self.fp.flush()' call in the
Tip revision: f85af61
grammar1.c

/* Grammar subroutines needed by parser */

#include "pgenheaders.h"
#include "assert.h"
#include "grammar.h"
#include "token.h"

/* Return the DFA for the given type */

dfa *
PyGrammar_FindDFA(grammar *g, register int type)
{
	register dfa *d;
#if 1
	/* Massive speed-up */
	d = &g->g_dfa[type - NT_OFFSET];
	assert(d->d_type == type);
	return d;
#else
	/* Old, slow version */
	register int i;
	
	for (i = g->g_ndfas, d = g->g_dfa; --i >= 0; d++) {
		if (d->d_type == type)
			return d;
	}
	assert(0);
	/* NOTREACHED */
#endif
}

char *
PyGrammar_LabelRepr(label *lb)
{
	static char buf[100];
	
	if (lb->lb_type == ENDMARKER)
		return "EMPTY";
	else if (ISNONTERMINAL(lb->lb_type)) {
		if (lb->lb_str == NULL) {
			sprintf(buf, "NT%d", lb->lb_type);
			return buf;
		}
		else
			return lb->lb_str;
	}
	else {
		if (lb->lb_str == NULL)
			return _PyParser_TokenNames[lb->lb_type];
		else {
			sprintf(buf, "%.32s(%.32s)",
				_PyParser_TokenNames[lb->lb_type], lb->lb_str);
			return buf;
		}
	}
}
back to top