yash_syntax/
lib.rs

1// This file is part of yash, an extended POSIX shell.
2// Copyright (C) 2021 WATANABE Yuki
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
17//! Shell language syntax and parser
18//!
19//! This crate defines data types for constructing abstract syntax trees (AST)
20//! of the shell language. See the [`syntax`] module for details.
21//!
22//! Some AST elements (e.g. [`Word`](syntax::Word)) provide a
23//! [location](source::Location) where the element appears in the source code.
24//! See the [`source`] module to learn how locations are coded in this crate.
25//!
26//! To parse source code into an AST, you can use the `parse` function on a
27//! `&str`, which is enabled by the implementations of
28//! [`FromStr`](std::str::FromStr) for the AST data types. However, ASTs
29//! constructed this way do not contain very meaningful source information: All
30//! locations' source will be [unknown](source::Source::Unknown). To include
31//! substantial source information, you need to prepare a
32//! [lexer](parser::lex::Lexer) with source information and then pass it to a
33//! [parser](parser::Parser). See the [`parser`] module for details.
34//!
35//! The [`input`] module defines an abstract method for feeding the parser with
36//! source code.
37//!
38//! This crate also defines the [`alias`] module that can be used to define
39//! aliases that are recognized while parsing.
40
41pub mod alias;
42pub mod decl_util;
43pub mod input;
44pub mod parser;
45pub mod source;
46pub mod syntax;