solidity-antlr4
Version:
Solidity Lang Lexer and Parser by official ANTLR4 grammar
32 lines (31 loc) • 895 B
JavaScript
import { BasePrinter } from "./base.js";
export class PrinterType extends BasePrinter {
printElementaryTypeName = ({ node }) => {
const parts = [node.name];
if (node.name === "address" && node.payable)
parts.push(this.space, "payable");
return parts;
};
printFunctionTypeName;
// TODO: implement in declaration.ts
printMappingKeyType = ({ node }) => node.name;
printMappingType = ({ path, print }) => {
return [
"mapping",
this.tuple([
path.call(print, "keyType"),
this.space,
"=>",
this.space,
path.call(print, "valueType")
])
];
};
printTypeName = (args) => {
const { node, path, print } = args;
if (node.type === "TypeName") {
return [path.call(print, "baseType"), this.list(path.call(print, "expression"))];
}
throw new Error("Unknown node type: " + node.type);
};
}