Skip to main content

blue_lang_syntax/
lib.rs

1//! blue's surface syntax.
2//!
3//! Blue is a general-purpose language whose surface is Ruby/Elixir-shaped
4//! and whose **program is a tatara-lisp value**. This crate is the join:
5//! it lexes blue source and parses it directly into `tatara_lisp::Sexp`.
6//!
7//! There is deliberately no private blue AST in between. Tenet 1 of
8//! `theory/BLUE.md` is that blue source parses *to tatara-lisp*, and an
9//! intermediate tree would make homoiconicity a conversion step rather
10//! than an identity — the difference between blue's macro story working
11//! and merely being asserted.
12//!
13//! ```
14//! use blue_lang_syntax::parse_expr;
15//! let form = parse_expr("user.greet(1)").unwrap();
16//! assert_eq!(form.to_string(), "(greet user 1)");
17//! ```
18
19pub mod forms;
20pub mod kigou;
21pub mod lex;
22pub mod parse;
23pub mod scope;
24pub mod yakugo;
25
26pub use forms::{Form, FORMS};
27pub use lex::{lex, LexError, Span, Token, TokenKind};
28// Re-exported so a consumer walking blue trees does not have to depend on
29// tatara-lisp directly just to name the node types blue emits.
30pub use parse::{
31    comments, is_callable_name, is_reserved_word, keyword_doc, parse_expr, parse_program,
32    parse_program_in, parse_program_spanned, parse_program_spanned_with_depth, parse_program_tree,
33    parse_program_tree_in, parse_program_tree_with_depth, parse_program_with_depth, qualified,
34    qualify, Comment, Infix, ParseError, BLOCK_KEYWORDS, BUILTIN_QUALIFIER, INFIX, LOWERED_ASSERT,
35    LOWERED_CONCAT, LOWERED_MAP, MAX_EXPR_DEPTH, QUALIFIER, SURFACE_KEYWORDS,
36};
37// `Spanned`/`SpannedForm` alongside `Sexp` for the same reason `Sexp` is here:
38// the parser's real output is the spanned tree, and a consumer that wants a
39// position should not have to add a tatara-lisp dependency to name the node it
40// got a span from.
41pub use tatara_lisp::{Atom, Sexp, Spanned, SpannedForm};