diff --git a/.github/workflows/haxeparser.yml b/.github/workflows/haxeparser.yml index f22ce46..66b2eb2 100644 --- a/.github/workflows/haxeparser.yml +++ b/.github/workflows/haxeparser.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - haxe-version: ['4.3.1', 'nightly'] + haxe-version: ['4.3.4', 'nightly'] steps: - name: Checkout sources uses: actions/checkout@v1 diff --git a/.haxerc b/.haxerc index 974487a..b6edbfa 100644 --- a/.haxerc +++ b/.haxerc @@ -1,4 +1,4 @@ { - "version": "bdd7bf4", + "version": "569e52e", "resolveLibs": "scoped" } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 4632d42..9d71ff3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,8 +10,10 @@ "test-adapter" ], "editor.codeActionsOnSave": { - "source.organizeImports": false, - "source.sortImports": false + "source.organizeImports": "never", + "source.sortImports": "never" }, - "haxe.enableExtendedIndentation": true + "haxe.enableExtendedIndentation": true, + "haxe.enableCompilationServer": false, + "editor.inlayHints.enabled": "off" } diff --git a/haxe_libraries/hxparse.hxml b/haxe_libraries/hxparse.hxml index a802671..9394da3 100644 --- a/haxe_libraries/hxparse.hxml +++ b/haxe_libraries/hxparse.hxml @@ -1,3 +1,3 @@ -# @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 \ No newline at end of file +# @install: lix --silent download "gh://github.com/simn/hxparse#876070ec62a4869de60081f87763e23457a3bda8" into hxparse/4.3.0/github/876070ec62a4869de60081f87763e23457a3bda8 +-cp ${HAXE_LIBCACHE}/hxparse/4.3.0/github/876070ec62a4869de60081f87763e23457a3bda8/src +-D hxparse=4.3.0 \ No newline at end of file diff --git a/haxe_libraries/test-adapter.hxml b/haxe_libraries/test-adapter.hxml index 2fde4ca..2551a21 100644 --- a/haxe_libraries/test-adapter.hxml +++ b/haxe_libraries/test-adapter.hxml @@ -1,5 +1,5 @@ -# @install: lix --silent download "haxelib:/test-adapter#2.0.5" into test-adapter/2.0.5/haxelib +# @install: lix --silent download "haxelib:/test-adapter#2.0.7" into test-adapter/2.0.7/haxelib -lib json2object --cp ${HAXE_LIBCACHE}/test-adapter/2.0.5/haxelib/ --D test-adapter=2.0.5 +-cp ${HAXE_LIBCACHE}/test-adapter/2.0.7/haxelib/ +-D test-adapter=2.0.7 --macro _testadapter.Macro.init() \ No newline at end of file diff --git a/haxe_libraries/utest.hxml b/haxe_libraries/utest.hxml index 4bb6be7..f077685 100644 --- a/haxe_libraries/utest.hxml +++ b/haxe_libraries/utest.hxml @@ -1,5 +1,4 @@ -# @install: lix --silent download "gh://github.com/haxe-utest/utest#5de48a964ca75c8e6321ac9706346a24958af2a4" into utest/1.13.2/github/5de48a964ca75c8e6321ac9706346a24958af2a4 --cp ${HAXE_LIBCACHE}/utest/1.13.2/github/5de48a964ca75c8e6321ac9706346a24958af2a4/src --D utest=1.13.2 ---macro utest.utils.Macro.checkHaxe() +# @install: lix --silent download "gh://github.com/haxe-utest/utest#bdb5fec4b8e77d9a3c079d9cfb108f29f153721a" into utest/2.0.0-alpha/github/bdb5fec4b8e77d9a3c079d9cfb108f29f153721a +-cp ${HAXE_LIBCACHE}/utest/2.0.0-alpha/github/bdb5fec4b8e77d9a3c079d9cfb108f29f153721a/src +-D utest=2.0.0-alpha --macro utest.utils.Macro.importEnvSettings() diff --git a/src/haxeparser/Data.hx b/src/haxeparser/Data.hx index 5638f5e..926cd9f 100644 --- a/src/haxeparser/Data.hx +++ b/src/haxeparser/Data.hx @@ -241,7 +241,7 @@ typedef Definition = { enum TypeDef { EClass(d:Definition>); EEnum(d:Definition>); - ETypedef(d:Definition); + ETypedef(d:Definition); EAbstract(a:Definition>); EStatic(s:Definition); EImport(sl:Array<{pack:String, pos:Position}>, mode:ImportMode); @@ -277,6 +277,11 @@ enum EnumFlag { EExtern; } +enum TypedefFlag { + TDPrivate; + TDExtern; +} + enum StaticFlag { SDynamic; SFinal; diff --git a/src/haxeparser/DefinitionConverter.hx b/src/haxeparser/DefinitionConverter.hx index 963a560..d3a0f38 100644 --- a/src/haxeparser/DefinitionConverter.hx +++ b/src/haxeparser/DefinitionConverter.hx @@ -56,7 +56,7 @@ class DefinitionConverter { return def; } - static function convertTypedef(t:Definition) { + static function convertTypedef(t:Definition) { var def = getGeneralDefinition(t); def.kind = TDAlias(t.data); return def; diff --git a/src/haxeparser/HaxeLexer.hx b/src/haxeparser/HaxeLexer.hx index c77763e..ca914d9 100644 --- a/src/haxeparser/HaxeLexer.hx +++ b/src/haxeparser/HaxeLexer.hx @@ -50,6 +50,7 @@ class HaxeLexer extends Lexer implements hxparse.RuleBuilder { static var integer_digits = '([0-9](_?[0-9])*)+'; static var integer = '([1-9](_?[0-9])*)|0'; static var hex_digits = '([0-9a-fA-F](_?[0-9a-fA-F])*)+'; + static var bin_digits = '([01](_?[01])*)+'; static var integer_suffix = "(_?[iu](([1-9](_?[0-9])*)|0)+)?"; static var float_suffix = "(_?f(([1-9](_?[0-9])*)|0)+)?"; @@ -73,6 +74,7 @@ class HaxeLexer extends Lexer implements hxparse.RuleBuilder { #end }, "0x" + hex_digits + integer_suffix => mk(lexer, splitIntSuffix(lexer.current)), + "0b" + bin_digits + integer_suffix => mk(lexer, splitIntSuffix(lexer.current)), integer + integer_suffix => mk(lexer, splitIntSuffix(lexer.current)), integer + float_suffix => mk(lexer, splitFloatSuffix(lexer.current)), integer + "\\." + integer_digits + float_suffix => mk(lexer, splitFloatSuffix(lexer.current)), @@ -95,9 +97,7 @@ class HaxeLexer extends Lexer implements hxparse.RuleBuilder { "<<=" => mk(lexer,Binop(OpAssignOp(OpShl))), "|\\|=" => mk(lexer,Binop(OpAssignOp(OpBoolOr))), "&&=" => mk(lexer,Binop(OpAssignOp(OpBoolAnd))), - #if (haxe >= version("4.3.0-rc.1")) "?\\?=" => mk(lexer,Binop(OpAssignOp(OpNullCoal))), - #end "==" => mk(lexer,Binop(OpEq)), "!=" => mk(lexer,Binop(OpNotEq)), "<=" => mk(lexer,Binop(OpLte)), @@ -131,9 +131,7 @@ class HaxeLexer extends Lexer implements hxparse.RuleBuilder { "}" => mk(lexer, BrClose), "\\(" => mk(lexer, POpen), "\\)" => mk(lexer, PClose), - #if (haxe >= version("4.3.0-rc.1")) "?\\?" => mk(lexer,Binop(OpNullCoal)), - #end "?" => mk(lexer, Question), "@" => mk(lexer, At), '"' => { diff --git a/src/haxeparser/HaxeParser.hx b/src/haxeparser/HaxeParser.hx index 74899cf..9e8d69b 100644 --- a/src/haxeparser/HaxeParser.hx +++ b/src/haxeparser/HaxeParser.hx @@ -50,17 +50,10 @@ class HaxeCondParser extends hxparse.Parser, Tok parseMacroIdent(allowOp, t, p); case [{tok:Const(CString(s, qs)), pos:p}]: {tk:None, expr:{expr:EConst(CString(s, qs)), pos:p}}; - #if (haxe >= version("4.3.0-rc.1")) case [{tok:Const(CInt(i, s)), pos:p}]: {tk:None, expr:{expr:EConst(CInt(i, s)), pos:p}}; case [{tok:Const(CFloat(f, s)), pos:p}]: {tk:None, expr:{expr:EConst(CFloat(f, s)), pos:p}}; - #else - case [{tok:Const(CInt(i)), pos:p}]: - {tk:None, expr:{expr:EConst(CInt(i)), pos:p}}; - case [{tok:Const(CFloat(f)), pos:p}]: - {tk:None, expr:{expr:EConst(CFloat(f)), pos:p}}; - #end case [{tok:Kwd(k), pos:p}]: parseMacroIdent(allowOp, HaxeParser.keywordString(k), p); case [{tok:Unop(op), pos:p}, o = parseMacroCond(allowOp)]: @@ -93,13 +86,8 @@ class HaxeCondParser extends hxparse.Parser, Tok function exprNext(e1:Expr):Expr { return switch stream { - #if (haxe >= version("4.3.0-rc.1")) case [{tok:Dot, pos:p}, e = parseField(e1, Normal, p)]: e; case [{tok:QuestionDot, pos:p}, e = parseField(e1, Safe, p)]: e; - #else - case [{tok:Dot, pos:p}, e = parseField(e1, p)]: e; - case [{tok:QuestionDot, pos:p}, e = parseField(e1, p)]: e; - #end case [{tok:POpen, pos:_}]: switch stream { case [params = parseCallParams(), {tok:PClose, pos:p2}]: @@ -138,7 +126,6 @@ class HaxeCondParser extends hxparse.Parser, Tok } } - #if (haxe >= version("4.3.0-rc.1")) function parseField(e1, efk, p) { return switch stream { case [{tok:Kwd(KwdMacro), pos:p2}]: @@ -163,32 +150,6 @@ class HaxeCondParser extends hxparse.Parser, Tok } } } - #else - function parseField(e1, p) { - return switch stream { - case [{tok:Kwd(KwdMacro), pos:p2}]: - exprNext({expr:EField(e1,"macro"), pos:HaxeParser.punion(e1.pos,p2)}); - case [{tok:Kwd(KwdExtern), pos:p2}]: - exprNext({expr:EField(e1,"extern"), pos:HaxeParser.punion(e1.pos,p2)}); - case [{tok:Kwd(KwdFunction), pos:p2}]: - exprNext({expr:EField(e1,"function"), pos:HaxeParser.punion(e1.pos,p2)}); - case [{tok:Kwd(KwdNew), pos:p2}]: - exprNext({expr:EField(e1,"new"), pos:HaxeParser.punion(e1.pos,p2)}); - case [{tok:Kwd(k), pos:p2}]: - exprNext({expr:EField(e1,KeywordPrinter.toString(k)), pos:HaxeParser.punion(e1.pos,p2)}); - case [{tok:Const(CIdent(f)), pos:p2}]: - exprNext({expr:EField(e1,f), pos:HaxeParser.punion(e1.pos,p2)}); - case [{tok:Dollar(v), pos:p2}]: - exprNext({expr:EField(e1, "$" + v), pos:HaxeParser.punion(e1.pos, p2)}); - case _: - switch(e1) { - case {expr: EConst(CInt(v)), pos:p2} if (p2.max == p.min): - exprNext({expr:EConst(CFloat(v + ".")), pos:HaxeParser.punion(p,p2)}); - case _: unexpected(); - } - } - } - #end function parseCallParams() { var ret = []; @@ -502,9 +463,7 @@ class HaxeParser extends hxparse.Parser implements hxpar case OpAdd | OpSub : {p: 3, left: left}; case OpShl | OpShr | OpUShr : {p: 4, left: left}; case OpOr | OpAnd | OpXor : {p: 5, left: left}; - #if (haxe >= version("4.3.0-rc.1")) case OpNullCoal: {p: 6, left: left}; - #end case OpEq | OpNotEq | OpGt | OpLt | OpGte | OpLte : {p: 7, left: left}; case OpInterval : {p: 8, left: left}; case OpBoolAnd : {p: 9, left: left}; @@ -562,17 +521,10 @@ class HaxeParser extends hxparse.Parser implements hxpar { expr: ETernary(makeUnop(op, e1, p1), e2, e3), pos:punion(p1,e.pos)}; case EIs(e, t): { expr: EIs(makeUnop(op, e, p1), t), pos:punion(p1, e.pos)}; - #if (haxe >= version("4.3.0-rc.1")) case EConst(CInt(v, s)) if (op.match(OpNeg)): { expr: EConst(CInt(neg(v), s)), pos:punion(p1, e.pos)}; case EConst(CFloat(v, s)) if (op.match(OpNeg)): { expr: EConst(CFloat(neg(v), s)), pos:punion(p1, e.pos)}; - #else - case EConst(CInt(v)) if (op.match(OpNeg)): - { expr: EConst(CInt(neg(v))), pos:punion(p1, e.pos)}; - case EConst(CFloat(v)) if (op.match(OpNeg)): - { expr: EConst(CFloat(neg(v))), pos:punion(p1, e.pos)}; - #end case _: { expr: EUnop(op,false,e), pos:punion(p1,e.pos)}; } @@ -734,7 +686,7 @@ class HaxeParser extends hxparse.Parser implements hxpar } } - function parseAbstract (doc, meta, flags:Array<{c:ClassFlag, e:EnumFlag, a:haxeparser.AbstractFlag, s:StaticFlag, pos:Position}>, p1) { + function parseAbstract (doc, meta, flags:Array<{c:ClassFlag, e:EnumFlag, a:haxeparser.AbstractFlag, s:StaticFlag, t:TypedefFlag, pos:Position}>, p1) { return switch stream { case [name = typeName(), tl = parseConstraintParams(), st = parseAbstractSubtype(), sl = parseRepeat(parseAbstractRelations)]: var fl = switch stream { @@ -756,7 +708,7 @@ class HaxeParser extends hxparse.Parser implements hxpar } } - function parseClassContent(doc, meta, flags:Array<{c:ClassFlag, e:EnumFlag, a:haxeparser.AbstractFlag, s:StaticFlag, pos:Position}>, n, p1) { + function parseClassContent(doc, meta, flags:Array<{c:ClassFlag, e:EnumFlag, a:haxeparser.AbstractFlag, s:StaticFlag, t:TypedefFlag, pos:Position}>, n, p1) { var name = typeName(); var tl = parseConstraintParams(); var hl = parseRepeat(parseClassHerit); @@ -831,7 +783,7 @@ class HaxeParser extends hxparse.Parser implements hxpar } case [{tok:Kwd(KwdEnum), pos:p1}]: switch stream { - case [{tok:Kwd(KwdAbstract), pos:p1}, a = parseAbstract(doc, meta, c.concat([{{c:null, e:null, a:AbEnum, s:null, pos:null}}]), p1)]: + case [{tok:Kwd(KwdAbstract), pos:p1}, a = parseAbstract(doc, meta, c.concat([{{c:null, e:null, a:AbEnum, s:null, t:null, pos:null}}]), p1)]: { decl: a.decl, pos: punion(p1, a.pos)}; case [name = typeName(), tl = parseConstraintParams(), {tok:BrOpen}, l = parseRepeat(parseEnum), {tok:BrClose, pos: p2}]: {decl: EEnum({ @@ -855,7 +807,7 @@ class HaxeParser extends hxparse.Parser implements hxpar doc: doc, meta: meta, params: tl, - flags: c.map(function(i) return i.e), + flags: c.map(function(i) return i.t), data: t }), pos: punion(p1,p2)}; @@ -1027,18 +979,18 @@ class HaxeParser extends hxparse.Parser implements hxpar return parseRepeat(parseClassField); } - function parseCommonFlags():Array<{c:ClassFlag, e:EnumFlag, a:haxeparser.AbstractFlag, s:StaticFlag, pos:Position}> { + function parseCommonFlags():Array<{c:ClassFlag, e:EnumFlag, a:haxeparser.AbstractFlag, s:StaticFlag, t:TypedefFlag, pos:Position}> { return switch stream { - case [{tok:Kwd(KwdPrivate), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:HPrivate, e:EPrivate, a:AbPrivate, s:SPrivate, pos:p}); - case [{tok:Kwd(KwdExtern), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:HExtern, e:EExtern, a:AbExtern, s:null, pos:p}); - case [{tok:Kwd(KwdFinal), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:HFinal, e:null, a:null, s:SFinal, pos:p}); - case [{tok:Kwd(KwdMacro), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:null, e:null, a:null, s:SMacro, pos:p}); - case [{tok:Kwd(KwdDynamic), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:null, e:null, a:null, s:SDynamic, pos:p}); - case [{tok:Kwd(KwdInline), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:null, e:null, a:null, s:SInline, pos:p}); + case [{tok:Kwd(KwdPrivate), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:HPrivate, e:EPrivate, a:AbPrivate, s:SPrivate, t:TDPrivate, pos:p}); + case [{tok:Kwd(KwdExtern), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:HExtern, e:EExtern, a:AbExtern, s:null, t:TDExtern, pos:p}); + case [{tok:Kwd(KwdFinal), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:HFinal, e:null, a:null, s:SFinal, t:null, pos:p}); + case [{tok:Kwd(KwdMacro), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:null, e:null, a:null, s:SMacro, t:null, pos:p}); + case [{tok:Kwd(KwdDynamic), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:null, e:null, a:null, s:SDynamic, t:null, pos:p}); + case [{tok:Kwd(KwdInline), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:null, e:null, a:null, s:SInline, t:null, pos:p}); // included for completeness, there are no Public / Static flags - // case [{tok:Kwd(KwdPublic), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:null, e:null, a:null, s:null, pos:p}); - // case [{tok:Kwd(KwdStatic), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:null, e:null, a:null, s:null, pos:p}); - case [{tok:Kwd(KwdOverload), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:null, e:null, a:null, s:SOverload, pos:p}); + // case [{tok:Kwd(KwdPublic), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:null, e:null, a:null, s:null, t:null, pos:p}); + // case [{tok:Kwd(KwdStatic), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:null, e:null, a:null, s:null, t:null, pos:p}); + case [{tok:Kwd(KwdOverload), pos:p}, l = parseCommonFlags()]: aunshift(l, {c:null, e:null, a:null, s:SOverload, t:null, pos:p}); case _: []; } } @@ -1602,7 +1554,6 @@ class HaxeParser extends hxparse.Parser implements hxpar case _: unexpected(); } - #if (haxe >= version("4.3.0-rc.1")) case [{tok:Kwd(KwdStatic), pos:p}]: switch stream { case [e = parseBlockVar()]: @@ -1615,7 +1566,6 @@ class HaxeParser extends hxparse.Parser implements hxpar case _: unexpected(); } - #end case [e = expr(), _ = semicolon()]: e; } } @@ -1779,11 +1729,7 @@ class HaxeParser extends hxparse.Parser implements hxpar } case [{tok:Kwd(KwdMacro), pos:p}]: switch stream { - #if (haxe >= version("4.3.0-rc.1")) case [{tok:Dot, pos:pd}, e = parseField({expr:EConst(CIdent("macro")), pos:p}, Normal, pd)]: e; - #else - case [{tok:Dot, pos:pd}, e = parseField({expr:EConst(CIdent("macro")), pos:p}, pd)]: e; - #end case [e = parseMacroExpr(p)]: e; } case [{tok:Kwd(KwdVar), pos: p1}, v = parseVarDecl(false)]: { expr: EVars([v]), pos: p1}; @@ -1893,11 +1839,7 @@ class HaxeParser extends hxparse.Parser implements hxpar { expr: ESwitch(e,cases.cases,cases.def), pos:punion(p1,p2)}; case [{tok:Kwd(KwdTry), pos:p1}, e = expr(), cl = parseRepeat(parseCatch)]: { expr: ETry(e,cl), pos:p1}; - #if (haxe >= version("4.3.0-rc.1")) case [{tok:IntInterval(i), pos:p1}, e2 = expr()]: makeBinop(OpInterval,{expr:EConst(CInt(i, null)), pos:p1}, e2); - #else - case [{tok:IntInterval(i), pos:p1}, e2 = expr()]: makeBinop(OpInterval,{expr:EConst(CInt(i)), pos:p1}, e2); - #end case [{tok:Kwd(KwdUntyped), pos:p1}, e = expr()]: { expr: EUntyped(e), pos:punion(p1,e.pos)}; case [{tok:Dollar(v), pos:p}]: exprNext({expr:EConst(CIdent("$" + v)), pos:p}); case [{tok:Kwd(KwdInline), pos:p}, e = secureExpr()]: makeMeta(":inline", [], e, p); @@ -1916,13 +1858,8 @@ class HaxeParser extends hxparse.Parser implements hxpar exprNext({expr: EMeta({name:n, params:[], pos:e1.pos},eparam), pos:punion(p1,p2)}); case _: throw false; } - #if (haxe >= version("4.3.0-rc.1")) case [{tok:Dot, pos:p}, e = parseField(e1, Normal, p)]: e; case [{tok:QuestionDot, pos:p}, e = parseField(e1, Safe, p)]: e; - #else - case [{tok:Dot, pos:p}, e = parseField(e1, p)]: e; - case [{tok:QuestionDot, pos:p}, e = parseField(e1, p)]: e; - #end case [{tok:POpen, pos:_}]: switch stream { case [params = parseCallParams(), {tok:PClose, pos:p2}]: @@ -1971,7 +1908,6 @@ class HaxeParser extends hxparse.Parser implements hxpar } - #if (haxe >= version("4.3.0-rc.1")) function parseField(e1, efk, p) { return switch stream { case [{tok:Kwd(KwdMacro), pos:p2}]: @@ -1996,32 +1932,6 @@ class HaxeParser extends hxparse.Parser implements hxpar } } } - #else - function parseField(e1, p) { - return switch stream { - case [{tok:Kwd(KwdMacro), pos:p2}]: - exprNext({expr:EField(e1, "macro"), pos:punion(e1.pos,p2)}); - case [{tok:Kwd(KwdExtern), pos:p2}]: - exprNext({expr:EField(e1, "extern"), pos:punion(e1.pos, p2)}); - case [{tok:Kwd(KwdFunction), pos:p2}]: - exprNext({expr:EField(e1, "function"), pos:punion(e1.pos, p2)}); - case [{tok:Kwd(KwdNew), pos:p2}]: - exprNext({expr:EField(e1, "new"), pos:punion(e1.pos, p2)}); - case [{tok:Kwd(k), pos:p2}]: - exprNext({expr:EField(e1, KeywordPrinter.toString(k)), pos:punion(e1.pos, p2)}); - case [{tok:Const(CIdent(f)), pos:p2}]: - exprNext({expr:EField(e1, f), pos:punion(e1.pos, p2)}); - case [{tok:Dollar(v), pos:p2}]: - exprNext({expr:EField(e1, "$" + v), pos:punion(e1.pos, p2)}); - case _: - switch(e1) { - case {expr: EConst(CInt(v)), pos:p2} if (p2.max == p.min): - exprNext({expr:EConst(CFloat(v + ".")), pos:punion(p, p2)}); - case _: unexpected(); - } - } - } - #end function parseGuard() { return switch stream { @@ -2171,9 +2081,7 @@ private class Reificator{ case OpInterval: return op("OpInterval"); case OpArrow: return op("OpArrow"); case OpIn: return op("OpIn"); - #if (haxe >= version("4.3.0-rc.1")) case OpNullCoal: return op("OpNullCoal"); - #end } } @@ -2445,18 +2353,14 @@ private class Reificator{ var type = vv.type; var expr = vv.expr; var isFinal = vv.isFinal; - #if (haxe >= version("4.3.0-rc.1")) var isStatic = vv.isStatic; - #end var meta = vv.meta; var fields:Array<{field:String, expr:Expr, quotes:QuoteStatus}> = [ {field:"name", expr:toString(name, p), quotes:Unquoted}, {field:"type", expr:toOpt(toCType, type, p), quotes:Unquoted}, {field:"expr", expr:toOpt(toExpr, expr, p), quotes:Unquoted}, {field:"isFinal", expr:toBool(isFinal, p), quotes:Unquoted}, - #if (haxe >= version("4.3.0-rc.1")) {field:"isStatic", expr:toBool(isStatic, p), quotes:Unquoted}, - #end {field:"meta", expr:toMeta(meta, p), quotes:Unquoted} ]; return toObj(fields, p); @@ -2513,10 +2417,6 @@ private class Reificator{ expr("EIs", [loop(e), toCType(ct, p)]); case EDisplay(e, dk): expr("EDisplay", [loop(e), toDisplaykind(dk, p)]); - #if (haxe < version("4.3.0-rc.1")) - case EDisplayNew(t): - expr("EDisplayNew", [toTPath(t, p)]); - #end case ETernary(e1, e2, e3): expr("ETernary", [loop(e1), loop(e2), loop(e3)]); case ECheckType(e1, ct): @@ -2681,17 +2581,9 @@ private class Reificator{ function mapConstant(c:haxeparser.Constant, p:haxe.macro.Position):haxe.macro.Expr { var constant:haxe.macro.Expr.Constant = switch (c) { case CInt(v, s): - #if (haxe >= version("4.3.0-rc.1")) CInt(v, s); - #else - CInt(v); - #end case CFloat(f, s): - #if (haxe >= version("4.3.0-rc.1")) CFloat(f, s); - #else - CFloat(f); - #end case CIdent(s): CIdent(s); case CString(s, kind): diff --git a/test/Test.hx b/test/Test.hx index 60d1bea..61a5e68 100644 --- a/test/Test.hx +++ b/test/Test.hx @@ -47,7 +47,6 @@ class Test implements ITest { eeq("13.14E-12"); } - #if (haxe >= version("4.3.0-rc.1")) function testIntSuffixes() { eeq("7i32"); eeq("-7i32"); @@ -81,6 +80,12 @@ class Test implements ITest { eeq("0x12_0"); eeq("0x1_2_0"); + #if (haxe >= version("5.0.0-alpha.1")) + // bin int + eeq("0b11_0"); + eeq("0b1_1_0"); + #end + // normal float eeq("12.3_4"); eeq("1_2.34"); @@ -107,6 +112,12 @@ class Test implements ITest { eeq("0x12_0i32"); eeq("0x1_2_0i32"); + #if (haxe >= version("5.0.0-alpha.1")) + // bin int + eeq("0b11_0i32"); + eeq("0b1_1_0i32"); + #end + // normal float eeq("12.3_4f64"); eeq("1_2.34f64"); @@ -130,6 +141,12 @@ class Test implements ITest { eeq("0x12_0_i32", "0x12_0i32"); eeq("0x1_2_0_i32", "0x1_2_0i32"); + #if (haxe >= version("5.0.0-alpha.1")) + // bin int + eeq("0b11_0_i32", "0b11_0i32"); + eeq("0b1_1_0_i32", "0b1_1_0i32"); + #end + // normal float eeq("12.3_4_f64", "12.3_4f64"); eeq("1_2.34_f64", "1_2.34f64"); @@ -153,6 +170,28 @@ class Test implements ITest { eeq("-1_2e-3_4_f64", "-1_2e-3_4f64"); eeq("-1_2.3e-4_5_f64", "-1_2.3e-4_5f64"); } + + #if (haxe >= version("5.0.0-alpha.1")) + function testIntLiterals() { + eeq("0xF"); + eeq("0xFF"); + eeq("0x12345678"); + eeq("0x09ABCDEF"); + + eeq("0b0"); + eeq("0b1"); + eeq("0b10"); + eeq("0b1000"); + eeq("0b11111111111111111111111111111111"); + } + + public function testBinSuffixes() { + eeq("0b11111111111111111111111111111111i32"); + eeq("0b11111111111111111111111111111111u32"); + eeq("0b11111111111111111111111111111111i64"); + eeq("0b1111111111111111111111111111111111111111111111111111111111111111i64"); + eeq("0b0111111111111111111111111111111111111111111111111111111111111111i64"); + } #end function testArrayAccess() { @@ -184,9 +223,7 @@ class Test implements ITest { eeq("1 % 1"); eeq("1 ... 1"); eeq("1 => 1"); - #if (haxe >= version("4.3.0-rc.1")) eeq("1 ?? 1"); - #end } function testAssignOps() { @@ -200,9 +237,7 @@ class Test implements ITest { eeq("1 ^= 1"); eeq("1 &&= 1"); eeq("1 ||= 1"); - #if (haxe >= version("4.3.0-rc.1")) eeq("1 ??= 1"); - #end eeq("1 <<= 1"); eeq("1 >>= 1"); eeq("1 >>>= 1"); @@ -259,9 +294,7 @@ class Test implements ITest { eeq("var x"); eeq("var x = 1"); eeq("var gen:Gen = null"); - #if (haxe >= version("4.3.0-rc.1")) eeq("var gen:Gen<-1i64> = null"); - #end } function testFunction() { @@ -330,9 +363,7 @@ class Test implements ITest { paeq("a => b in c", "(a => (b in c))"); paeq("a = b in c", "(a = (b in c))"); paeq("a += b in c", "(a += (b in c))"); - #if (haxe >= version("4.3.0-rc.1")) paeq("a ?? b in c", "(a ?? (b in c))"); - #end } function testIf() { @@ -424,7 +455,12 @@ class Test implements ITest { peq("class C extends A implements B implements C {}"); peq("class C {}"); peq("class C {}"); + #if (haxe >= version("5.0.0-alpha.1")) + peq("class C {}"); + peq("class C {}", "class C {}"); + #else peq("class C {}"); + #end peq("abstract class C {}"); } @@ -450,7 +486,12 @@ class Test implements ITest { peq("enum E {}"); peq("enum E {}"); peq("enum E {}"); + #if (haxe >= version("5.0.0-alpha.1")) + peq("enum E {}"); + peq("enum E {}", "enum E {}"); + #else peq("enum E {}"); + #end } function testEnumField() { @@ -558,17 +599,10 @@ class Test implements ITest { eeq("macro $i{a};", '({ expr : EConst(CIdent(a)), pos : { file : "main:0", min : 8, max : 11 } } : haxe.macro.Expr)',fakePosInfos); //eeq("macro $p{a};", '',fakePosInfos); // ??? //eeq("macro $v{a};", '',fakePosInfos); // ??? - #if (haxe >= version("4.3.0-rc.1")) eeq("macro var a;", '({ expr : EVars([{ name : "a", type : null, expr : null, isFinal : false, isStatic : false, meta : [] }]), pos : { file : "main:0", min : 6, max : 9 } } : haxe.macro.Expr)',fakePosInfos); eeq("macro final a;", '({ expr : EVars([{ name : "a", type : null, expr : null, isFinal : true, isStatic : false, meta : [] }]), pos : { file : "main:0", min : 6, max : 11 } } : haxe.macro.Expr)',fakePosInfos); eeq("macro final @meta a;", '({ expr : EVars([{ name : "a", type : null, expr : null, isFinal : true, isStatic : false, meta : [{ name : "meta", params : [], pos : { file : "main:0", min : 12, max : 17 } }] }]), pos : { file : "main:0", min : 6, max : 11 } } : haxe.macro.Expr)',fakePosInfos); eeq("macro @meta var a;", '({ expr : EMeta({ name : "meta", params : [], pos : { file : "main:0", min : 6, max : 15 } }, { expr : EVars([{ name : "a", type : null, expr : null, isFinal : false, isStatic : false, meta : [] }]), pos : { file : "main:0", min : 12, max : 15 } }), pos : { file : "main:0", min : 6, max : 15 } } : haxe.macro.Expr)',fakePosInfos); - #else - eeq("macro var a;", '({ expr : EVars([{ name : "a", type : null, expr : null, isFinal : false, meta : [] }]), pos : { file : "main:0", min : 6, max : 9 } } : haxe.macro.Expr)',fakePosInfos); - eeq("macro final a;", '({ expr : EVars([{ name : "a", type : null, expr : null, isFinal : true, meta : [] }]), pos : { file : "main:0", min : 6, max : 11 } } : haxe.macro.Expr)',fakePosInfos); - eeq("macro final @meta a;", '({ expr : EVars([{ name : "a", type : null, expr : null, isFinal : true, meta : [{ name : "meta", params : [], pos : { file : "main:0", min : 12, max : 17 } }] }]), pos : { file : "main:0", min : 6, max : 11 } } : haxe.macro.Expr)',fakePosInfos); - eeq("macro @meta var a;", '({ expr : EMeta({ name : "meta", params : [], pos : { file : "main:0", min : 6, max : 15 } }, { expr : EVars([{ name : "a", type : null, expr : null, isFinal : false, meta : [] }]), pos : { file : "main:0", min : 12, max : 15 } }), pos : { file : "main:0", min : 6, max : 15 } } : haxe.macro.Expr)',fakePosInfos); - #end eeq("macro f();", '({ expr : ECall({ expr : EConst(CIdent("f")), pos : { file : "main:0", min : 6, max : 7 } }, []), pos : { file : "main:0", min : 6, max : 9 } } : haxe.macro.Expr)',fakePosInfos); eeq("macro :Array;", '(TPath({ pack : [], name : "Array", params : [] }) : haxe.macro.Expr.ComplexType)',fakePosInfos); @@ -779,7 +813,6 @@ class Test implements ITest { peq("var regex = ~/[\\u0000-\\u001F\\u007F-\\u009F\\u2000-\\u200D\\uFEFF]/g;"); } - #if (haxe >= version("4.3.0-rc.1")) function testDefaultTypeParams() { peq("class DefaultTPClass_y {}"); peq("class DefaultTPClass_yn {}"); @@ -828,8 +861,6 @@ class Test implements ITest { peq('var SRC = ;', 'var SRC = @:markup "";'); } - #end - function parseExpr(inputCode:String, ?p:haxe.PosInfos) { var parser = new haxeparser.HaxeParser(byte.ByteData.ofString(inputCode), '${p.methodName}:${p.lineNumber}'); for (key => value in defines) parser.define(key, value);