Skip to content

Commit 76636c8

Browse files
authored
Add support for class renaming via as keyword (#136)
1 parent bcd421b commit 76636c8

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

hscript/Expr.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ enum Error {
121121

122122
enum ModuleDecl {
123123
DPackage( path : Array<String> );
124-
DImport( path : Array<String>, ?everything : Bool );
124+
DImport( path : Array<String>, ?everything : Bool, ?name : String );
125125
DClass( c : ClassDecl );
126126
DTypedef( c : TypeDecl );
127127
}

hscript/Parser.hx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,8 +1169,18 @@ class Parser {
11691169
unexpected(t);
11701170
}
11711171
}
1172+
var name = null;
1173+
if ( maybe(TId("as")) && !star) {
1174+
var t = token();
1175+
switch( t ) {
1176+
case TId(id):
1177+
name = id;
1178+
default:
1179+
unexpected(t);
1180+
}
1181+
}
11721182
ensure(TSemicolon);
1173-
return DImport(path, star);
1183+
return DImport(path, star, name);
11741184
case "class":
11751185
var name = getIdent();
11761186
var params = parseParams();

0 commit comments

Comments
 (0)