var process = require('process')
var fs = require('fs')
var nearley = require('nearley')
var grammar = require('./grammar')

var p = new nearley.Parser(grammar.ParserRules, grammar.ParserStart)
var filename = process.argv[2]
var data = fs.readFileSync(filename, 'utf8')

var result = p.feed(data)

console.log(result.results.length)
console.dir(result.results[0], {
    depth: null
})

@@ -121,77 +121,41 @@
 r')%0A
-%0A
 var 
-p = new nearley.Parser(grammar.ParserRules, grammar.ParserStart)
+helper = require('./helper')%0A
 %0Avar
@@ -232,68 +232,1148 @@
 ')%0A%0A
-var result = p.feed(data)%0A%0Aconsole.log(result.results.length
+// Normalize endings%0A%0Aconsole.error('Normalize endings...')%0Adata = data.replace(/%5Cr%5Cn/g, '%5Cn').replace(/%5Cr/g, '')%0A%0A// Remove comments & strings%0A%0Aconsole.error('Remove comments...')%0A%0Avar removed = helper.removeStringComments(data)%0Avar stringCommentsRemoved = removed%5B1%5D%0Adata = removed%5B0%5D%0A%0A// Get indent length%0A%0Aconsole.error('Determine indent length...')%0Avar indentLength%0A%0Atry %7B%0A    indentLength = helper.getIndent(data)%0A%7D catch(e) %7B%0A    console.error('Mixed indentation @' + e.line + ':1')%0A    return%0A%7D%0A%0A// Indentifizer%0A%0Aconsole.error('Indentifizer...')%0Adata = helper.indentifizer(data, stringCommentsRemoved, indentLength)%0A%0A// Invoke nearley%0A%0Aconsole.error('Parsing...')%0Avar p = new nearley.Parser(grammar.ParserRules, grammar.ParserStart)%0A%0Atry %7B%0A    var result = p.feed(data)%0A%0A    if (!result %7C%7C !result.results %7C%7C !result.results.length)%0A        throw %7B offset: data.length - 1 %7D%0A%7D catch(e) %7B%0A    var pos = helper.offsetToLinePos(e.offset, data)%0A    console.error('Parse error @' + pos%5B0%5D + ':' + pos%5B1%5D)%0A    return%0A%7D%0A%0Aconsole.error('Compiled.')%0Aconsole.error(result.results.length == 1 ? 'No ambiguity detected.' : 'Ambiguity detected.'
 )%0Aco
@@ -1400,18 +1400,11 @@
 ults
-%5B0%5D, %7B%0A   
+, %7B
  dep
@@ -1411,12 +1411,12 @@
 th: null
-%0A
+ 
 %7D)%0A

Update milk.js