mirror of
https://github.com/Wack0/IFPSTools.NET.git
synced 2025-06-18 10:45:36 -04:00

libifpscc: initial commit readme: document ifpscc/libifpscc license: add credits for ifpscc/libifpscc (derived from code also MIT licensed) libifps: make additional fields/types public for libifpscc libifps: fix field documentation for some opcodes libifps: fix loading functions that are not exported libifps: allow saving a nonexistant primitive type if the same primitive type was added already libifps: fix parsing Extended constants libifps: fix ushort/short being mapped to the wrong types in one table csproj: set Prefer32Bit=false for release builds
98 lines
3.1 KiB
C#
98 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace LexicalAnalysis {
|
|
public enum KeywordVal {
|
|
AUTO,
|
|
DOUBLE,
|
|
INT,
|
|
STRUCT,
|
|
BREAK,
|
|
ELSE,
|
|
LONG,
|
|
SWITCH,
|
|
CASE,
|
|
ENUM,
|
|
REGISTER,
|
|
TYPEDEF,
|
|
CHAR,
|
|
EXTERN,
|
|
RETURN,
|
|
UNION,
|
|
CONST,
|
|
FLOAT,
|
|
SHORT,
|
|
UNSIGNED,
|
|
CONTINUE,
|
|
FOR,
|
|
SIGNED,
|
|
VOID,
|
|
DEFAULT,
|
|
GOTO,
|
|
SIZEOF,
|
|
VOLATILE,
|
|
DO,
|
|
IF,
|
|
STATIC,
|
|
WHILE,
|
|
|
|
ATTRIBUTE,
|
|
STRING,
|
|
INT64,
|
|
INTERFACE,
|
|
VARIANT
|
|
}
|
|
|
|
public class TokenKeyword : Token {
|
|
public TokenKeyword(KeywordVal val) {
|
|
this.Val = val;
|
|
}
|
|
|
|
public override TokenKind Kind { get; } = TokenKind.KEYWORD;
|
|
public KeywordVal Val { get; }
|
|
public static Dictionary<String, KeywordVal> Keywords { get; } = new Dictionary<String, KeywordVal>(StringComparer.InvariantCultureIgnoreCase) {
|
|
{ "AUTO", KeywordVal.AUTO },
|
|
{ "DOUBLE", KeywordVal.DOUBLE },
|
|
{ "INT", KeywordVal.INT },
|
|
{ "STRUCT", KeywordVal.STRUCT },
|
|
{ "BREAK", KeywordVal.BREAK },
|
|
{ "ELSE", KeywordVal.ELSE },
|
|
{ "LONG", KeywordVal.LONG },
|
|
{ "SWITCH", KeywordVal.SWITCH },
|
|
{ "CASE", KeywordVal.CASE },
|
|
{ "ENUM", KeywordVal.ENUM },
|
|
{ "REGISTER", KeywordVal.REGISTER },
|
|
{ "TYPEDEF", KeywordVal.TYPEDEF },
|
|
{ "CHAR", KeywordVal.CHAR },
|
|
{ "EXTERN", KeywordVal.EXTERN },
|
|
{ "RETURN", KeywordVal.RETURN },
|
|
{ "UNION", KeywordVal.UNION },
|
|
{ "CONST", KeywordVal.CONST },
|
|
{ "FLOAT", KeywordVal.FLOAT },
|
|
{ "SHORT", KeywordVal.SHORT },
|
|
{ "UNSIGNED", KeywordVal.UNSIGNED },
|
|
{ "CONTINUE", KeywordVal.CONTINUE },
|
|
{ "FOR", KeywordVal.FOR },
|
|
{ "SIGNED", KeywordVal.SIGNED },
|
|
{ "VOID", KeywordVal.VOID },
|
|
{ "DEFAULT", KeywordVal.DEFAULT },
|
|
{ "GOTO", KeywordVal.GOTO },
|
|
{ "SIZEOF", KeywordVal.SIZEOF },
|
|
{ "VOLATILE", KeywordVal.VOLATILE },
|
|
{ "DO", KeywordVal.DO },
|
|
{ "IF", KeywordVal.IF },
|
|
{ "STATIC", KeywordVal.STATIC },
|
|
{ "WHILE", KeywordVal.WHILE },
|
|
{ "__ATTRIBUTE", KeywordVal.ATTRIBUTE },
|
|
{ "__STRING", KeywordVal.STRING },
|
|
{ "__INT64", KeywordVal.INT64 },
|
|
{ "__INTERFACE", KeywordVal.INTERFACE },
|
|
{ "__VARIANT", KeywordVal.VARIANT }
|
|
};
|
|
|
|
public override String ToString() {
|
|
return this.Kind + $" [{Line}:{Column}]: " + this.Val;
|
|
}
|
|
|
|
}
|
|
} |