Compare commits
No commits in common. "02c2055601508b7e53cad635dfa9f5f5ae354d54" and "830693d16d87054bfdf56d993209bc2a637af007" have entirely different histories.
02c2055601
...
830693d16d
2 changed files with 8 additions and 19 deletions
|
@ -1,13 +1,12 @@
|
|||
const (
|
||||
Cock = 1
|
||||
Ball = 2 + 3
|
||||
Deals = 3
|
||||
Businesses = 4
|
||||
)
|
||||
//const (
|
||||
// Cock = 1
|
||||
// Ball = 2
|
||||
// Deals = 3
|
||||
// Businesses = 4
|
||||
//)
|
||||
|
||||
fn main(a int) int {
|
||||
1 + 2 + 3 + 4
|
||||
1 + 1 * 1
|
||||
3 / (51 + 2)
|
||||
println(2 * 1956)
|
||||
}
|
||||
|
|
|
@ -91,12 +91,10 @@ pub const Parser = struct {
|
|||
}
|
||||
|
||||
fn consumeSingle(self: *Parser, ttype: TokenType) !Token {
|
||||
std.debug.warn("consume {}..?", ttype);
|
||||
|
||||
if (self.check(ttype)) {
|
||||
var cur = self.peek();
|
||||
_ = try self.nextToken();
|
||||
std.debug.warn(" now has {}\n", self.peek());
|
||||
std.debug.warn("consumed {}, now has {}\n", ttype, self.peek());
|
||||
return cur;
|
||||
}
|
||||
|
||||
|
@ -381,7 +379,6 @@ pub const Parser = struct {
|
|||
_ = try self.consumeSingle(.LeftBrace);
|
||||
|
||||
while (self.peek().ttype != .RightBrace) {
|
||||
std.debug.warn("get smt with cur {}\n", self.peek().ttype);
|
||||
var node = try self.parseStmt();
|
||||
ast.printNode(node, 0);
|
||||
try stmts.append(node.Stmt);
|
||||
|
@ -405,11 +402,7 @@ pub const Parser = struct {
|
|||
|
||||
fn parsePrintln(self: *@This()) !*Stmt {
|
||||
_ = try self.consumeSingle(.Println);
|
||||
|
||||
_ = try self.consumeSingle(.LeftParen);
|
||||
var expr = try self.parseExpr();
|
||||
_ = try self.consumeSingle(.RightParen);
|
||||
|
||||
return try Stmt.mkPrintln(self.allocator, expr.Expr);
|
||||
}
|
||||
|
||||
|
@ -516,10 +509,7 @@ pub const Parser = struct {
|
|||
_ = try self.nextToken();
|
||||
var expr = (try self.parseExpr()).Expr;
|
||||
_ = try self.consume(.RightParen, "Expected ')' after expression");
|
||||
|
||||
// for groupings, we don't want to skip tokens as we already
|
||||
// consumed RightParen.
|
||||
return try self.mkGrouping(expr);
|
||||
break :blk try self.mkGrouping(expr);
|
||||
},
|
||||
|
||||
else => blk: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue