/* Require - check for a required token */ void Require(ParseContext *c, Token token, Token requiredToken) { char tknbuf[MAXTOKEN]; if (token != requiredToken) { strcpy(tknbuf, TokenName(requiredToken)); ParseError(c, "Expecting '%s', found '%s'", tknbuf, TokenName(token)); } }
void FScanner::TokenMustBe (int token) { if (TokenType != token) { FString tok1 = TokenName(token); FString tok2 = TokenName(TokenType, String); ScriptError ("Expected %s but got %s instead.", tok1.GetChars(), tok2.GetChars()); } }
/* Try and continue by looking for the start of the next statement */ static void syntax_error(TokenType type) { fprintf(stderr, "Error in config file line %lu: Expected %s\n", scan_input->line_number, TokenName(type)); do { next_token(); if (ct.type == TOK_EOF || ct.type == TOK_NAME) return; } while (1); }
void Recog( unsigned token ) { char *start; unsigned len; if( token != CurrToken ) { TokenName( token, &start, &len ); Error( ERR_LOC, LIT( ERR_WANT_TOKEN ), start, len ); } Scan(); }