From dc61c8ee6f34552b04cb5b3a32e6241228323a98 Mon Sep 17 00:00:00 2001 From: Karchnu Date: Thu, 17 Dec 2020 03:19:53 +0100 Subject: [PATCH] Reading classes and inner classes, properties, assignments. --- src/parse.zig | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/parse.zig b/src/parse.zig index f4d6d12..92392dc 100644 --- a/src/parse.zig +++ b/src/parse.zig @@ -253,6 +253,12 @@ const Parser = struct { // TODO: class definition (inheritance). fn parseClass(p: *Parser) !void { + if (p.indent > 0) { + p.say("INNER parseClass\n", .{}); + } + else { + p.say("TOP parseClass\n", .{}); + } p.indent += 1; defer { p.indent -= 1; } @@ -280,11 +286,14 @@ const Parser = struct { // TODO: parsing class content. // TODO: loop over this. const token = p.nextToken(); + p.say("(top class reading) reading token: {}\n", .{p.giveTokenContent(token)}); switch (p.token_ids[token]) { .Identifier => { const following = p.nextToken(); switch (p.token_ids[following]) { + // Class header (with or without id). + .LParen, .LBrace => { p.putBackToken(following); p.putBackToken(token); @@ -306,6 +315,9 @@ const Parser = struct { else => { // Wasn't expected. // Couln't understand what was in this class. + p.say("did not understand {} then {}\n" + , .{ p.giveTokenContent(token) + , p.giveTokenContent(following)}); p.putBackToken(following); p.putBackToken(token); break; @@ -317,6 +329,8 @@ const Parser = struct { p.say("Reading a property\n", .{}); p.putBackToken(token); try p.parseProperty(); + p.say("Done reading a property\n", .{}); + continue; }, .LBrace => { @@ -325,7 +339,7 @@ const Parser = struct { .RBrace => { p.say("Reading a RBrace\n", .{}); - // p.putBackToken(token); + p.putBackToken(token); break; },