2020-11-10 15:26:38 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace hex::lang {
|
|
|
|
|
|
|
|
struct Token {
|
|
|
|
enum class Type : u64 {
|
|
|
|
Keyword,
|
|
|
|
Type,
|
|
|
|
Operator,
|
|
|
|
Integer,
|
|
|
|
Identifier,
|
|
|
|
EndOfExpression,
|
|
|
|
ScopeOpen,
|
|
|
|
ScopeClose,
|
2020-11-12 23:57:43 +01:00
|
|
|
ArrayOpen,
|
|
|
|
ArrayClose,
|
2020-11-10 15:26:38 +01:00
|
|
|
Separator,
|
|
|
|
EndOfProgram
|
|
|
|
} type;
|
|
|
|
|
|
|
|
struct KeywordToken {
|
|
|
|
enum class Keyword {
|
|
|
|
Struct,
|
2020-11-20 21:29:28 +01:00
|
|
|
Union,
|
2020-11-14 14:40:21 +01:00
|
|
|
Using,
|
2020-11-20 20:26:19 +01:00
|
|
|
Enum,
|
2020-12-06 21:40:57 +01:00
|
|
|
Bitfield,
|
|
|
|
LittleEndian,
|
|
|
|
BigEndian
|
2020-11-10 15:26:38 +01:00
|
|
|
} keyword;
|
|
|
|
} keywordToken;
|
|
|
|
struct IdentifierToken {
|
|
|
|
std::string identifier;
|
|
|
|
} identifierToken;
|
|
|
|
struct OperatorToken {
|
|
|
|
enum class Operator {
|
|
|
|
AtDeclaration,
|
2020-11-14 14:40:21 +01:00
|
|
|
Assignment,
|
2020-11-21 23:00:09 +01:00
|
|
|
Inherit,
|
|
|
|
Star
|
2020-11-10 15:26:38 +01:00
|
|
|
} op;
|
|
|
|
} operatorToken;
|
|
|
|
struct IntegerToken {
|
|
|
|
s128 integer;
|
|
|
|
} integerToken;
|
|
|
|
struct TypeToken {
|
|
|
|
enum class Type {
|
|
|
|
Unsigned8Bit = 0x10,
|
|
|
|
Signed8Bit = 0x11,
|
|
|
|
Unsigned16Bit = 0x20,
|
|
|
|
Signed16Bit = 0x21,
|
|
|
|
Unsigned32Bit = 0x40,
|
|
|
|
Signed32Bit = 0x41,
|
|
|
|
Unsigned64Bit = 0x80,
|
|
|
|
Signed64Bit = 0x81,
|
|
|
|
Unsigned128Bit = 0x100,
|
|
|
|
Signed128Bit = 0x101,
|
|
|
|
Float = 0x42,
|
|
|
|
Double = 0x82,
|
2020-11-20 21:59:27 +01:00
|
|
|
CustomType = 0x00,
|
|
|
|
Padding = 0x1F
|
2020-11-10 15:26:38 +01:00
|
|
|
} type;
|
|
|
|
} typeToken;
|
2020-11-27 21:20:23 +01:00
|
|
|
|
|
|
|
u32 lineNumber;
|
2020-11-10 15:26:38 +01:00
|
|
|
};
|
|
|
|
}
|