code generator finally seems to work properly
This commit is contained in:
34
lib/parse.js
34
lib/parse.js
@@ -166,6 +166,14 @@ function is_unicode_connector_punctuation(ch) {
|
||||
return UNICODE.connector_punctuation.test(ch);
|
||||
};
|
||||
|
||||
function is_identifier(name) {
|
||||
return /^[a-z_$][a-z0-9_$]*$/i.test(name)
|
||||
&& name != "this"
|
||||
&& !HOP(KEYWORDS_ATOM, name)
|
||||
&& !HOP(RESERVED_WORDS, name)
|
||||
&& !HOP(KEYWORDS, name);
|
||||
};
|
||||
|
||||
function is_identifier_start(ch) {
|
||||
return ch == "$" || ch == "_" || is_letter(ch);
|
||||
};
|
||||
@@ -695,11 +703,10 @@ function parse($TEXT, exigent_mode) {
|
||||
};
|
||||
|
||||
function parenthesised() {
|
||||
return new AST_Parenthesized({
|
||||
start : expect("("),
|
||||
expression : expression(),
|
||||
end : expect(")")
|
||||
});
|
||||
expect("(");
|
||||
var exp = expression();
|
||||
expect(")");
|
||||
return exp;
|
||||
};
|
||||
|
||||
function embed_tokens(parser) {
|
||||
@@ -834,7 +841,7 @@ function parse($TEXT, exigent_mode) {
|
||||
S.labels.push(label);
|
||||
var start = S.token, stat = statement();
|
||||
S.labels.pop();
|
||||
return new AST_LabeledStatement({ statement: stat });
|
||||
return new AST_LabeledStatement({ statement: stat, label: label });
|
||||
};
|
||||
|
||||
function simple_statement() {
|
||||
@@ -866,9 +873,6 @@ function parse($TEXT, exigent_mode) {
|
||||
init = is("keyword", "var")
|
||||
? (next(), var_(true))
|
||||
: expression(true, true);
|
||||
if (init instanceof AST_Var) {
|
||||
init.inline = true;
|
||||
}
|
||||
if (is("operator", "in")) {
|
||||
if (init instanceof AST_Var && init.definitions.length > 1)
|
||||
croak("Only one variable declaration allowed in for..in loop");
|
||||
@@ -932,7 +936,7 @@ function parse($TEXT, exigent_mode) {
|
||||
--S.in_function;
|
||||
S.in_loop = loop;
|
||||
S.labels = labels;
|
||||
return new AST_Bracketed({ body: a });
|
||||
return new AST_BlockStatement({ body: a });
|
||||
})()
|
||||
});
|
||||
};
|
||||
@@ -997,7 +1001,7 @@ function parse($TEXT, exigent_mode) {
|
||||
}));
|
||||
|
||||
function try_() {
|
||||
var body = new AST_Bracketed({
|
||||
var body = new AST_BlockStatement({
|
||||
start : S.token,
|
||||
body : block_(),
|
||||
end : prev()
|
||||
@@ -1011,7 +1015,7 @@ function parse($TEXT, exigent_mode) {
|
||||
bcatch = new AST_Catch({
|
||||
start : start,
|
||||
argname : name,
|
||||
body : new AST_Bracketed({
|
||||
body : new AST_BlockStatement({
|
||||
start : S.token,
|
||||
body : block_(),
|
||||
end : prev()
|
||||
@@ -1024,7 +1028,7 @@ function parse($TEXT, exigent_mode) {
|
||||
next();
|
||||
bfinally = new AST_Finally({
|
||||
start : start,
|
||||
body : new AST_Bracketed({
|
||||
body : new AST_BlockStatement({
|
||||
start : S.token,
|
||||
body : block_(),
|
||||
end : prev()
|
||||
@@ -1191,7 +1195,7 @@ function parse($TEXT, exigent_mode) {
|
||||
var type = start.type;
|
||||
var name = as_property_name();
|
||||
if (type == "name" && !is("punc", ":")) {
|
||||
if (name.name == "get") {
|
||||
if (name == "get") {
|
||||
a.push(new AST_ObjectGetter({
|
||||
start : start,
|
||||
name : name,
|
||||
@@ -1200,7 +1204,7 @@ function parse($TEXT, exigent_mode) {
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
if (name.name == "set") {
|
||||
if (name == "set") {
|
||||
a.push(new AST_ObjectSetter({
|
||||
start : start,
|
||||
name : name,
|
||||
|
||||
Reference in New Issue
Block a user