Skip to main content

Crate blue_lang_syntax

Crate blue_lang_syntax 

Source
Expand description

blue’s surface syntax.

Blue is a general-purpose language whose surface is Ruby/Elixir-shaped and whose program is a tatara-lisp value. This crate is the join: it lexes blue source and parses it directly into tatara_lisp::Sexp.

There is deliberately no private blue AST in between. Tenet 1 of theory/BLUE.md is that blue source parses to tatara-lisp, and an intermediate tree would make homoiconicity a conversion step rather than an identity — the difference between blue’s macro story working and merely being asserted.

use blue_lang_syntax::parse_expr;
let form = parse_expr("user.greet(1)").unwrap();
assert_eq!(form.to_string(), "(greet user 1)");

Re-exports§

pub use forms::Form;
pub use forms::FORMS;
pub use lex::lex;
pub use lex::LexError;
pub use lex::Token;
pub use lex::TokenKind;
pub use parse::comments;
pub use parse::is_callable_name;
pub use parse::is_reserved_word;
pub use parse::keyword_doc;
pub use parse::parse_expr;
pub use parse::parse_program;
pub use parse::parse_program_documented;
pub use parse::parse_program_documented_with_depth;
pub use parse::parse_program_in;
pub use parse::parse_program_spanned;
pub use parse::parse_program_spanned_with_depth;
pub use parse::parse_program_tree;
pub use parse::parse_program_tree_in;
pub use parse::parse_program_tree_with_depth;
pub use parse::parse_program_with_depth;
pub use parse::parses_on_this_thread;
pub use parse::qualified;
pub use parse::qualify;
pub use parse::spelling_notes;
pub use parse::Comment;
pub use parse::Infix;
pub use parse::ParseError;
pub use parse::BLOCK_KEYWORDS;
pub use parse::BUILTIN_QUALIFIER;
pub use parse::INFIX;
pub use parse::LOWERED_ASSERT;
pub use parse::LOWERED_ATTEMPTED;
pub use parse::LOWERED_CONCAT;
pub use parse::LOWERED_ENSURE;
pub use parse::LOWERED_ERROR_MATCH;
pub use parse::LOWERED_FAILED;
pub use parse::LOWERED_FIELD;
pub use parse::LOWERED_HEADS;
pub use parse::LOWERED_KWARGS;
pub use parse::LOWERED_MAP;
pub use parse::LOWERED_MERGE;
pub use parse::LOWERED_OPTIONAL_ARG;
pub use parse::LOWERED_OPTIONAL_ARITY;
pub use parse::LOWERED_RERAISE;
pub use parse::LOWERED_SPLICE;
pub use parse::MASTER_VERBS;
pub use parse::MAX_EXPR_DEPTH;
pub use parse::OPERATOR_KEYWORDS;
pub use parse::OPTIONAL_MARKER;
pub use parse::QUALIFIER;
pub use parse::RESCUED;
pub use parse::SURFACE_KEYWORDS;
pub use parse::SYMBOL_SPELLINGS;
pub use spelling::Note;
pub use spelling::Spelling;

Modules§

doc
@doc and @moduledoc: documentation as a typed child of the tree.
forms
The surface forms, one row each: how a form is written, the tatara-lisp tree it lowers to, and one line on what it means.
kigou
kigou (記号) — the character library: which symbols blue understands.
lex
The blue lexer.
parse
Precedence-climbing parser, lowering straight to the tatara-lisp quoted form.
scope
The binder grammar: which forms open a scope, which names they bind, and which symbols are references. One walker, and every pass that needs scopes drives it — the check stage’s name table (blue_lang_check::names) and the capability frame’s reach walk (blue_lang_waku::check_reach_program). Two hand-written walkers used to answer this question, and they disagreed: waku bound a define only at the level of a begin, so a name assigned inside an if branch and read after it was reported as an escape, and it knew no let*, letrec or catch.
spelling
yakugo
yakugo (訳語) — blue’s words, in any human language.

Structs§

Span
A half-open byte range into the source.
Spanned
An S-expression node with source position.

Enums§

Atom
Sexp
SpannedForm
Same variants as Sexp, but children are Spanned so every subtree carries its own position.