Skip to content

Commit

Permalink
[FORMAT] Improve spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyTy committed Jul 12, 2024
1 parent 7fc2266 commit a64e503
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 654 deletions.
9 changes: 0 additions & 9 deletions docs/target-haxe.md

This file was deleted.

208 changes: 0 additions & 208 deletions library/haxe/haxe.hexa

This file was deleted.

28 changes: 22 additions & 6 deletions source/server/format.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fun autoFormatWholeFile(file: String): String {
var tabStack = ['']
var tabCase = [false]
var depth = 0
let assignOp = [Token.Add, Token.Multiply, Token.Subtract]
let assignOp = [Token.Add, Token.Multiply, Token.Subtract, Token.BitwiseAnd, Token.BitwiseOr]
var parenthesis = -1000000

fun updateTab() {
Expand Down Expand Up @@ -124,26 +124,42 @@ fun autoFormatWholeFile(file: String): String {
lastToken == Token.Dot or
token == Token.Dot or

// `+=`
(token == Token.Assign and assignOp.includes(lastToken)) or

// `~123`
lastToken == Token.BitwiseNot or

// `(something`
lastToken == Token.CallOpen or
// `(`
(
token == Token.CallOpen and
(
// Keywords
lastToken != Token.KIn and
lastToken != Token.Add and
lastToken != Token.Subtract and
lastToken != Token.KReturn and
lastToken != Token.KIf and
lastToken != Token.KFun and
lastToken != Token.LogicalAnd and
lastToken != Token.LogicalOr and
lastToken != Token.KNew and
lastToken != Token.KNot and
lastToken != Token.KSwitch and
lastToken != Token.KWhile and
lastToken != Token.KDo and
lastToken != Token.KFor and
lastToken != Token.LogicalAnd and
lastToken != Token.LogicalOr and

// Operators
lastToken != Token.Assign and
lastToken != Token.Add and
lastToken != Token.Subtract and
lastToken != Token.BitwiseAnd and
lastToken != Token.BitwiseOr and
lastToken != Token.Comma and
lastToken != Token.Equal and
lastToken != Token.Unequal and
lastToken != Token.Question and

// `@demo()` but not `@demo ()`
not (
Expand All @@ -158,7 +174,7 @@ fun autoFormatWholeFile(file: String): String {
// @sds() TODO error () no args not allowed
token == Token.CallClose or

// `[]`
// `[`
lastToken == Token.IndexOpen or
(
token == Token.IndexOpen and
Expand Down
2 changes: 1 addition & 1 deletion source/targets/genC.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ class GenCxx {
if c.external {
if c.jsRequire != null {
// todo MAKE IT possible to use plain-c include's!
// like "declare" vs "deep extern declare" for Haxe
// like "declare" vs "deep extern declare"
out += '\n ' + '/*var ' + c.name + ' = require("' + c.jsRequire + '")*/'
continue
}
Expand Down
2 changes: 1 addition & 1 deletion source/targets/genCxx.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@
if (c.external) {
if (c.jsRequire != null) {
// todo MAKE IT possible to use plain-c include's!
// like "declare" vs "deep extern declare" for Haxe
// like "declare" vs "deep extern declare"
out += '\n ' + '/*var ' + c.name + ' = require("' + c.jsRequire + '")*/'
continue
}
Expand Down
Loading

0 comments on commit a64e503

Please sign in to comment.