Skip to content

Commit

Permalink
Adding missing attributes (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
Claes65 authored Sep 30, 2023
1 parent 7cde97b commit d02ec80
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Stream<DynamicTest> reportADiagnosticForKeywordsThatCanBeIdentifiers()
return Arrays.stream(SyntaxKind.values())
.filter(SyntaxKind::canBeIdentifier)
.filter(sk -> sk != SyntaxKind.IDENTIFIER)
.map(sk -> dynamicTest("%s should be discouraged as identifier".formatted(sk), () ->
.map(sk -> dynamicTest("%s should be discouraged as identifier, but was not. Is it defined in the KeywordTable?".formatted(sk), () ->
{
testDiagnostics(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public static SyntaxKind getKeyword(String possibleKeyword)
case "eject" -> SyntaxKind.EJECT;
case "else" -> SyntaxKind.ELSE;
case "em" -> SyntaxKind.EM;
case "emu" -> SyntaxKind.EMU;
case "encoded" -> SyntaxKind.ENCODED;
case "end" -> SyntaxKind.END;
case "end-all" -> SyntaxKind.END_ALL;
Expand Down Expand Up @@ -260,6 +261,7 @@ public static SyntaxKind getKeyword(String possibleKeyword)
case "hw" -> SyntaxKind.HW;
case "ia" -> SyntaxKind.IA;
case "ic" -> SyntaxKind.IC;
case "icu" -> SyntaxKind.ICU;
case "id" -> SyntaxKind.ID;
case "identical" -> SyntaxKind.IDENTICAL;
case "if" -> SyntaxKind.IF;
Expand Down Expand Up @@ -309,6 +311,7 @@ public static SyntaxKind getKeyword(String possibleKeyword)
case "language" -> SyntaxKind.LANGUAGE;
case "last" -> SyntaxKind.LAST;
case "lc" -> SyntaxKind.LC;
case "lcu" -> SyntaxKind.LCU;
case "le" -> SyntaxKind.LE;
case "leading" -> SyntaxKind.LEADING;
case "leave" -> SyntaxKind.LEAVE;
Expand Down Expand Up @@ -555,6 +558,7 @@ public static SyntaxKind getKeyword(String possibleKeyword)
case "system" -> SyntaxKind.SYSTEM;
case "tan" -> SyntaxKind.TAN;
case "tc" -> SyntaxKind.TC;
case "tcu" -> SyntaxKind.TCU;
case "terminate" -> SyntaxKind.TERMINATE;
case "text" -> SyntaxKind.TEXT;
case "textarea" -> SyntaxKind.TEXTAREA;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ public enum SyntaxKind
EDITED(true, false, false),
EJ(true, false, false),
EM(true, false, false), // EDITOR MASK
EMU(true, false, false),
ENCODED(true, false, false),
END_CLASS(true, false, false),
END_DEFINE(true, false, false),
Expand Down Expand Up @@ -475,6 +476,7 @@ public enum SyntaxKind
HW(true, false, false),
IA(true, false, false),
IC(true, false, false),
ICU(true, false, false),
ID(true, false, false),
IDENTICAL(true, false, false),
IM(true, false, false),
Expand Down Expand Up @@ -512,6 +514,7 @@ public enum SyntaxKind
KEYS(true, false, false),
LAST(true, false, false),
LC(true, false, false),
LCU(true, false, false),
LE(true, false, false),
LEAVE(true, false, false),
LEAVING(true, false, false),
Expand All @@ -529,7 +532,6 @@ public enum SyntaxKind
LISTED(true, false, false),
LOCAL(true, false, false),
LOCKS(true, false, false),
// LOG(true,false, false), sadly this is used my natunit as a subroutine name :(
LOG_LS(true, false, false),
LOG_PS(true, false, false),
LOGICAL(true, false, false),
Expand Down Expand Up @@ -693,6 +695,7 @@ public enum SyntaxKind
SYNC(true, false, false),
SYSTEM(true, false, false),
TC(true, false, false),
TCU(true, false, false),
TEXT(true, false, false),
TEXTAREA(true, false, false),
TEXTVARIABLE(true, false, false),
Expand Down Expand Up @@ -783,6 +786,38 @@ public boolean canBeIdentifier()

public boolean isAttribute()
{
return this == AD || this == DY || this == CD || this == EM || this == NL || this == AL || this == DF || this == PM || this == IP || this == IS || this == CV || this == ZP || this == SG || this == ES || this == SB;
return this == AD ||
this == AL ||
this == CC ||
this == CD ||
this == CV ||
this == DF ||
this == DL ||
this == DY ||
this == EM || this == EMU ||
this == ES ||
this == FC ||
this == FL ||
this == GC ||
this == HC ||
this == HW ||
this == IC || this == ICU ||
this == IP ||
this == IS ||
this == KD ||
this == LC || this == LCU ||
this == LS ||
this == MC ||
this == MP ||
this == MS ||
this == NL ||
this == PC ||
this == PM ||
this == PS ||
this == SB ||
this == SG ||
this == TC || this == TCU ||
this == UC ||
this == ZP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,45 @@ class LexerForAttributeControlsShould extends AbstractLexerTest
@TestFactory
Stream<DynamicTest> recognizeAttributes()
{
var attributes = List.of(SyntaxKind.AD, SyntaxKind.DY, SyntaxKind.CD, SyntaxKind.EM, SyntaxKind.NL, SyntaxKind.AL, SyntaxKind.DF, SyntaxKind.PM, SyntaxKind.IP, SyntaxKind.IS, SyntaxKind.CV, SyntaxKind.ZP, SyntaxKind.SG, SyntaxKind.ES, SyntaxKind.SG, SyntaxKind.SB);
var attributes = List.of(
SyntaxKind.AD,
SyntaxKind.AL,
SyntaxKind.CC,
SyntaxKind.CD,
SyntaxKind.CV,
SyntaxKind.DF,
SyntaxKind.DL,
SyntaxKind.DY,
SyntaxKind.EM,
SyntaxKind.EMU,
SyntaxKind.ES,
SyntaxKind.FC,
SyntaxKind.FL,
SyntaxKind.GC,
SyntaxKind.HC,
SyntaxKind.HW,
SyntaxKind.IC,
SyntaxKind.ICU,
SyntaxKind.IP,
SyntaxKind.IS,
SyntaxKind.KD,
SyntaxKind.LC,
SyntaxKind.LCU,
SyntaxKind.LS,
SyntaxKind.MC,
SyntaxKind.MP,
SyntaxKind.MS,
SyntaxKind.NL,
SyntaxKind.PC,
SyntaxKind.PM,
SyntaxKind.PS,
SyntaxKind.SB,
SyntaxKind.SG,
SyntaxKind.TC,
SyntaxKind.TCU,
SyntaxKind.UC,
SyntaxKind.ZP
);

var shouldBeAttributes = attributes.stream()
.map(a -> dynamicTest("%s should be attribute".formatted(a), () -> assertThat(a.isAttribute()).isTrue()));
Expand Down

0 comments on commit d02ec80

Please sign in to comment.