-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add scope hack for compiler #55
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -709,13 +709,11 @@ VimLParser.prototype.parse_command_modifiers = function() { | |
var modifiers = []; | ||
while (TRUE) { | ||
var pos = this.reader.tell(); | ||
var d = ""; | ||
if (isdigit(this.reader.peekn(1))) { | ||
var d = this.reader.read_digit(); | ||
this.reader.skip_white(); | ||
} | ||
else { | ||
var d = ""; | ||
} | ||
var k = this.reader.read_alpha(); | ||
var c = this.reader.peekn(1); | ||
this.reader.skip_white(); | ||
|
@@ -1024,6 +1022,7 @@ VimLParser.prototype.parse_command = function() { | |
|
||
VimLParser.prototype.find_command = function() { | ||
var c = this.reader.peekn(1); | ||
var name = ""; | ||
if (c == "k") { | ||
this.reader.getn(1); | ||
var name = "k"; | ||
|
@@ -1227,6 +1226,7 @@ VimLParser.prototype.parse_cmd_modifier_range = function() { | |
|
||
// TODO: | ||
VimLParser.prototype.parse_cmd_common = function() { | ||
var end = this.reader.getpos(); | ||
if (viml_eqregh(this.ea.cmd.flags, "\\<TRLBAR\\>") && !this.ea.usefilter) { | ||
var end = this.separate_nextcmd(); | ||
} | ||
|
@@ -1380,6 +1380,7 @@ VimLParser.prototype.parse_cmd_loadkeymap = function() { | |
} | ||
|
||
VimLParser.prototype.parse_cmd_lua = function() { | ||
var lines = []; | ||
this.reader.skip_white(); | ||
if (this.reader.peekn(2) == "<<") { | ||
this.reader.getn(2); | ||
|
@@ -1496,6 +1497,7 @@ VimLParser.prototype.parse_cmd_function = function() { | |
else { | ||
var named = {}; | ||
while (TRUE) { | ||
var varnode = Node(NODE_IDENTIFIER); | ||
var token = tokenizer.get(); | ||
if (token.type == TOKEN_IDENTIFIER) { | ||
if (!isargname(token.value) || token.value == "firstline" || token.value == "lastline") { | ||
|
@@ -1505,7 +1507,6 @@ VimLParser.prototype.parse_cmd_function = function() { | |
throw Err(viml_printf("E853: Duplicate argument name: %s", token.value), token.pos); | ||
} | ||
named[token.value] = 1; | ||
var varnode = Node(NODE_IDENTIFIER); | ||
varnode.pos = token.pos; | ||
varnode.value = token.value; | ||
viml_add(node.rlist, varnode); | ||
|
@@ -1529,7 +1530,6 @@ VimLParser.prototype.parse_cmd_function = function() { | |
} | ||
} | ||
else if (token.type == TOKEN_DOTDOTDOT) { | ||
var varnode = Node(NODE_IDENTIFIER); | ||
varnode.pos = token.pos; | ||
varnode.value = token.value; | ||
viml_add(node.rlist, varnode); | ||
|
@@ -2433,6 +2433,7 @@ ExprTokenizer.prototype.get2 = function() { | |
return this.token(TOKEN_REG, r.getn(2), pos); | ||
} | ||
else if (c == "&") { | ||
var s = ""; | ||
if ((r.p(1) == "g" || r.p(1) == "l") && r.p(2) == ":") { | ||
var s = r.getn(3) + r.read_word(); | ||
} | ||
|
@@ -2966,6 +2967,7 @@ ExprParser.prototype.parse_expr8 = function() { | |
if (token.type != TOKEN_SQCLOSE) { | ||
throw Err(viml_printf("unexpected token: %s", token.value), token.pos); | ||
} | ||
var left = node; | ||
} | ||
else { | ||
var right = this.parse_expr1(); | ||
|
@@ -2983,6 +2985,7 @@ ExprParser.prototype.parse_expr8 = function() { | |
if (token.type != TOKEN_SQCLOSE) { | ||
throw Err(viml_printf("unexpected token: %s", token.value), token.pos); | ||
} | ||
var left = node; | ||
} | ||
else { | ||
var node = Node(NODE_SUBSCRIPT); | ||
|
@@ -2993,9 +2996,9 @@ ExprParser.prototype.parse_expr8 = function() { | |
if (token.type != TOKEN_SQCLOSE) { | ||
throw Err(viml_printf("unexpected token: %s", token.value), token.pos); | ||
} | ||
var left = node; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this your expected? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes? Maybe I just don't understand what you asked? It's exactly translated as I expected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, you don't expect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It works because it's "var", not "let". Ideally, we may want to drop "var" here but it's not this p-r scope. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, right. hopefully we will fix this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VIm script's "let" ≒ JavaScript "var" Cool! Easy to translate! Happy variable scope life! 😇 😇 😇 |
||
} | ||
} | ||
var left = node; | ||
delete node; | ||
} | ||
else if (token.type == TOKEN_POPEN) { | ||
|
@@ -3066,6 +3069,7 @@ ExprParser.prototype.parse_expr8 = function() { | |
ExprParser.prototype.parse_expr9 = function() { | ||
var pos = this.reader.tell(); | ||
var token = this.tokenizer.get(); | ||
var node = Node(-1); | ||
if (token.type == TOKEN_NUMBER) { | ||
var node = Node(NODE_NUMBER); | ||
node.pos = token.pos; | ||
|
@@ -3317,13 +3321,14 @@ ExprParser.prototype.parse_identifier = function() { | |
var node = Node(NODE_IDENTIFIER); | ||
node.pos = npos; | ||
node.value = curly_parts[0].value; | ||
return node; | ||
} | ||
else { | ||
var node = Node(NODE_CURLYNAME); | ||
node.pos = npos; | ||
node.value = curly_parts; | ||
return node; | ||
} | ||
return node; | ||
} | ||
|
||
ExprParser.prototype.parse_curly_parts = function() { | ||
|
@@ -3391,6 +3396,7 @@ LvalueParser.prototype.parse_lv8 = function() { | |
var token = this.tokenizer.get(); | ||
if (!iswhite(c) && token.type == TOKEN_SQOPEN) { | ||
var npos = token.pos; | ||
var node = Node(-1); | ||
if (this.tokenizer.peek().type == TOKEN_COLON) { | ||
this.tokenizer.get(); | ||
var node = Node(NODE_SLICE); | ||
|
@@ -3462,6 +3468,7 @@ LvalueParser.prototype.parse_lv8 = function() { | |
LvalueParser.prototype.parse_lv9 = function() { | ||
var pos = this.reader.tell(); | ||
var token = this.tokenizer.get(); | ||
var node = Node(-1); | ||
if (token.type == TOKEN_COPEN) { | ||
this.reader.seek_set(pos); | ||
var node = this.parse_identifier(); | ||
|
@@ -4075,6 +4082,7 @@ Compiler.prototype.compile_excall = function(node) { | |
} | ||
|
||
Compiler.prototype.compile_let = function(node) { | ||
var left = ""; | ||
if (node.left !== NIL) { | ||
var left = this.compile(node.left); | ||
} | ||
|
@@ -4147,6 +4155,7 @@ Compiler.prototype.compile_while = function(node) { | |
} | ||
|
||
Compiler.prototype.compile_for = function(node) { | ||
var left = ""; | ||
if (node.left !== NIL) { | ||
var left = this.compile(node.left); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add indent space into previous line?