test0r.coffee 989 B

123456789101112131415161718192021222324252627282930313233343536
  1. code = """
  2. foo = 'bar'
  3. """
  4. main = (parse) ->
  5. ast = parse code
  6. console.log stringify ast
  7. stringify = (obj) ->
  8. JSON.stringify obj, null, 2
  9. if require.main is module
  10. param = process.argv[2]
  11. parseFunction = null
  12. switch param
  13. when 'narcissus' # new narcisuss
  14. console.log 'narcissus'
  15. narcissus = require 'narcissus_new'
  16. parseFunction = narcissus.parser.parse
  17. when 'packed'
  18. console.log 'narcissus_packed'
  19. narcissus = require './src/documents/lib/narcissus_packed'
  20. parseFunction = narcissus.parser.parse
  21. when 'acorn'
  22. console.log 'acorn'
  23. acorn = require 'acorn'
  24. parseFunction = acorn.parse
  25. when 'esprima'
  26. console.log 'esprima'
  27. esprima = require 'esprima'
  28. parseFunction = esprima.parse
  29. else
  30. console.log 'no parser specified'
  31. process.exit 1
  32. main(parseFunction)