Skip to content

Commit

Permalink
fix symbol literal
Browse files Browse the repository at this point in the history
- \     === ''
- \0123 === '0123'
- build v0.0.26
  • Loading branch information
mohayonao committed May 14, 2014
1 parent 1ec71dd commit bf8d483
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
8 changes: 4 additions & 4 deletions build/scscript.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function(global) {
"use strict";

var sc = { VERSION: "0.0.25" };
var sc = { VERSION: "0.0.26" };

// src/sc/sc.js
(function(sc) {
Expand Down Expand Up @@ -1895,11 +1895,11 @@ var sc = { VERSION: "0.0.25" };
var re, start, items;
var value;

re = /^\\([a-z_]\w*)?/i;
re = /^\\([a-zA-Z_]\w*|\d+)?/;
start = this.index;
items = re.exec(this.source.slice(this.index));

value = items[1];
value = items[1] || "";

this.index += items[0].length;

Expand Down Expand Up @@ -2124,7 +2124,7 @@ var sc = { VERSION: "0.0.25" };
node = this.withScope(function() {
var body;

body = this.parseFunctionBody("");
body = this.parseFunctionBody(null);
if (body.length === 1 && body[0].type === Syntax.BlockExpression) {
body = body[0].body;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scscript",
"version": "0.0.25",
"version": "0.0.26",
"author": "Nao Yonamine <mohayonao@gmail.com>",
"homepage": "http://mohayonao.github.io/SCScript/",
"bugs": "https://github.com/mohayonao/SCScript/issues",
Expand Down
4 changes: 2 additions & 2 deletions src/sc/lang/compiler/lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,11 +596,11 @@
var re, start, items;
var value;

re = /^\\([a-z_]\w*)?/i;
re = /^\\([a-zA-Z_]\w*|\d+)?/;
start = this.index;
items = re.exec(this.source.slice(this.index));

value = items[1];
value = items[1] || "";

this.index += items[0].length;

Expand Down
22 changes: 22 additions & 0 deletions src/sc/lang/compiler/lexer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,28 @@
}
},
],
"\\": [
{
type: Token.SymbolLiteral,
value: "",
range: [ 0, 1 ],
loc: {
start: { line: 1, column: 0 },
end : { line: 1, column: 1 }
}
},
],
"\\0123": [
{
type: Token.SymbolLiteral,
value: "0123",
range: [ 0, 5 ],
loc: {
start: { line: 1, column: 0 },
end : { line: 1, column: 5 }
}
},
],
"'symbol'": [
{
type: Token.SymbolLiteral,
Expand Down
2 changes: 1 addition & 1 deletion src/sc/lang/compiler/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
node = this.withScope(function() {
var body;

body = this.parseFunctionBody("");
body = this.parseFunctionBody(null);
if (body.length === 1 && body[0].type === Syntax.BlockExpression) {
body = body[0].body;
}
Expand Down

0 comments on commit bf8d483

Please sign in to comment.