Skip to content

Commit

Permalink
updated haxeparser to support latest Haxe nightly syntax (#657)
Browse files Browse the repository at this point in the history
* updated haxeparser and tokentree to support latest Haxe nightly syntax
* only run tests on nightly because suffixes test fails on 4.2.5
  • Loading branch information
AlexHaxe authored Sep 14, 2022
1 parent 727e95b commit efbacf9
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
build:
strategy:
matrix:
haxe-version: ['4.0.5', '4.1.5', '4.2.5', 'nightly']
haxe-version: ['4.2.5', 'nightly']
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down Expand Up @@ -51,8 +51,10 @@ jobs:
- name: Build JSON schema
run: npx haxe buildSchema.hxml
- name: Run eval tests
if: (matrix.haxe-version == 'nightly')
run: npx haxe -D codecov_json test.hxml
- name: Run Java tests
if: (matrix.haxe-version == 'nightly')
run: npx haxe -D codecov_json testJava.hxml
- name: Run Node version with --check
run: node run.js -s . --check
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## dev branch / next version (1.x.x)

## version 1.14.2 (2022-09-14)

- Updated haxeparser to support latest Haxe nightly syntax ([#657](https://github.com/HaxeCheckstyle/haxe-formatter/issues/657))

## version 1.14.1 (2022-09-07)

- Improved support for inline markup ([#656](https://github.com/HaxeCheckstyle/haxe-formatter/issues/656))
Expand Down
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
6 changes: 3 additions & 3 deletions haxe_libraries/hxparse.hxml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# @install: lix --silent download "gh://github.com/Simn/hxparse#93f67419852e96daa2b81901c43a77e878c8c2bc" into hxparse/4.0.1/github/93f67419852e96daa2b81901c43a77e878c8c2bc
-cp ${HAXE_LIBCACHE}/hxparse/4.0.1/github/93f67419852e96daa2b81901c43a77e878c8c2bc/src
-D hxparse=4.0.1
# @install: lix --silent download "gh://github.com/simn/hxparse#32e376f80c4b0e999e9f3229947d4dac2138382b" into hxparse/4.0.1/github/32e376f80c4b0e999e9f3229947d4dac2138382b
-cp ${HAXE_LIBCACHE}/hxparse/4.0.1/github/32e376f80c4b0e999e9f3229947d4dac2138382b/src
-D hxparse=4.0.1
6 changes: 3 additions & 3 deletions haxe_libraries/tokentree.hxml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# @install: lix --silent download "haxelib:/tokentree#1.2.1" into tokentree/1.2.1/haxelib
-cp ${HAXE_LIBCACHE}/tokentree/1.2.1/haxelib/src
-D tokentree=1.2.1
# @install: lix --silent download "haxelib:/tokentree#1.2.3" into tokentree/1.2.3/haxelib
-cp ${HAXE_LIBCACHE}/tokentree/1.2.3/haxelib/src
-D tokentree=1.2.3
4 changes: 2 additions & 2 deletions haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"style"
],
"description": "A code formatter for Haxe",
"version": "1.14.1",
"releasenote": "improved support for inline markup - see CHANGELOG for details.",
"version": "1.14.2",
"releasenote": "updated haxeparser to support latest Haxe nightly syntax - see CHANGELOG for details.",
"contributors": [
"AlexHaxe",
"Gama11"
Expand Down
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": "@haxecheckstyle/haxe-formatter",
"version": "1.14.1",
"version": "1.14.2",
"description": "A code formatter for Haxe",
"repository": {
"type": "git",
Expand Down
6 changes: 4 additions & 2 deletions src/formatter/marker/MarkWhitespace.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MarkWhitespace extends MarkerBase {
}
case Binop(OpGt):
markGt(token);
case Binop(OpInterval):
case Spread | Binop(OpInterval):
markOpSpread(token);
case Binop(OpIn):
markIn(token);
Expand Down Expand Up @@ -203,7 +203,7 @@ class MarkWhitespace extends MarkerBase {
var prev:Null<TokenInfo> = getPreviousToken(token);
if (prev != null) {
switch (prev.token.tok) {
case POpen, BrOpen, BkOpen, IntInterval(_), Binop(OpInterval):
case POpen | BrOpen | BkOpen | IntInterval(_) | Spread | Binop(OpInterval):
policy = policy.remove(Before);
case PClose:
switch (TokenTreeCheckUtils.getPOpenType(prev.token)) {
Expand Down Expand Up @@ -760,6 +760,7 @@ class MarkWhitespace extends MarkerBase {
return;
case Dot:
case DblDot:
case QuestionDot:
case Arrow:
case Comma:
case BkOpen, BrOpen, POpen:
Expand All @@ -771,6 +772,7 @@ class MarkWhitespace extends MarkerBase {
case At:
case Eof:
return;
case Spread:
}
whitespace(token, Before);
}
Expand Down
169 changes: 169 additions & 0 deletions test/testcases/other/numeric_separator.hxtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{}

---

public function test() {
// normal int
eq(12_0, 120);
eq(1_2_0, 120);

// hex int
eq(0x12_0, 0x120);
eq(0x1_2_0, 0x120);

// normal float
feq(12.3_4, 12.34);
feq(1_2.34, 12.34);
feq(1_2.3_4, 12.34);

// dot float
feq(.3_4, .34);
feq(.3_4_5, .345);

// science float
feq(1_2e3_4, 12e34);
feq(1_2.3e4_5, 12.3e45);

// int but actually float
feq(1_2f64, 12f64);
}

public function testWithSuffix() {
// normal int
eq(12_0i32, 120i32);
eq(1_2_0i32, 120i32);

// hex int
eq(0x12_0i32, 0x120i32);
eq(0x1_2_0i32, 0x120i32);

// normal float
feq(12.3_4f64, 12.34f64);
feq(1_2.34f64, 12.34f64);
feq(1_2.3_4f64, 12.34f64);

// dot float
feq(.3_4f64, .34f64);
feq(.3_4_5f64, .345f64);

// science float
feq(1_2e3_4f64, 12e34f64);
feq(1_2.3e4_5f64, 12.3e45f64);
}

public function testJustBeforeSuffix() {
// normal int
eq(12_0_i32, 120i32);
eq(1_2_0_i32, 120i32);

// hex int
eq(0x12_0_i32, 0x120i32);
eq(0x1_2_0_i32, 0x120i32);

// normal float
feq(12.3_4_f64, 12.34f64);
feq(1_2.34_f64, 12.34f64);
feq(1_2.3_4_f64, 12.34f64);

// dot float
feq(.3_4_f64, .34f64);
feq(.3_4_5_f64, .345f64);

// science float
feq(1_2e3_4_f64, 12e34f64);
feq(1_2.3e4_5_f64, 12.3e45f64);

feq(1_2e-3_4_f64, 12e-34f64);
feq(1_2.3e-4_5_f64, 12.3e-45f64);
feq(1_2e+3_4_f64, 12e+34f64);
feq(1_2.3e+4_5_f64, 12.3e+45f64);

feq(-1_2e-3_4_f64, -12e-34f64);
feq(-1_2.3e-4_5_f64, -12.3e-45f64);
feq(-1_2e+3_4_f64, -12e+34f64);
feq(-1_2.3e+4_5_f64, -12.3e+45f64);
}

---

public function test() {
// normal int
eq(12_0, 120);
eq(1_2_0, 120);

// hex int
eq(0x12_0, 0x120);
eq(0x1_2_0, 0x120);

// normal float
feq(12.3_4, 12.34);
feq(1_2.34, 12.34);
feq(1_2.3_4, 12.34);

// dot float
feq(.3_4, .34);
feq(.3_4_5, .345);

// science float
feq(1_2e3_4, 12e34);
feq(1_2.3e4_5, 12.3e45);

// int but actually float
feq(1_2f64, 12f64);
}

public function testWithSuffix() {
// normal int
eq(12_0i32, 120i32);
eq(1_2_0i32, 120i32);

// hex int
eq(0x12_0i32, 0x120i32);
eq(0x1_2_0i32, 0x120i32);

// normal float
feq(12.3_4f64, 12.34f64);
feq(1_2.34f64, 12.34f64);
feq(1_2.3_4f64, 12.34f64);

// dot float
feq(.3_4f64, .34f64);
feq(.3_4_5f64, .345f64);

// science float
feq(1_2e3_4f64, 12e34f64);
feq(1_2.3e4_5f64, 12.3e45f64);
}

public function testJustBeforeSuffix() {
// normal int
eq(12_0i32, 120i32);
eq(1_2_0i32, 120i32);

// hex int
eq(0x12_0i32, 0x120i32);
eq(0x1_2_0i32, 0x120i32);

// normal float
feq(12.3_4f64, 12.34f64);
feq(1_2.34f64, 12.34f64);
feq(1_2.3_4f64, 12.34f64);

// dot float
feq(.3_4f64, .34f64);
feq(.3_4_5f64, .345f64);

// science float
feq(1_2e3_4f64, 12e34f64);
feq(1_2.3e4_5f64, 12.3e45f64);

feq(1_2e-3_4f64, 12e-34f64);
feq(1_2.3e-4_5f64, 12.3e-45f64);
feq(1_2e+3_4f64, 12e+34f64);
feq(1_2.3e+4_5f64, 12.3e+45f64);

feq(-1_2e-3_4f64, -12e-34f64);
feq(-1_2.3e-4_5f64, -12.3e-45f64);
feq(-1_2e+3_4f64, -12e+34f64);
feq(-1_2.3e+4_5f64, -12.3e+45f64);
}

0 comments on commit efbacf9

Please sign in to comment.