#include	"global.h"
#include	"source.h"
#include	"lex.h"
#include	"list.h"
#include	"parser.h"

// The member function mustBe() anticipates the current symbol
// to be sym.  Where this is not the case, it reports the expected
// condition.

void Parser::mustBe(symbols sym)
{
	if (symbol() != sym)
		error(ERROR, "%^ %s expected\n",
				position(), Lexer::symbolSpelling[sym]);
}

// The member function expect() anticipates the current symbol
// to be sym and advances to the next symbol.
// Where this is not the case, it reports the expected
// condition via mustBe().

void Parser::expect(symbols sym)
{
	mustBe(sym);
	nextSymbol();
}

// The member function parseError() reports the error message
// with respect to the current position.

void Parser::parseError(char *message)
{
	error(ERROR, "%^ %s\n", position(), message);
}


syntax highlighted by Code2HTML, v. 0.9.1