const parser = require('./sgtableParser');


if (require.main == module) {
  const fs   = require('fs');
  const file = process.argv[2]
  const text = fs.readFileSync(file, { encoding: 'utf8' });

  const timer = require('../common/util').timer();
  const data  = parser.parse(text);
  const time  = timer();

  try {
    console.log(`${JSON.stringify(data, null, 2)}`);
  } catch(ex) {
    console.error(ex);
  }

  console.log(`Parsing time: ${time} msec`);
};

@@ -38,16 +38,920 @@
 er');%0A%0A%0A
+const makeOperator = spec =%3E %7B%0A  const d = spec.length;%0A  return spec.map(row =%3E %7B%0A    const r = new Array(d).fill(0);%0A    for (const %7B i, f %7D of row)%0A      r%5Bi-1%5D = f;%0A    return r;%0A  %7D);%0A%7D;%0A%0A%0Aconst cook = rawData =%3E %7B%0A  const lookup = %5B%5D;%0A  const alias  = %7B%7D;%0A  const table  = %7B%7D;%0A%0A  for (const entry of rawData) %7B%0A    const %7B type, name %7D = entry;%0A%0A    if (type == 'alias') %7B%0A      alias%5Bname%5D = entry.fullName;%0A    %7D%0A    else if (type == 'lookup') %7B%0A      lookup.push(%7B%0A        name,%0A        system    : entry.system,%0A        centering : entry.centering,%0A        fromStd   : makeOperator(entry.fromStd)%0A      %7D);%0A    %7D%0A    else if (type == 'setting') %7B%0A      table%5Bname%5D = %7B%0A        transform: makeOperator(entry.transform),%0A        operators: entry.operators.map(makeOperator)%0A      %7D;%0A    %7D%0A    else%0A      throw new Error(%60unknown entry type $%7Btype%7D%60);%0A  %7D%0A%0A  return %7B lookup, alias, table %7D;%0A%7D;%0A%0A%0A
 if (requ
@@ -1108,16 +1108,17 @@
 t timer 
+ 
 = requir
@@ -1154,20 +1154,21 @@
   const 
-data
+raw  
   = pars
@@ -1196,12 +1196,13 @@
 st t
-ime 
+parse
  = t
@@ -1213,132 +1213,189 @@
 ();%0A
-%0A  try %7B%0A    console.log(%60$%7BJSON.stringify(data, null, 2)%7D%60);%0A  %7D catch(ex) %7B%0A    console.error(ex);%0A  %7D%0A%0A  console.log(%60Par
+  const data   = cook(raw);%0A  const tcook  = timer();%0A%0A  console.log(%60$%7BJSON.stringify(data, null, 2)%7D%60);%0A  console.error(%60Parsing time   : $%7Btparse%7D msec%60);%0A  console.error(%60Proces
 sing
@@ -1404,19 +1404,20 @@
 ime: $%7Bt
-ime
+cook
 %7D msec%60)

add some processing of space group data