solidity-antlr4
Version:
Solidity Lang Lexer and Parser by official ANTLR4 grammar
25 lines (24 loc) • 826 B
JavaScript
import { BaseNodeList } from "../base.js";
import {
VariableDeclarationContext
} from "../../antlr4/index.js";
const isVarCtx = (ctx) => ctx instanceof VariableDeclarationContext;
export const VariableDeclarationTuple = class extends BaseNodeList {
type = "VariableDeclarationTuple";
constructor(ctx, visitor) {
const list = [];
const children = ctx.children ?? [];
for (let index = 0; index < children.length; index += 1) {
const current = children[index];
const next = children[index + 1];
if (!next)
continue;
if (!isVarCtx(current) && isVarCtx(next)) {
list.push(next);
} else if (!isVarCtx(current) && !isVarCtx(next)) {
list.push(null);
}
}
super(list, visitor, (current) => current === null ? null : current.accept(visitor));
}
};