#!/usr/bin/env node
const fs=require("fs");
function print(/*arguments*/){
process.stdout.write.apply(process.stdout,arguments);
}
function pad(s,w,c){
s=s+"";
if(s.length>=Math.abs(w))return s;
if(w<0)return s+Array(-w-s.length+1).join(c?c:" ");
else return Array(w-s.length+1).join(c?c:" ")+s;
}
function readopmap(fname){
let table=String(fs.readFileSync(fname)).split("\n");
let i;
for(i=0;i
\n\n");
print("#include \"opfuncs.h\"\n");
print("#include \"parser.h\"\n");
function alsolen(_){
outputfunc(_);
_.name+="_len";
_.dolen=true;
outputfunc(_);
}
alsolen({
opmap:opmap,
name:"precedence",
gen:(op,o)=>o.prec,
padw:2,
dolen:false,
rettype:"int",
defval:"-1",
checkend:true
});
alsolen({
opmap:opmap,
name:"associativity",
gen:(op,o)=>assocenum[o.assoc],
padw:-11,
dolen:false,
rettype:"int",
defval:"-1",
checkend:true
});
outputfunc({
opmap:opmap,
name:"parseoplength",
gen:(op,o)=>op.length,
padw:1,
dolen:false,
rettype:"int",
defval:"-1",
checkend:false
});
outputfunc({
opmap:opmap,
name:"opconststring_len",
gen:(op,o)=>'"'+op+'"',
padw:3,
dolen:true,
rettype:"const char*",
defval:"NULL",
checkend:true
});