Fixed: AS3 direct editation - Allow internal keyword on script traits (e.g. classes)

This commit is contained in:
Jindra Petřík
2025-05-31 13:02:34 +02:00
parent bc85daca85
commit 7588307dd0
3 changed files with 32 additions and 6 deletions

View File

@@ -1101,9 +1101,10 @@ public class ActionScript3Parser {
boolean isDynamic = false;
boolean isPublic = false;
boolean isNative = false;
boolean isInternal = false;
NamespaceItem ns = packageInternalNs;
List<ParsedSymbol> preSymbols = new ArrayList<>();
while (s.isType(SymbolType.FINAL, SymbolType.DYNAMIC, SymbolType.PUBLIC)) {
while (s.isType(SymbolType.FINAL, SymbolType.DYNAMIC, SymbolType.PUBLIC, SymbolType.INTERNAL)) {
if (s.type == SymbolType.FINAL) {
if (isFinal) {
throw new AVM2ParseException("Only one final keyword allowed", lexer.yyline());
@@ -1111,13 +1112,24 @@ public class ActionScript3Parser {
isFinal = true;
preSymbols.add(s);
}
if (s.type == SymbolType.INTERNAL) {
if (!inPackage) {
throw new AVM2ParseException("internal only allowed inside package", lexer.yyline());
}
if (isPublic || isInternal) {
throw new AVM2ParseException("Only one of public/internal keyword allowed", lexer.yyline());
}
isInternal = true;
ns = packageInternalNs;
preSymbols.add(s);
}
if (s.type == SymbolType.PUBLIC) {
if (!inPackage) {
throw new AVM2ParseException("public only allowed inside package", lexer.yyline());
}
if (isPublic) {
throw new AVM2ParseException("Only one public keyword allowed", lexer.yyline());
if (isPublic || isInternal) {
throw new AVM2ParseException("Only one of public/internal keyword allowed", lexer.yyline());
}
isPublic = true;
ns = publicNs;

View File

@@ -883,8 +883,9 @@ public class ActionScript3SimpleParser implements SimpleParser {
boolean isDynamic = false;
boolean isPublic = false;
boolean isNative = false;
boolean isInternal = false;
List<ParsedSymbol> preSymbols = new ArrayList<>();
while (s.isType(SymbolType.FINAL, SymbolType.DYNAMIC, SymbolType.PUBLIC)) {
while (s.isType(SymbolType.FINAL, SymbolType.DYNAMIC, SymbolType.PUBLIC, SymbolType.INTERNAL)) {
if (s.type == SymbolType.FINAL) {
if (isFinal) {
errors.add(new SimpleParseException("Only one final keyword allowed", lexer.yyline(), s.position));
@@ -892,13 +893,25 @@ public class ActionScript3SimpleParser implements SimpleParser {
isFinal = true;
preSymbols.add(s);
}
if (s.type == SymbolType.INTERNAL) {
if (!inPackage) {
errors.add(new SimpleParseException("internal only allowed inside package", lexer.yyline(), s.position));
}
if (isPublic || isInternal) {
errors.add(new SimpleParseException("Only one public/internal keyword allowed", lexer.yyline(), s.position));
}
isInternal = true;
//ns = internalNs;
preSymbols.add(s);
}
if (s.type == SymbolType.PUBLIC) {
if (!inPackage) {
errors.add(new SimpleParseException("public only allowed inside package", lexer.yyline(), s.position));
}
if (isPublic) {
errors.add(new SimpleParseException("Only one public keyword allowed", lexer.yyline(), s.position));
if (isPublic || isInternal) {
errors.add(new SimpleParseException("Only one public/internal keyword allowed", lexer.yyline(), s.position));
}
isPublic = true;
//ns = publicNs;