Skip to content

Commit

Permalink
Renamed TokenKinds for static imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jmjrawlings committed Dec 28, 2024
1 parent 910cd77 commit 284eaa7
Show file tree
Hide file tree
Showing 9 changed files with 676 additions and 675 deletions.
6 changes: 4 additions & 2 deletions src/MiniZinc.Parser/Expressions/RangeLiteralSyntax.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace MiniZinc.Parser.Syntax;

using static TokenKind;

public sealed class RangeLiteralSyntax : ExpressionSyntax
{
public readonly ExpressionSyntax? Lower;
Expand All @@ -18,8 +20,8 @@ public RangeLiteralSyntax(
{
Operator = op;
Lower = lower;
LowerIncusive = op is TokenKind.CLOSED_RANGE or TokenKind.RIGHT_OPEN_RANGE;
LowerIncusive = op is TOKEN_CLOSED_RANGE or TOKEN_RIGHT_OPEN_RANGE;
Upper = upper;
UpperInclusive = op is TokenKind.CLOSED_RANGE or TokenKind.LEFT_OPEN_RANGE;
UpperInclusive = op is TOKEN_CLOSED_RANGE or TOKEN_LEFT_OPEN_RANGE;
}
}
208 changes: 105 additions & 103 deletions src/MiniZinc.Parser/Keyword.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace MiniZinc.Parser;

using static TokenKind;

internal static class Keyword
{
const char FWD_SLASH = '/';
Expand Down Expand Up @@ -90,112 +92,112 @@ internal static class Keyword
internal static string GetString(TokenKind kind) =>
kind switch
{
TokenKind.KEYWORD_ANNOTATION => ANNOTATION,
TokenKind.KEYWORD_ANN => ANN,
TokenKind.KEYWORD_ANY => ANY,
TokenKind.KEYWORD_ARRAY => ARRAY,
TokenKind.KEYWORD_BOOL => BOOL,
TokenKind.KEYWORD_CASE => CASE,
TokenKind.KEYWORD_CONSTRAINT => CONSTRAINT,
TokenKind.KEYWORD_DEFAULT => DEFAULT,
TokenKind.KEYWORD_DIFF => DIFF,
TokenKind.KEYWORD_DIV => DIV,
TokenKind.KEYWORD_ELSE => ELSE,
TokenKind.KEYWORD_ELSEIF => ELSEIF,
TokenKind.KEYWORD_ENDIF => ENDIF,
TokenKind.KEYWORD_ENUM => ENUM,
TokenKind.KEYWORD_FALSE => FALSE,
TokenKind.KEYWORD_FLOAT => FLOAT,
TokenKind.KEYWORD_FUNCTION => FUNCTION,
TokenKind.KEYWORD_IF => IF,
TokenKind.KEYWORD_IN => IN,
TokenKind.KEYWORD_INCLUDE => INCLUDE,
TokenKind.KEYWORD_INT => INT,
TokenKind.KEYWORD_INTERSECT => INTERSECT,
TokenKind.KEYWORD_LET => LET,
TokenKind.KEYWORD_LIST => LIST,
TokenKind.KEYWORD_MAXIMIZE => MAXIMIZE,
TokenKind.KEYWORD_MINIMIZE => MINIMIZE,
TokenKind.KEYWORD_MOD => MOD,
TokenKind.KEYWORD_NOT => NOT,
TokenKind.KEYWORD_OF => OF,
TokenKind.KEYWORD_OP => OP,
TokenKind.KEYWORD_OPT => OPT,
TokenKind.KEYWORD_OUTPUT => OUTPUT,
TokenKind.KEYWORD_PAR => PAR,
TokenKind.KEYWORD_PREDICATE => PREDICATE,
TokenKind.KEYWORD_RECORD => RECORD,
TokenKind.KEYWORD_SATISFY => SATISFY,
TokenKind.KEYWORD_SET => SET,
TokenKind.KEYWORD_SOLVE => SOLVE,
TokenKind.KEYWORD_STRING => STRING,
TokenKind.KEYWORD_SUBSET => SUBSET,
TokenKind.KEYWORD_SUPERSET => SUPERSET,
TokenKind.KEYWORD_SYMDIFF => SYMDIFF,
TokenKind.KEYWORD_TEST => TEST,
TokenKind.KEYWORD_THEN => THEN,
TokenKind.KEYWORD_TRUE => TRUE,
TokenKind.KEYWORD_TUPLE => TUPLE,
TokenKind.KEYWORD_TYPE => TYPE,
TokenKind.KEYWORD_UNION => UNION,
TokenKind.KEYWORD_VAR => VAR,
TokenKind.KEYWORD_WHERE => WHERE,
TokenKind.KEYWORD_XOR => XOR,
KEYWORD_ANNOTATION => ANNOTATION,
KEYWORD_ANN => ANN,
KEYWORD_ANY => ANY,
KEYWORD_ARRAY => ARRAY,
KEYWORD_BOOL => BOOL,
KEYWORD_CASE => CASE,
KEYWORD_CONSTRAINT => CONSTRAINT,
KEYWORD_DEFAULT => DEFAULT,
KEYWORD_DIFF => DIFF,
KEYWORD_DIV => DIV,
KEYWORD_ELSE => ELSE,
KEYWORD_ELSEIF => ELSEIF,
KEYWORD_ENDIF => ENDIF,
KEYWORD_ENUM => ENUM,
KEYWORD_FALSE => FALSE,
KEYWORD_FLOAT => FLOAT,
KEYWORD_FUNCTION => FUNCTION,
KEYWORD_IF => IF,
KEYWORD_IN => IN,
KEYWORD_INCLUDE => INCLUDE,
KEYWORD_INT => INT,
KEYWORD_INTERSECT => INTERSECT,
KEYWORD_LET => LET,
KEYWORD_LIST => LIST,
KEYWORD_MAXIMIZE => MAXIMIZE,
KEYWORD_MINIMIZE => MINIMIZE,
KEYWORD_MOD => MOD,
KEYWORD_NOT => NOT,
KEYWORD_OF => OF,
KEYWORD_OP => OP,
KEYWORD_OPT => OPT,
KEYWORD_OUTPUT => OUTPUT,
KEYWORD_PAR => PAR,
KEYWORD_PREDICATE => PREDICATE,
KEYWORD_RECORD => RECORD,
KEYWORD_SATISFY => SATISFY,
KEYWORD_SET => SET,
KEYWORD_SOLVE => SOLVE,
KEYWORD_STRING => STRING,
KEYWORD_SUBSET => SUBSET,
KEYWORD_SUPERSET => SUPERSET,
KEYWORD_SYMDIFF => SYMDIFF,
KEYWORD_TEST => TEST,
KEYWORD_THEN => THEN,
KEYWORD_TRUE => TRUE,
KEYWORD_TUPLE => TUPLE,
KEYWORD_TYPE => TYPE,
KEYWORD_UNION => UNION,
KEYWORD_VAR => VAR,
KEYWORD_WHERE => WHERE,
KEYWORD_XOR => XOR,
_ => string.Empty
};

internal const TokenKind Annotation = TokenKind.KEYWORD_ANNOTATION;
internal const TokenKind Ann = TokenKind.KEYWORD_ANN;
internal const TokenKind Any = TokenKind.KEYWORD_ANY;
internal const TokenKind AnonEnum = TokenKind.KEYWORD_ANONENUM;
internal const TokenKind Array = TokenKind.KEYWORD_ARRAY;
internal const TokenKind Bool = TokenKind.KEYWORD_BOOL;
internal const TokenKind Case = TokenKind.KEYWORD_CASE;
internal const TokenKind Constraint = TokenKind.KEYWORD_CONSTRAINT;
internal const TokenKind Default = TokenKind.KEYWORD_DEFAULT;
internal const TokenKind Diff = TokenKind.KEYWORD_DIFF;
internal const TokenKind Div = TokenKind.KEYWORD_DIV;
internal const TokenKind Else = TokenKind.KEYWORD_ELSE;
internal const TokenKind Elseif = TokenKind.KEYWORD_ELSEIF;
internal const TokenKind Endif = TokenKind.KEYWORD_ENDIF;
internal const TokenKind Enum = TokenKind.KEYWORD_ENUM;
internal const TokenKind False = TokenKind.KEYWORD_FALSE;
internal const TokenKind Float = TokenKind.KEYWORD_FLOAT;
internal const TokenKind Function = TokenKind.KEYWORD_FUNCTION;
internal const TokenKind If = TokenKind.KEYWORD_IF;
internal const TokenKind In = TokenKind.KEYWORD_IN;
internal const TokenKind Include = TokenKind.KEYWORD_INCLUDE;
internal const TokenKind Int = TokenKind.KEYWORD_INT;
internal const TokenKind Intersect = TokenKind.KEYWORD_INTERSECT;
internal const TokenKind Let = TokenKind.KEYWORD_LET;
internal const TokenKind List = TokenKind.KEYWORD_LIST;
internal const TokenKind Maximize = TokenKind.KEYWORD_MAXIMIZE;
internal const TokenKind Minimize = TokenKind.KEYWORD_MINIMIZE;
internal const TokenKind Mod = TokenKind.KEYWORD_MOD;
internal const TokenKind Not = TokenKind.KEYWORD_NOT;
internal const TokenKind Of = TokenKind.KEYWORD_OF;
internal const TokenKind Op = TokenKind.KEYWORD_OP;
internal const TokenKind Opt = TokenKind.KEYWORD_OPT;
internal const TokenKind Output = TokenKind.KEYWORD_OUTPUT;
internal const TokenKind Par = TokenKind.KEYWORD_PAR;
internal const TokenKind Predicate = TokenKind.KEYWORD_PREDICATE;
internal const TokenKind Record = TokenKind.KEYWORD_RECORD;
internal const TokenKind Satisfy = TokenKind.KEYWORD_SATISFY;
internal const TokenKind Set = TokenKind.KEYWORD_SET;
internal const TokenKind Solve = TokenKind.KEYWORD_SOLVE;
internal const TokenKind String = TokenKind.KEYWORD_STRING;
internal const TokenKind Subset = TokenKind.KEYWORD_SUBSET;
internal const TokenKind Superset = TokenKind.KEYWORD_SUPERSET;
internal const TokenKind Symdiff = TokenKind.KEYWORD_SYMDIFF;
internal const TokenKind Test = TokenKind.KEYWORD_TEST;
internal const TokenKind Then = TokenKind.KEYWORD_THEN;
internal const TokenKind True = TokenKind.KEYWORD_TRUE;
internal const TokenKind Tuple = TokenKind.KEYWORD_TUPLE;
internal const TokenKind Type = TokenKind.KEYWORD_TYPE;
internal const TokenKind Union = TokenKind.KEYWORD_UNION;
internal const TokenKind Var = TokenKind.KEYWORD_VAR;
internal const TokenKind Where = TokenKind.KEYWORD_WHERE;
internal const TokenKind Xor = TokenKind.KEYWORD_XOR;
internal const TokenKind Annotation = KEYWORD_ANNOTATION;
internal const TokenKind Ann = KEYWORD_ANN;
internal const TokenKind Any = KEYWORD_ANY;
internal const TokenKind AnonEnum = KEYWORD_ANONENUM;
internal const TokenKind Array = KEYWORD_ARRAY;
internal const TokenKind Bool = KEYWORD_BOOL;
internal const TokenKind Case = KEYWORD_CASE;
internal const TokenKind Constraint = KEYWORD_CONSTRAINT;
internal const TokenKind Default = KEYWORD_DEFAULT;
internal const TokenKind Diff = KEYWORD_DIFF;
internal const TokenKind Div = KEYWORD_DIV;
internal const TokenKind Else = KEYWORD_ELSE;
internal const TokenKind Elseif = KEYWORD_ELSEIF;
internal const TokenKind Endif = KEYWORD_ENDIF;
internal const TokenKind Enum = KEYWORD_ENUM;
internal const TokenKind False = KEYWORD_FALSE;
internal const TokenKind Float = KEYWORD_FLOAT;
internal const TokenKind Function = KEYWORD_FUNCTION;
internal const TokenKind If = KEYWORD_IF;
internal const TokenKind In = KEYWORD_IN;
internal const TokenKind Include = KEYWORD_INCLUDE;
internal const TokenKind Int = KEYWORD_INT;
internal const TokenKind Intersect = KEYWORD_INTERSECT;
internal const TokenKind Let = KEYWORD_LET;
internal const TokenKind List = KEYWORD_LIST;
internal const TokenKind Maximize = KEYWORD_MAXIMIZE;
internal const TokenKind Minimize = KEYWORD_MINIMIZE;
internal const TokenKind Mod = KEYWORD_MOD;
internal const TokenKind Not = KEYWORD_NOT;
internal const TokenKind Of = KEYWORD_OF;
internal const TokenKind Op = KEYWORD_OP;
internal const TokenKind Opt = KEYWORD_OPT;
internal const TokenKind Output = KEYWORD_OUTPUT;
internal const TokenKind Par = KEYWORD_PAR;
internal const TokenKind Predicate = KEYWORD_PREDICATE;
internal const TokenKind Record = KEYWORD_RECORD;
internal const TokenKind Satisfy = KEYWORD_SATISFY;
internal const TokenKind Set = KEYWORD_SET;
internal const TokenKind Solve = KEYWORD_SOLVE;
internal const TokenKind String = KEYWORD_STRING;
internal const TokenKind Subset = KEYWORD_SUBSET;
internal const TokenKind Superset = KEYWORD_SUPERSET;
internal const TokenKind Symdiff = KEYWORD_SYMDIFF;
internal const TokenKind Test = KEYWORD_TEST;
internal const TokenKind Then = KEYWORD_THEN;
internal const TokenKind True = KEYWORD_TRUE;
internal const TokenKind Tuple = KEYWORD_TUPLE;
internal const TokenKind Type = KEYWORD_TYPE;
internal const TokenKind Union = KEYWORD_UNION;
internal const TokenKind Var = KEYWORD_VAR;
internal const TokenKind Where = KEYWORD_WHERE;
internal const TokenKind Xor = KEYWORD_XOR;

internal static readonly Dictionary<string, TokenKind> Lookup;

Expand Down
Loading

0 comments on commit 284eaa7

Please sign in to comment.