XPlor/libs/dsl/Token.h
njohnson 3e3883cfeb Add DSL journaling infrastructure for field editing and write-back
Introduce operation journaling to track how values are read from the
binary stream, enabling future write-back of edited fields.

New components:
- OperationJournal: Records read operations with stream offsets, sizes,
  byte order, and original values during parsing
- ReverseEval: Analyzes expressions for invertibility (e.g., x+5 can be
  reversed to compute the source field when editing the result)
- Recompiler: Infrastructure for recompiling modified values back to
  binary format

Interpreter enhancements:
- Add runTypeInternalWithJournal() for journaled parsing
- Journal scalar reads, byte reads, strings, skip/seek operations
- Add deadrising_lzx() built-in for Dead Rising 2 LZX decompression
- Support _deadrising_lzx_stem context variable for nested archives

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 20:53:20 -05:00

80 lines
1.2 KiB
C

#ifndef TOKEN_H
#define TOKEN_H
#include <QString>
enum class TokenKind {
End,
Identifier,
Number,
String,
// punctuation
LBrace, RBrace,
LParen, RParen,
LBracket, RBracket,
Semicolon, Comma,
Assign,
Pipe,
Dot,
DotDot,
// operators
Plus, Minus, Star, Slash, Percent,
LShift, RShift, Bar,
Amp, Caret,
Bang,
EqEq, NotEq,
Lt, Lte, Gt, Gte,
AndAnd, OrOr,
// keywords
KwType,
KwByteOrder,
KwLE, KwBE,
KwSkip,
KwIf, KwElse,
KwWhile,
KwAlign,
KwSeek,
KwRepeat,
KwFor,
KwIn,
KwEOF,
KwCriteria,
KwRequire,
KwBool,
KwBreak,
KwTrue,
KwFalse,
KwMatch,
KwInline,
KwArray,
KwConst,
KwWhen,
KwAt,
KwDefault,
KwUi, // ui
KwEdit, // edit
KwReadOnly, // readonly
// punctuation additions
Arrow, // =>
Colon, // :
// scalar keywords
KwU8, KwU16, KwU32, KwU64,
KwI8, KwI16, KwI32, KwI64,
KwF32, KwF64,
};
struct Token {
TokenKind kind = TokenKind::End;
QString text;
qint64 number = 0;
int line = 1;
int col = 1;
};
#endif // TOKEN_H