Skip to main content

Crate nifty_syntax

Crate nifty_syntax 

Source
Expand description

Front end of the Nifty language: source text to a syntax tree, with diagnostics.

Modules§

ast
The syntax tree. It records what was written; names and types are checked later.
diagnostic 🔒
lexer 🔒
Turns source text into tokens. Strings are split into text and interpolation tokens so the parser handles "{expr}" with the ordinary expression grammar.
parser 🔒
Recursive-descent parser. On an error it records a diagnostic, skips to the end of the line and carries on, so one mistake reports once instead of cascading.
project
Which files make up a project: the folder holding main.nf and every .nf file below it.
span 🔒
token 🔒

Structs§

Diagnostic
An error in the source, pointing at the text that caused it.
FileId
One source file of a program. Files are numbered in the order they are checked, and the first, FileId::default(), is the project’s entry file.
Note
A secondary place a Diagnostic points at, with what it is.
Parsed
The result of parsing one source file. The tree is complete even when there are diagnostics: parts that failed to parse are skipped or marked ExprKind::Error.
Span
A byte range in the text of one source file.
Token

Enums§

TokenKind

Constants§

ESCAPES
The characters that may follow \\ in a string.
KEYWORDS
Every keyword; TokenKind::text spells them.
SYMBOLS
Every punctuation and operator token; TokenKind::text spells them.

Functions§

parse
Parses the text of file; every span in the result points into it.
string_literal
text as a Nifty string literal, quotes included, with every special character escaped.
tokens
The tokens of source, ending with Eof. Lexing errors are left to parse.