Skip to content

Commit b6799be

Browse files
Merge pull request #4 from KoloInDaCrib/class-name-override-funkin
[FEATURE] Class Renaming via `as`
2 parents 79b3906 + 0435566 commit b6799be

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
@@ -1170,8 +1170,18 @@ class Parser {
11701170
unexpected(t);
11711171
}
11721172
}
1173+
var name = null;
1174+
if ( maybe(TId("as")) && !star) {
1175+
var t = token();
1176+
switch( t ) {
1177+
case TId(id):
1178+
name = id;
1179+
default:
1180+
unexpected(t);
1181+
}
1182+
}
11731183
ensure(TSemicolon);
1174-
return DImport(path, star);
1184+
return DImport(path, star, name);
11751185
case "class":
11761186
var name = getIdent();
11771187
var params = parseParams();

0 commit comments

Comments
 (0)