Skip to content

Commit

Permalink
updated haxeparser lib with latest Haxe nightly syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHaxe committed Sep 14, 2022
1 parent 9b3b563 commit e1bcea4
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 19 deletions.
6 changes: 3 additions & 3 deletions haxe_libraries/haxeparser.hxml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @install: lix --silent download "gh://github.com/HaxeCheckstyle/haxeparser#1ea2a8915956ac3af6f1a11c67e0e56261b75929" into haxeparser/3.3.0/github/1ea2a8915956ac3af6f1a11c67e0e56261b75929
# @install: lix --silent download "gh://github.com/HaxeCheckstyle/haxeparser#f0a7f07101c14dc32b0964dd52af8dcaa322e178" into haxeparser/4.3.0-rc.1/github/f0a7f07101c14dc32b0964dd52af8dcaa322e178
-lib hxparse
-cp ${HAXE_LIBCACHE}/haxeparser/3.3.0/github/1ea2a8915956ac3af6f1a11c67e0e56261b75929/src
-D haxeparser=3.3.0
-cp ${HAXE_LIBCACHE}/haxeparser/4.3.0-rc.1/github/f0a7f07101c14dc32b0964dd52af8dcaa322e178/src
-D haxeparser=4.3.0-rc.1
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": "moved inline markup code to haxeparser - see CHANGELOG for details",
"version": "1.2.1",
"releasenote": "updated haxeparser to support latest Haxe nightly syntax - see CHANGELOG for details",
"version": "1.2.2",
"url": "https://github.com/HaxeCheckstyle/tokentree",
"dependencies": {}
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.2.1",
"version": "1.2.2",
"description": "TokenTree library used by haxe-checkstyle, haxe-formatter and haxe-languageserver",
"repository": {
"type": "git",
Expand Down
10 changes: 6 additions & 4 deletions src/tokentree/ToTokenTreeDef.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ abstract ToTokenTreeDef(TokenTreeDef) {
return new ToTokenTreeDef(switch (tok) {
case Kwd(k): Kwd(k);
case Const(c): switch (c) {
#if (haxe < version("4.3.0-rc.1"))
case CInt(v): Const(CInt(v));
case CFloat(f): Const(CFloat(f));
#else
#if (haxe >= version("4.3.0-rc.1"))
case CInt(v, s): Const(CInt(v, s));
case CFloat(f, s): Const(CFloat(f, s));
#else
case CInt(v): Const(CInt(v));
case CFloat(f): Const(CFloat(f));
#end
case CString(s, kind): Const(CString(s, kind));
case CIdent(s): Const(CIdent(s));
Expand All @@ -39,6 +39,7 @@ abstract ToTokenTreeDef(TokenTreeDef) {
case Semicolon: Semicolon;
case Dot: Dot;
case DblDot: DblDot;
case QuestionDot: QuestionDot;
case Arrow: Arrow;
case Comma: Comma;
case BkOpen: BkOpen;
Expand All @@ -50,6 +51,7 @@ abstract ToTokenTreeDef(TokenTreeDef) {
case Question: Question;
case At: At;
case Eof: Eof;
case Spread: Spread;
});
}
}
2 changes: 2 additions & 0 deletions src/tokentree/TokenTreeDef.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum TokenTreeDef {
Semicolon;
Dot;
DblDot;
QuestionDot;
Arrow;
Comma;
BkOpen;
Expand All @@ -28,4 +29,5 @@ enum TokenTreeDef {
Question;
At;
Eof;
Spread;
}
10 changes: 9 additions & 1 deletion src/tokentree/TokenTreeDefPrinter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ class TokenTreeDefPrinter {
return switch (def) {
case Root: "<root>";
case Kwd(k): k.getName().substr(3).toLowerCase();
case Const(CInt(s) | CFloat(s) | CIdent(s)): s;
#if (haxe >= version("4.3.0-rc.1"))
case Const(CInt(v, null) | CFloat(v, null)): v;
case Const(CInt(v, s) | CFloat(v, s)): '$v$s';
#else
case Const(CInt(s) | CFloat(s)): s;
#end
case Const(CIdent(s)): s;
case Const(CString(s)): '"$s"';
case Const(CRegexp(r, opt)): '~/$r/$opt';
case Const(CMarkup(s)): '$s';
Expand All @@ -19,6 +25,7 @@ class TokenTreeDefPrinter {
case Semicolon: ";";
case Dot: ".";
case DblDot: ":";
case QuestionDot: "?.";
case Arrow: "->";
case Comma: ",";
case BkOpen: "[";
Expand All @@ -30,6 +37,7 @@ class TokenTreeDefPrinter {
case Question: "?";
case At: "@";
case Eof: "<eof>";
case Spread: "...";
}
}
}
6 changes: 4 additions & 2 deletions src/tokentree/utils/TokenTreeCheckUtils.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TokenTreeCheckUtils {
case Kwd(KwdExtern):
case Const(CIdent(_)):
case Dot:
case Binop(OpIn):
case Kwd(KwdIn) | Binop(OpIn):
case Kwd(KwdImport):
return true;
case Kwd(KwdUsing):
Expand Down Expand Up @@ -67,10 +67,12 @@ class TokenTreeCheckUtils {
}
}
switch (prev.tok) {
case Binop(OpIn):
case Kwd(KwdIn) | Binop(OpIn):
return true;
case Binop(_):
return true;
case Spread:
return true;
case BkOpen:
return true;
case BkClose:
Expand Down
2 changes: 1 addition & 1 deletion src/tokentree/walk/WalkFor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class WalkFor {
}
var inTok:Null<TokenTree> = null;
switch (stream.token()) {
case Binop(OpIn):
case Kwd(KwdIn) | Binop(OpIn):
inTok = stream.consumeToken();
identifier.addChild(inTok);
WalkComment.walkComment(stream, inTok);
Expand Down
8 changes: 5 additions & 3 deletions src/tokentree/walk/WalkStatement.hx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class WalkStatement {
}
return;
}
case IntInterval(_):
case IntInterval(_) | Spread:
wantMore = true;
case Const(CIdent("final")) | Kwd(_):
if (walkKeyword(stream, parent)) wantMore = true;
Expand Down Expand Up @@ -107,7 +107,7 @@ class WalkStatement {
WalkSharp.walkSharp(stream, parent, walkStatement);
walkStatementContinueAfterSharp(stream, parent);
return;
case Dot:
case Dot | QuestionDot:
wantMore = true;
case DblDot:
switch (parent.tok) {
Expand Down Expand Up @@ -158,7 +158,7 @@ class WalkStatement {
public static function walkStatementContinue(stream:TokenStream, parent:TokenTree) {
if (!stream.hasMore()) return;
switch (stream.token()) {
case Dot:
case Dot | QuestionDot:
walkStatementWithoutSemicolon(stream, parent);
case DblDot:
walkDblDot(stream, parent);
Expand Down Expand Up @@ -206,6 +206,8 @@ class WalkStatement {
walkStatementContinue(stream, parent);
default:
}
case Spread:
walkStatementWithoutSemicolon(stream, parent);
default:
}
}
Expand Down

0 comments on commit e1bcea4

Please sign in to comment.