Add It param to ParseResult
This commit is contained in:
parent
52bb8739f8
commit
1340862c28
1 changed files with 8 additions and 8 deletions
|
@ -123,7 +123,7 @@ const TemplateType = enum {
|
||||||
if_block,
|
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 {
|
comptime {
|
||||||
var iter = tokens;
|
var iter = tokens;
|
||||||
var items: []const TemplateItem = &.{};
|
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 {
|
comptime {
|
||||||
var iter = tokens;
|
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 {
|
comptime {
|
||||||
var iter = tokens;
|
var iter = tokens;
|
||||||
var first_token: bool = true;
|
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 {
|
comptime {
|
||||||
const iterable = parseExpression(tokens);
|
const iterable = parseExpression(tokens);
|
||||||
var iter = iterable.new_iter;
|
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 {
|
comptime {
|
||||||
const condition = parseExpression(tokens);
|
const condition = parseExpression(tokens);
|
||||||
var iter = endControlBlock(condition.new_iter);
|
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 {
|
comptime {
|
||||||
var iter = tokens;
|
var iter = tokens;
|
||||||
var fields: []const []const u8 = &.{};
|
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 {
|
return struct {
|
||||||
new_iter: TokenIter,
|
new_iter: It,
|
||||||
item: T,
|
item: T,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue