RE:INSTEAD: minimal INSTEAD parser-game player. C engine (src/, SDL2/SDL3), game logic and parser in Lua (data/). Games live in data/games/<name>/, entry file main3.lua (archive/urzi use main3-ru.lua / main3-en.lua selected via @lang).
make— default (LuaJIT + SDL2 via pkg-config). SDL3:make SDLVER=sdl3(pkg-configsdl3)../make-default.sh— bundled Lua (src/lua), no LuaJIT;SDLVER=sdl3 ./make-default.shfor SDL3. Also./make-tcc.sh,make WITH_FREETYPE=1,make WITH_SCHRIFT=1.- Platform:
src/platform_sdl.cholds the SDL-shared part and includessrc/sdl2/platform.corsrc/sdl3/platform.c(-DUSE_SDL3selects SDL3).src/platform.his the only platform header. Plan9 (src/plan9/platform.c) is standalone. ./clean.shormake clean; binary is./reinstead.- Build artifacts (
*.o,reinstead,data/settings) are untracked — never commit them. - CI (
.github/workflows/CI.yml) only builds variants; it does not run tests.
./tests/run-parser-tests.sh(needs a built./reinstead; override withBIN=...). Runs parser unit checks (tests/parser-tests) and golden diffs (tests/match-dump/golden.txt=mp:matchsnapshots,golden-compl.txt=mp:compl;tests/noun-forms/golden.txt= noun declension forms).- Single test game directly:
SDL_VIDEODRIVER=dummy ./reinstead -appdata "$(mktemp -d)" -noautosave "$PWD/tests/parser-tests" - Golden regeneration is only for intentional parser behavior changes: run the dump game directly (it writes
out.txt/out-compl.txtnext totests/match-dump/main3.lua), then copy them togolden*.txt. The noun forms golden is regenerated the same way (tests/noun-forms/out.txt→golden.txt). To validate a refactor, compare against a previousmp.lua:git show <rev>:data/stead3/parser/mp.luaswapped in, run the dump,diff.
- Pass the game directory as an absolute path; relative
games/trialfails with "Can not detect game format":SDL_VIDEODRIVER=dummy ./reinstead -appdata /tmp/x -noautosave /work/data/games/trial -i /work/data/games/trial/autoscript -iscript is opened relative to CWD (use an absolute path). CLI options are parsed indata/core/core.lua: positional = game dir, plus-i,-appdata,-noautosave,-debug,-scale,-tts,-noautoload.- Autoscript = one player command per line; lines starting with
!//are system commands (!game,!script,!restart,!font,!quit, ...).data/games/autoscriptis an orchestrator over all games, not a game. dict.mrdbeside a game is a generated, tracked cache; the engine regenerates it when sources change, so it can appear modified after runs.
mp.lua(core: input, tokens, match, completion, actions),mplib.lua(standard verbs, scope/visibility),mp-ru.lua/mp-en.lua(language layer: messages,Verb{...}, morphology). Gamesrequire "parser/mp-ru"(ormp-en).mp:matchis decomposed into helpers (find_alternative,disambiguate,slot_hit/varg/missing/optional,accept_descriptor,rank_matches,drop_extra,finalize).mp:debug_matchprints match details; its call is commented out insidemp:match.Verb{ ..., prio = N }sets verb priority; patterns are compiled at registration intod.compiled;{token}slots still expand at parse time.- Hot-path invariants — preserve unless you have a golden + benchmark:
mp:noun_formscaches per-object word forms (invalidated byob.wordchange; dynamicword/raw_wordfunctions are not cached);first_charmemo + first-char prefilters infind_alternative/lookup_verb/lookup_noun/disambiguate(exact mode only — fuzzy matching needs all candidates);std.obj:hasmemoizes attribute parsing;mp:trace/mp:traceinsideuse one growing list;visible()/access()are inlined without closures. Do not cache results keyed on mutable scene state (e.g. darkness) without invalidating on move/attr. - Tests run inside the engine:
init()is global context (std.gameis nil,p()raises "Call from global context"). Usestd.mod_startfor game logic or stub side effects withstd.rawset(mp, 'xaction', ...).
- Words:
obj { -"камень,валун"; ... }— comma = aliases,|= separate names,/= grammatical hints (-"пёс,собака/мр,од,жив"). - Attributes are set with
:attr 'container,open'; a plain fieldcontainer = truedoes NOT set an attribute. - Rooms are lit by default;
:attr '~light'makes a room dark.
- Work on branch
opencode, commits authored asopencode <opencode@localhost>; do not commit without explicit confirmation. - Comments in
data/stead3/parser/are English.