Skip to content

Commit

Permalink
fix endless loop with case in block (#93)
Browse files Browse the repository at this point in the history
* fix endless loop with case in block
* prepare release 1.0.9
  • Loading branch information
AlexHaxe authored Aug 13, 2018
1 parent d5caab0 commit 08fd5d6
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## dev branch / next version (1.x.x)

## version 1.0.9 (2018-08-13)

- Fixed endless loop with case and conditionals [#93](https://github.com/HaxeCheckstyle/tokentree/issues/93)

## version 1.0.8 (2018-08-13)

- Fixed null poiner and detection in `getPOpenType` [#73](https://github.com/HaxeCheckstyle/tokentree/issues/73) + [#88](https://github.com/HaxeCheckstyle/tokentree/issues/88) + [#91](https://github.com/HaxeCheckstyle/tokentree/issues/91)
Expand Down
4 changes: 2 additions & 2 deletions haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"contributors": [
"AlexHaxe"
],
"releasenote": "fixed POpen and BrOpen type detection, fixed endless loop with switch and conditionals - see CHANGELOG for details",
"version": "1.0.8",
"releasenote": "fixed endless loop with switch and conditionals - see CHANGELOG for details",
"version": "1.0.9",
"url": "https://github.com/HaxeCheckstyle/tokentree",
"dependencies": {}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tokentree",
"version": "1.0.8",
"version": "1.0.9",
"description": "TokenTree library used by haxe-checkstyle",
"repository": {
"type": "git",
Expand Down
2 changes: 2 additions & 0 deletions src/tokentree/walk/WalkBlock.hx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class WalkBlock {
case BkClose, PClose:
var child:TokenTree = stream.consumeToken();
parent.addChild(child);
case Kwd(KwdCase), Kwd(KwdDefault):
WalkSwitch.walkSwitchCases(stream, parent);
default:
WalkStatement.walkStatement(stream, parent);
}
Expand Down
15 changes: 11 additions & 4 deletions src/tokentree/walk/WalkSwitch.hx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ class WalkSwitch {
WalkComment.walkComment(stream, switchTok);
WalkStatement.walkStatement(stream, switchTok);
WalkComment.walkComment(stream, switchTok);
var brOpen:TokenTree = stream.consumeTokenDef(BrOpen);
switchTok.addChild(brOpen);
WalkSwitch.walkSwitchCases(stream, brOpen);
brOpen.addChild(stream.consumeTokenDef(BrClose));
switch (stream.token()) {
case Sharp(_):
WalkSharp.walkSharp(stream, parent, WalkSwitch.walkSwitchCases);
default:
}
if (stream.is(BrOpen)) {
var brOpen:TokenTree = stream.consumeTokenDef(BrOpen);
switchTok.addChild(brOpen);
WalkSwitch.walkSwitchCases(stream, brOpen);
brOpen.addChild(stream.consumeTokenDef(BrClose));
}
}

public static function walkSwitchCases(stream:TokenStream, parent:TokenTree) {
Expand Down
19 changes: 19 additions & 0 deletions test/tokentree/TokenTreeBuilderParsingTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,25 @@ abstract TokenTreeBuilderParsingTests(String) to String {
Sys.println (' succedded');
}
}
public static function main() {
#if neko
switch (Sys.command ('neko', ['tests.n', name, field.name]))
#elseif cpp
switch (Sys.command ('./bin/FunctionalTest', [name, field.name]))
#end {
case 0:
passed++;
Sys.println (' succedded');
#if neko
case 1:
Sys.println(' failed');
#end
case 1:
Sys.println(' failed');
case _:
Sys.println(' errored');
}
}
}
";
}

0 comments on commit 08fd5d6

Please sign in to comment.