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.nfand every.nffile 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
Diagnosticpoints 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§
Constants§
- ESCAPES
- The characters that may follow
\\in a string. - KEYWORDS
- Every keyword;
TokenKind::textspells them. - SYMBOLS
- Every punctuation and operator token;
TokenKind::textspells them.
Functions§
- parse
- Parses the text of
file; every span in the result points into it. - string_
literal textas a Nifty string literal, quotes included, with every special character escaped.- tokens
- The tokens of
source, ending withEof. Lexing errors are left toparse.