Skip to content

Commit

Permalink
后缀表达式的++、--后无需保留空白
Browse files Browse the repository at this point in the history
  • Loading branch information
army8735 committed Aug 9, 2015
1 parent 7162037 commit 6beb20b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homunculus",
"version": "0.10.0",
"version": "0.10.1",
"description": "A lexer&parser by Javascript",
"maintainers": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/parser/es6/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ var Parser = IParser.extend(function(lexer) {
if(this.look && ['++', '--'].indexOf(this.look.content()) > -1 && !this.hasMoveLine) {
node.add(
leftexpr,
this.match(undefined, true)
this.match()
);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/parser/js/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ var Parser = IParser.extend(function(lexer) {
if(this.look && ['++', '--'].indexOf(this.look.content()) > -1 && !this.hasMoveLine) {
node.add(
leftexpr,
this.match(undefined, true)
this.match()
);
}
else {
Expand Down
5 changes: 5 additions & 0 deletions tests/jsparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ describe('jsparser', function() {
var node = parser.parse('a++');
expect(tree(node)).to.eql([JsNode.PROGRAM,[JsNode.EXPRSTMT,[JsNode.POSTFIXEXPR,[JsNode.PRMREXPR,["a"],"++"]]]]);
});
it('postfixexpr 5', function() {
var parser = homunculus.getParser('js');
var node = parser.parse('{a:a++\n}');
expect(tree(node)).to.eql([JsNode.PROGRAM,[JsNode.BLOCK,["{",JsNode.LABSTMT,["a",":",JsNode.EXPRSTMT,[JsNode.POSTFIXEXPR,[JsNode.PRMREXPR,["a"],"++"]]],"}"]]]);
});
it('postfixexpr error 1', function() {
var parser = homunculus.getParser('js');
expect(function() {
Expand Down
2 changes: 1 addition & 1 deletion web/parser/es6/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ var Parser = IParser.extend(function(lexer) {
if(this.look && ['++', '--'].indexOf(this.look.content()) > -1 && !this.hasMoveLine) {
node.add(
leftexpr,
this.match(undefined, true)
this.match()
);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion web/parser/js/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ var Parser = IParser.extend(function(lexer) {
if(this.look && ['++', '--'].indexOf(this.look.content()) > -1 && !this.hasMoveLine) {
node.add(
leftexpr,
this.match(undefined, true)
this.match()
);
}
else {
Expand Down

0 comments on commit 6beb20b

Please sign in to comment.