/
dgrigorev
/
gw-basic-cpp
Обзор
Документация
Войти
/
dgrigorev
/
gw-basic-cpp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
include/gwbasic/token.hpp
129 строк
2 KB
Дмитрий Григорьев
Advance GW-BASIC compatibility and tooling
16 май 2026, 20:04
16 май 2026, 20:04
8e3f79b
Код
Авторство
О чём код?
#pragma once #include <string> namespace gwbasic { /** Token categories emitted by Lexer and consumed by Parser. */ enum class TokenType { EndOfLine, Number, String, Identifier, LineNumber, Comma, Colon, Semicolon, LeftParen, RightParen, Plus, Minus, Star, Slash, Backslash, Caret, Hash, Equal, NotEqual, Less, LessEqual, Greater, GreaterEqual, KeywordPrint, KeywordUsing, KeywordOpen, KeywordClose, KeywordWrite, KeywordLine, KeywordAs, KeywordInputFile, KeywordOutput, KeywordAppend, KeywordRandom, KeywordLen, KeywordLet, KeywordInput, KeywordIf, KeywordThen, KeywordElse, KeywordAnd, KeywordOr, KeywordMod, KeywordNot, KeywordGoto, KeywordGosub, KeywordReturn, KeywordFor, KeywordTo, KeywordStep, KeywordNext, KeywordData, KeywordRead, KeywordRestore, KeywordDim, KeywordErase, KeywordOption, KeywordBase, KeywordWhile, KeywordWend, KeywordOn, KeywordError, KeywordResume, KeywordDef, KeywordDefint, KeywordDefstr, KeywordDefsng, KeywordDefdbl, KeywordStop, KeywordCont, KeywordEnd, KeywordRem, KeywordList, KeywordRun, KeywordLoad, KeywordSave, KeywordNew, KeywordClear, KeywordField, KeywordFiles, KeywordGet, KeywordPut, KeywordLset, KeywordRset, KeywordSwap, KeywordKill, KeywordName, KeywordMkdir, KeywordChdir, KeywordRmdir, KeywordCls, KeywordLocate, KeywordWidth, KeywordColor, KeywordBeep, KeywordScreen, KeywordKey, KeywordPoke, KeywordSound, KeywordPlay, KeywordRandomize, KeywordPset, KeywordCircle, KeywordPaint, KeywordDraw, KeywordView, KeywordWindow, KeywordPalette }; /** One lexical token with its original lexeme and 1-based source column. */ struct Token { TokenType type{}; std::string lexeme{}; std::size_t column{}; }; /** Return a human-readable token name, mostly for diagnostics and tests. */ [[nodiscard]] auto to_string(TokenType type) -> std::string; } // namespace gwbasic