latest-narcissus.coffee 606 B

12345678910111213141516171819202122232425262728293031
  1. nParser = require 'narcissus/lib/parser'
  2. esprima = require 'esprima'
  3. acorn = require 'acorn'
  4. {inspect} = require 'util'
  5. fs = require 'fs'
  6. arg = process.argv[2]
  7. content = fs.readFileSync(arg, {encoding: 'utf8'})
  8. console.log '--narcissus'
  9. try
  10. result = nParser.parse content
  11. console.log inspect result
  12. catch err
  13. console.error err.message
  14. console.log '--esprima'
  15. try
  16. result = esprima.parse content
  17. console.log inspect result.body[0].expression
  18. catch err
  19. console.error err.message
  20. console.log '--acorn'
  21. result = acorn.parse content
  22. console.log inspect result.body[0].expression