- /**
- * Core packing routine for a file
- *
- * @param str - str source text..
- * @param fn - filename (for reference?)
- * @param minfile - min file location...
- *
- */
-
- packFile : function (str,fn,minfile)
- {
-
- var tr = new TokenReader( {
- keepDocs :true,
- keepWhite : true,
- keepComments : true,
- sepIdents : true,
- collapseWhite : false,
- filename : fn
- });
- this.timerPrint("START" + fn);
-
- // we can load translation map here...
-
- var toks = tr.tokenize(new TextStream(str)); // dont merge xxx + . + yyyy etc.
-
- // at this point we can write a language file...
- if (this.translateJSON) {
-
- this.writeTranslateFile(fn, minfile, toks);
- }
-
- this.activeFile = fn;
-
- // and replace if we are generating a different language..
-
- this.timerPrint("Tokenized");
- //var ts = new TokenStream(toks);
- //print(JSON.stringify(toks, null,4 )); Seed.quit();
- var ts = new Collapse(toks);
- // print(JSON.stringify(ts.tokens, null,4 )); Seed.quit();
- //return;//
- var sp = new ScopeParser(ts);
- this.timerPrint("Converted to Parser");
- sp.packer = this;
- sp.buildSymbolTree();
- this.timerPrint("Built Sym tree");
- sp.mungeSymboltree();
- this.timerPrint("Munged Sym tree");
- print(sp.warnings.join("\n"));
- this.timerPrint("Compressed");
-
- var out = CompressWhite(new TokenStream(toks), this, this.keepWhite); // do not kill whitespace..
-
-
- this.timerPrint("Compressed");
-
- if (out.length) {
- File.write(minfile, out);
- this.timerPrint("Write (" + out.length + "bytes) " + minfile);
- }
-
- return out;
-
-
-
- },
-
-
- md5 : function (string)
- {
-
- return GLib.compute_checksum_for_string(GLib.ChecksumType.MD5, string, string.length);
-
- },
-
- //stringHandler : function(tok) -- not used...
+ /**
+ * Core packing routine for a file
+ *
+ * @param str - str source text..
+ * @param fn - filename (for reference?)
+ * @param minfile - min file location...
+ *
+ */
+
+ private string packFile (string str,string fn, string minfile)
+ {
+
+ var tr = new TokenReader();
+ tr.keepDocs =true;
+ tr.keepWhite = true;
+ tr.keepComments = true;
+ tr.sepIdents = true;
+ tr.collapseWhite = false;
+ tr.filename = fn;
+
+ // we can load translation map here...
+
+ TokenArray toks = tr.tokenize(new TextStream(str)); // dont merge xxx + . + yyyy etc.
+
+
+
+ this.activeFile = fn;
+
+ // and replace if we are generating a different language..
+
+
+ //var ts = new TokenStream(toks);
+ //print(JSON.stringify(toks, null,4 )); Seed.quit();
+ var ts = new Collapse(toks.tokens);
+
+ //ts.dumpAll(""); print("Done collaps"); Process.exit(1);
+
+ // print(JSON.stringify(ts.tokens, null,4 )); Seed.quit();
+ //return;//
+ var sp = new ScopeParser(ts);
+
+ //sp.packer = this;
+ sp.buildSymbolTree();
+
+ sp.mungeSymboltree();
+ sp.printWarnings();
+ //print(sp.warnings.join("\n"));
+
+ GLib.Process.exit(1);
+ // compress works on the original array - in theory the replacements have already been done by now
+ var outf = CompressWhite(new TokenStream(toks.tokens), this, this.keepWhite); // do not kill whitespace..
+
+
+ print("RESULT: \n %s\n", outf);
+
+ if (outf.length > 0) {
+ FileUtils.set_contents(minfile, outf);
+
+ }
+
+
+ return outf;
+
+
+
+ }
+
+
+ public string md5(string str)
+ {
+
+ return GLib.Checksum.compute_for_string(GLib.ChecksumType.MD5, str);
+
+ }