Expand description
Yog Script (.ys) and Yog Nanite Script (.yns): the language a Yog
mod is written in (docs/design/ys.md, docs/design/ys-grammar.md).
This crate reads a source into its syntax tree, resolves its names and
says what’s wrong with it, as Diagnostics placed in the source.
Modules§
- ast
- The syntax tree of a Yog Script source (
docs/design/ys-grammar.md). - index
- The class index (
docs/design/ys.md§8): what the compiler knows of the game for one Minecraft version — each class by Mojang’s name, the side it’s on, what it extends and implements, its fields and methods with their descriptors and access. Built byyog indexfrom the game’s own jars; the resolver and the type checker look the game’s names up in it. - macros
- Declarative macros (
ys.md§3, Attributes and macros), expanded over the tokens before anything reads the code:macro Name { rules }is taken out, eachName!(…)replaced by what its first matching rule writes, again and again until no call of a declared macro is left. The built-in macros (panic!, …) stay for the parser. - parser
- The parser core: a cursor over tokens, problems and recovery, and the
turn-taking — each form is parsed by its word (
words/) or by a generic form here (types, members, blocks, expressions by precedence). - resolve
- What the names of a source stand for, and what’s out of place: each
name looked up in the scopes around it (a declaration’s anywhere in its
body, a block’s from where it’s bound), declared twice, assigned while
constant, cased against C#’s style,
breakoutside a loop,skipoutside abefore,itoutside a block lambda,thisoutside members,awaitoutsideasync. Names a source doesn’t declare are the game’s and the library’s: the type checker looks them up. - system
- The System library’s declarations (
system/*.ys), read once and seen by every source as its own types are, namespaceSystem. - token
- What the lexer cuts a source into: tokens, each with where it is.
- versions
- Game versions matched with what a source says of them:
targets mc …;and#if mc …— the one way, compared as Yog compares versions. - words
- The words of Yog Script. Each word is one file under
words/: how it’s written, what it means (shown by editors) and how it parses. The parser core only hands each word its turn; this file only lists them. - yog
- Yog’s surface as compiled code writes it (
yog-event’s Java records,dev.yog.bus): a service’s record called, an event’s listened to, a payload’s fields read.
Structs§
- Checked
- A source checked: its tree, what its names stand for, its problems.
- Env
- What a source is checked in: the game’s classes (a
.yns’s, of one version), the build’s procedural macros. - Parsed
- A source read: its tree (what could be read of it) and its problems.
- Types
- The types of a checked file’s expressions. An expression is known by its node in the file’s tree — which, once checked, isn’t changed — so two that share a place (a macro’s output, all at its call) stay apart.
Enums§
- Type
- A type.
Functions§
- check
- The source
srcof the filenameread, its names resolved and its types checked (the game’s unknown): what the editors report. - check_
in check_withinenv.- check_
with checkof a.ynswith the game’s classes of one of the versions it targets: whatyog buildreports, once a version. A.ysreaches Yog, not the game:gameis ignored for it.- is_
nanites - Whether the file
nameis Yog Nanite Script (.yns): patches allowed, the game’s classes reachable. - parse
- The source
srcof the filenameread; patches are allowed when it’s a.ynsfile (read as the newest game version Yog runs on). - targets
- The game versions a
.ynssays it’s for (targets mc …;).