From 531d7a92994aa7d98135edfd7ec459b35acc47de Mon Sep 17 00:00:00 2001 From: AlexHaxe Date: Wed, 2 Dec 2015 12:02:57 +0100 Subject: [PATCH] support for KwdExtern in package and import lines https://github.com/HaxeFoundation/haxe/blob/haxe-3.2.1/parser.ml#L526 https://github.com/HaxeFoundation/haxe/blob/haxe-3.2.1/parser.ml#L665-666 --- src/haxeparser/HaxeParser.hx | 3 +++ test/Test.hx | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/haxeparser/HaxeParser.hx b/src/haxeparser/HaxeParser.hx index 37d2140..a6037bc 100644 --- a/src/haxeparser/HaxeParser.hx +++ b/src/haxeparser/HaxeParser.hx @@ -448,6 +448,7 @@ class HaxeParser extends hxparse.Parser implements hxpar return switch stream { case [{tok:Const(CIdent(i))} && isLowerIdent(i)]: i; case [{tok:Kwd(KwdMacro)}]: "macro"; + case [{tok:Kwd(KwdExtern)}]: "extern"; } } @@ -598,6 +599,8 @@ class HaxeParser extends hxparse.Parser implements hxpar acc.push({pack:k,pos:p}); case [{tok:Kwd(KwdMacro), pos:p}]: acc.push({pack:"macro",pos:p}); + case [{tok:Kwd(KwdExtern), pos:p}]: + acc.push({pack:"extern",pos:p}); case [{tok:Binop(OpMult)}, {tok:Semicolon, pos:p2}]: return { decl: EImport(acc, IAll), diff --git a/test/Test.hx b/test/Test.hx index 8067068..664a940 100644 --- a/test/Test.hx +++ b/test/Test.hx @@ -256,6 +256,8 @@ class Test extends haxe.unit.TestCase { function testPackage() { assertEquals(0, parseFile("package;").pack.length); assertEquals(1, parseFile("package x;").pack.length); + assertEquals(2, parseFile("package haxe.macro;").pack.length); + assertEquals(2, parseFile("package haxe.extern;").pack.length); assertEquals(1, parseFile( "//test\n" + "package x;" @@ -486,4 +488,4 @@ class Test extends haxe.unit.TestCase { } assertEquals(whitespaceEreg.replace(expectedCode, ""), whitespaceEreg.replace(inputParsed, ""), p); } -} \ No newline at end of file +}