|
1 | 1 | _ = window?._ ? self?._ ? global?._ ? require 'lodash' # rely on lodash existing, since it busts CodeCombat to browserify it--TODO
|
2 | 2 |
|
3 | 3 | jshintHolder = {}
|
| 4 | +acorn_loose = require 'acorn-loose' |
4 | 5 | escodegen = require 'escodegen'
|
5 | 6 |
|
6 | 7 | Language = require './language'
|
@@ -41,8 +42,8 @@ module.exports = class JavaScript extends Language
|
41 | 42 | return not _.isEqual(aAST.body, bAST.body)
|
42 | 43 | # Esprima couldn't parse either ASTs, so let's fall back to acorn_loose
|
43 | 44 | options = {locations: false, tabSize: 4, ecmaVersion: 5}
|
44 |
| - aAST = acorn_loose.parse_dammit a, options |
45 |
| - bAST = acorn_loose.parse_dammit b, options |
| 45 | + aAST = acorn_loose.parse a, options |
| 46 | + bAST = acorn_loose.parse b, options |
46 | 47 | unless aAST and bAST
|
47 | 48 | console.log "Couldn't even loosely parse; are you sure #{a} and #{b} are #{@name}?"
|
48 | 49 | return true
|
@@ -121,7 +122,7 @@ module.exports = class JavaScript extends Language
|
121 | 122 | ast = escodegen.attachComments ast, ast.comments, ast.tokens
|
122 | 123 | catch e
|
123 | 124 | console.log 'got error beautifying', e
|
124 |
| - ast = acorn_loose.parse_dammit rawCode, {tabSize: 4, ecmaVersion: 5} |
| 125 | + ast = acorn_loose.parse rawCode, {tabSize: 4, ecmaVersion: 5} |
125 | 126 | beautified = escodegen.generate ast, {comment: true, parse: esprima.parse}
|
126 | 127 | beautified
|
127 | 128 |
|
@@ -152,7 +153,7 @@ module.exports = class JavaScript extends Language
|
152 | 153 | # Useful for parsing incomplete code as it is being written without giving up.
|
153 | 154 | # This should never throw an error and should always return some sort of AST, even if incomplete or empty.
|
154 | 155 | parseDammit: (code, aether) ->
|
155 |
| - ast = acorn_loose.parse_dammit code, {locations: true, tabSize: 4, ecmaVersion: 5} |
| 156 | + ast = acorn_loose.parse code, {locations: true, tabSize: 4, ecmaVersion: 5} |
156 | 157 |
|
157 | 158 | if ast? and ast.body.length isnt 1
|
158 | 159 | ast.body = ast.body.slice(0,0)
|
|
0 commit comments