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. - spelling
- How Yog Script spells what its reader reads: what a writer of it
(
yog-codegen-ys) writes the same way. - system
- The System library’s declarations (
system/**/*.ys: one type a file, its folders its namespace), read once and seen by every source as its own types are. Its names areyog_script_ids::system’s. - 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. - Message
- A method as a call chose it: its type (none: the file’s), its name, which of the type’s methods of that name (in declaration order), its parameters and result as declared (its type parameters unbound). A call across sides: the file’s method it runs on the other side, and which way it goes.
- Message
Template - A string written for a message template: its text as written (holes and all), and whether its holes are its values.
- Method
Use - Operator
Use - An operator or a conversion a type declares, as used: the type, its
method (
op_Addition,op_Implicit). - Parsed
- A source read: its tree (what could be read of it) and its problems.
- Quoted
- A lambda given as an expression tree: its delegate’s type, and the parameters and result the delegate gives it.
- 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§
- body_
yields - Whether
bodyyields: it’s an iterator’s. - builtin_
type - The built-in type its keyword names (
i32,string): the one table of them, for whatever lowers types too. - 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.- command_
arg - The game’s argument type a command’s parameter of type
tis parsed as. - content_
base - The library class content of kind
kindinherits (block’sBlockObject), when its kind has one. - content_
path - The path of content declaration
name’s id (Lamp:lamp), in its mod’s namespace: the file it binds to islamp.yblock. - declarations
- Source
src’s declarations, read (macros expanded) as its check reads them: what the other sources of its mod reach (Env::others). What’s wrong with it is its own check’s to report. - holes
- Each hole’s value of string
e, in order. - is_
nanites - Whether the file
nameis Yog Nanite Script (.yns): patches allowed, the game’s classes reachable. - item_of
- What an iterator giving
tgives an item of:IEnumerable<T>’sT. - leaves
- Whether
salways leaves what it’s in (return,break,continue,yield break, a panic), so what follows runs only when it doesn’t run. - list_
item - What a list pattern on
onmatches each item of: an array’s item, a string’schar, a list’sT. - parse
- The source
srcof the filenameread; patches are allowed when it’s a.ynsfile (read as the newest game version Yog runs on). - system_
name - A built-in type’s type in
System(string’sString), which a[Host]declaration gives its members. - system_
type - The built-in type
System’s typenameis (Int32isi32,Voidvoid): the same table read the other way. - targets
- The game versions a
.ynssays it’s for (targets mc …;).