jack-compiler/parser/parser-util.h

22 lines
728 B
C
Raw Normal View History

2020-12-22 11:18:54 -05:00
#ifndef PARSER_INTERNAL_H
#define PARSER_INTERNAL_H
#include <string.h>
#include "parser.h"
2020-12-31 18:24:27 -05:00
/* parser-util
* Random utilities used in the parser module. */
2020-12-22 11:18:54 -05:00
#define next(parser) parser->current = p->current->next
2020-12-22 12:38:10 -05:00
#define anchorparser(parser) p->checkpoint = p->current
#define rewindparser(parser) p->current = p->checkpoint
2020-12-22 11:18:54 -05:00
#define differs(parser, str) strcmp(parser->current->token, str)
#define nextdiffers(parser, str) strcmp(parser->current->next->token, str)
#define equals(parser, str) !differs(parser, str)
#define nextequals(parser, str) !nextdiffers(parser, str)
void unexpected(PARSER* p);
char* parseidentifier(PARSER* p);
void checkcontent(PARSER* p, const char* content);
DEBUGINFO* getdebug(PARSER* p);
#endif