Reading classes and inner classes, properties, assignments.

mess
Karchnu 2020-12-17 03:19:53 +01:00
parent 69122b1e7b
commit dc61c8ee6f
1 changed files with 15 additions and 1 deletions

View File

@ -253,6 +253,12 @@ const Parser = struct {
// TODO: class definition (inheritance). // TODO: class definition (inheritance).
fn parseClass(p: *Parser) !void { fn parseClass(p: *Parser) !void {
if (p.indent > 0) {
p.say("INNER parseClass\n", .{});
}
else {
p.say("TOP parseClass\n", .{});
}
p.indent += 1; p.indent += 1;
defer { p.indent -= 1; } defer { p.indent -= 1; }
@ -280,11 +286,14 @@ const Parser = struct {
// TODO: parsing class content. // TODO: parsing class content.
// TODO: loop over this. // TODO: loop over this.
const token = p.nextToken(); const token = p.nextToken();
p.say("(top class reading) reading token: {}\n", .{p.giveTokenContent(token)});
switch (p.token_ids[token]) { switch (p.token_ids[token]) {
.Identifier => { .Identifier => {
const following = p.nextToken(); const following = p.nextToken();
switch (p.token_ids[following]) { switch (p.token_ids[following]) {
// Class header (with or without id).
.LParen,
.LBrace => { .LBrace => {
p.putBackToken(following); p.putBackToken(following);
p.putBackToken(token); p.putBackToken(token);
@ -306,6 +315,9 @@ const Parser = struct {
else => { else => {
// Wasn't expected. // Wasn't expected.
// Couln't understand what was in this class. // 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(following);
p.putBackToken(token); p.putBackToken(token);
break; break;
@ -317,6 +329,8 @@ const Parser = struct {
p.say("Reading a property\n", .{}); p.say("Reading a property\n", .{});
p.putBackToken(token); p.putBackToken(token);
try p.parseProperty(); try p.parseProperty();
p.say("Done reading a property\n", .{});
continue;
}, },
.LBrace => { .LBrace => {
@ -325,7 +339,7 @@ const Parser = struct {
.RBrace => { .RBrace => {
p.say("Reading a RBrace\n", .{}); p.say("Reading a RBrace\n", .{});
// p.putBackToken(token); p.putBackToken(token);
break; break;
}, },