aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-06-03 14:00:59 +0800
committerGitHub <noreply@github.com>2017-06-03 14:00:59 +0800
commit17436218891781a5dc4fad8a9c23080c254aa695 (patch)
treebfa655e454a6c25fd1ceef8d9b0064014b8ffed8 /lib
parentf330ab743aa65234ad8c7d7cea7a6f8cc71fc6a5 (diff)
downloadtracifyjs-17436218891781a5dc4fad8a9c23080c254aa695.tar.gz
tracifyjs-17436218891781a5dc4fad8a9c23080c254aa695.zip
clean up `lib/parse.js` (#2047)
- remove unused definitions - replace `array_to_hash()`
Diffstat (limited to 'lib')
-rw-r--r--lib/parse.js16
-rw-r--r--lib/utils.js7
2 files changed, 2 insertions, 21 deletions
diff --git a/lib/parse.js b/lib/parse.js
index a02fce8f..553568e1 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -115,8 +115,6 @@ var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,;:"));
var PUNC_CHARS = makePredicate(characters("[]{}(),;:"));
-var REGEXP_MODIFIERS = makePredicate(characters("gmsiy"));
-
/* -----[ Tokenizer ]----- */
// regexps adapted from http://xregexp.com/plugins/#unicode
@@ -684,9 +682,7 @@ var PRECEDENCE = (function(a, ret){
{}
);
-var STATEMENTS_WITH_LABELS = array_to_hash([ "for", "do", "while", "switch" ]);
-
-var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "name" ]);
+var ATOMIC_START_TOKEN = makePredicate([ "atom", "num", "string", "regexp", "name" ]);
/* -----[ Parser ]----- */
@@ -1222,7 +1218,6 @@ function parse($TEXT, options) {
var tok = S.token, ret;
switch (tok.type) {
case "name":
- case "keyword":
ret = _make_symbol(AST_SymbolRef);
break;
case "num":
@@ -1252,13 +1247,6 @@ function parse($TEXT, options) {
break;
}
break;
- case "operator":
- if (!is_identifier_string(tok.value)) {
- croak("Invalid getter/setter name: " + tok.value,
- tok.line, tok.col, tok.pos);
- }
- ret = _make_symbol(AST_SymbolRef);
- break;
}
next();
return ret;
@@ -1292,7 +1280,7 @@ function parse($TEXT, options) {
func.end = prev();
return subscripts(func, allow_calls);
}
- if (ATOMIC_START_TOKEN[S.token.type]) {
+ if (ATOMIC_START_TOKEN(S.token.type)) {
return subscripts(as_atom_node(), allow_calls);
}
unexpected();
diff --git a/lib/utils.js b/lib/utils.js
index e21fc5ec..76306919 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -43,13 +43,6 @@
"use strict";
-function array_to_hash(a) {
- var ret = Object.create(null);
- for (var i = 0; i < a.length; ++i)
- ret[a[i]] = true;
- return ret;
-};
-
function slice(a, start) {
return Array.prototype.slice.call(a, start || 0);
};