We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8c956ce commit 8057112Copy full SHA for 8057112
parser.c
@@ -45,9 +45,18 @@ static void consume(TokenType type, const char* message) {
45
error_at(&parser.current, message);
46
}
47
48
+static bool match(TokenType type) {
49
+ if (parser.current.type == type) {
50
+ advance();
51
+ return true;
52
+ }
53
+ return false;
54
+}
55
+
56
static Expr* expression();
57
static Stmt* statement();
58
static Stmt* declaration();
59
+static Expr* unary();
60
61
static Expr* binary() {
62
Expr* expr = unary();
@@ -93,5 +102,9 @@ void init_parser() {
93
102
Stmt* parse() {
94
103
init_parser();
95
104
advance();
96
- return declaration();
105
+ Stmt* stmt = NULL;
106
+ while (!match(TOKEN_EOF)) {
107
+ stmt = declaration();
108
109
+ return stmt;
97
110
0 commit comments