yash_syntax/
decl_util.rs

1// This file is part of yash, an extended POSIX shell.
2// Copyright (C) 2024 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//! Items for parsing declaration utilities
18//!
19//! This module re-exports utilities for parsing declaration utilities from the
20//! `yash-env` crate. See the documentation of the [`yash_env::decl_util`]
21//! module for details.
22//!
23//! # Parser behavior
24//!
25//! When the [parser] recognizes a command name as a declaration utility,
26//! command words that follow the command name are tested for the form of
27//! variable assignments. If a word is a variable assignment, it is parsed as
28//! such: the word is split into a variable name and a value, and tilde expansions
29//! are parsed with the [`parse_tilde_everywhere_after`] method in the value part.
30//! The result word is marked with [`ExpansionMode::Single`] in
31//! [`SimpleCommand::words`] to indicate that the word is not subject to field
32//! splitting and pathname expansion. If a word is not a variable assignment, it
33//! is parsed as a normal command word with [`parse_tilde_front`] and marked with
34//! [`ExpansionMode::Multiple`].
35//!
36//! The shell is expected to change the expansion behavior of the words based on
37//! the [`ExpansionMode`] of the words. In yash-rs, the semantics is implemented
38//! in the `yash-semantics` crate.
39//!
40//! [parser]: crate::parser
41//! [`parse_tilde_front`]: crate::syntax::Word::parse_tilde_front
42//! [`parse_tilde_everywhere_after`]: crate::syntax::Word::parse_tilde_everywhere_after
43//! [`ExpansionMode`]: crate::syntax::ExpansionMode
44//! [`ExpansionMode::Multiple`]: crate::syntax::ExpansionMode::Multiple
45//! [`ExpansionMode::Single`]: crate::syntax::ExpansionMode::Single
46//! [`SimpleCommand::words`]: crate::syntax::SimpleCommand::words
47
48#[doc(no_inline)]
49pub use yash_env::decl_util::*;