Add It param to ParseResult

This commit is contained in:
jaina heartles 2022-11-18 02:02:24 -08:00
parent 52bb8739f8
commit 1340862c28

View file

@ -123,7 +123,7 @@ const TemplateType = enum {
if_block,
};
fn parseTemplate(comptime tokens: TokenIter, comptime template_type: TemplateType) ParseResult([]const TemplateItem) {
fn parseTemplate(comptime tokens: TokenIter, comptime template_type: TemplateType) ParseResult(TokenIter, []const TemplateItem) {
comptime {
var iter = tokens;
var items: []const TemplateItem = &.{};
@ -177,7 +177,7 @@ fn parseTemplate(comptime tokens: TokenIter, comptime template_type: TemplateTyp
}
}
fn parseExpression(comptime tokens: TokenIter) ParseResult(Expression) {
fn parseExpression(comptime tokens: TokenIter) ParseResult(TokenIter, Expression) {
comptime {
var iter = tokens;
@ -203,7 +203,7 @@ fn parseExpression(comptime tokens: TokenIter) ParseResult(Expression) {
}
}
fn parseControlBlock(comptime tokens: TokenIter) ParseResult(ControlBlock) {
fn parseControlBlock(comptime tokens: TokenIter) ParseResult(TokenIter, ControlBlock) {
comptime {
var iter = tokens;
var first_token: bool = true;
@ -325,7 +325,7 @@ fn endControlBlock(comptime tokens: TokenIter) TokenIter {
}
}
fn parseForLoop(comptime tokens: TokenIter) ParseResult(ForLoop) {
fn parseForLoop(comptime tokens: TokenIter) ParseResult(TokenIter, ForLoop) {
comptime {
const iterable = parseExpression(tokens);
var iter = iterable.new_iter;
@ -360,7 +360,7 @@ fn parseForLoop(comptime tokens: TokenIter) ParseResult(ForLoop) {
}
}
fn parseIfStatement(comptime tokens: TokenIter) ParseResult(IfStatement) {
fn parseIfStatement(comptime tokens: TokenIter) ParseResult(TokenIter, IfStatement) {
comptime {
const condition = parseExpression(tokens);
var iter = endControlBlock(condition.new_iter);
@ -371,7 +371,7 @@ fn parseIfStatement(comptime tokens: TokenIter) ParseResult(IfStatement) {
}
}
fn parseDeref(comptime tokens: TokenIter) ParseResult([]const []const u8) {
fn parseDeref(comptime tokens: TokenIter) ParseResult(TokenIter, []const []const u8) {
comptime {
var iter = tokens;
var fields: []const []const u8 = &.{};
@ -398,9 +398,9 @@ fn parseDeref(comptime tokens: TokenIter) ParseResult([]const []const u8) {
}
}
fn ParseResult(comptime T: type) type {
fn ParseResult(comptime It: type, comptime T: type) type {
return struct {
new_iter: TokenIter,
new_iter: It,
item: T,
};
}