ここに yash の文法の形式的定義を示します。Yash の文法は解析表現文法で定義されます。
Yash の文法における終端記号の集合は、yash を実行する環境が扱える任意の文字の集合 (実行文字集合) です (ただしナル文字 '\0' を除く)。
以下は、yash の文法を構成する非終端記号とそれに対応する終端記号の一覧です。ただしここに挙げる文法の定義にはヒアドキュメントの内容とその終わりを表す行の解析のための規則は含まれていません。また POSIX 準拠モードでは構文が若干変わりますが、ここには示しません。
- CompleteCommand
- Sequence
- List
-
Pipeline ((
&&/||) N* Pipeline)* ListSeparator - Pipeline
- Command
-
CompoundCommand Redirection* /
!R FunctionDefinition /
!R SimpleCommand - CompoundCommand
-
Subshell /
Grouping /
IfCommand /
ForCommand /
WhileCommand /
CaseCommand /
FunctionCommand - Subshell
- Grouping
- IfCommand
-
If Sequence Then Sequence (Elif Sequence Then Sequence)* (Else Sequence)? Fi
- ForCommand
-
For Name S* Separator? (In Word* Separator)? Do Sequence Done
- WhileCommand
- CaseCommand
- CaseItem
- FunctionCommand
-
Function Word (
(S*))? N* CompoundCommand Redirection* - FunctionDefinition
-
Name S*
(S*)N* CompoundCommand Redirection* - SimpleCommand
-
&(Word / Redirection) (Assignment / Redirection)* (Word / Redirection)*
- Assignment
- Name
-
![[:digit:]] [[:alnum:]
_]+ - PortableName
-
![
0-9] [0-9ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]+ - Word
-
(WordElement / !SpecialChar .)+ S*
- WordElement
-
\. /
'(!'.)*'/
"QuoteElement*"/
Parameter /
Arithmetic /
CommandSubstitution - QuoteElement
-
\([$`"\] / NL) /
Parameter /
Arithmetic /
CommandSubstitution /
![`"\] . - Parameter
-
$[@*#?-$![:digit:]] /
$PortableName /
$ParameterBody - ParameterBody
-
{ParameterNumber? (ParameterName / ParameterBody / Parameter) ParameterIndex? ParameterMatch?} - ParameterNumber
-
#![+=:/%] !([-?#]}) - ParameterName
-
[
@*#?-$!] /
[[:alnum:]_]+ - ParameterIndex
-
[ParameterIndexWord (,ParameterIndexWord)?] - ParameterIndexWord
-
(WordElement / ![
"'],] .)+ - ParameterMatch
-
:? [-+=?] ParameterMatchWord /
(#/##/%/%%) ParameterMatchWord /
(:///[#%/]?) ParameterMatchWordNoSlash (/ParameterMatchWord)? - ParameterMatchWord
-
(WordElement / ![
"'}] .)* - ParameterMatchWordNoSlash
-
(WordElement / ![
"'/}] .)* - Arithmetic
-
$((ArithmeticBody*)) - ArithmeticBody
-
\. /
Parameter /
Arithmetic /
CommandSubstitution /
(ArithmeticBody)/
![`()] . - CommandSubstitution
-
$(Sequence)/
`CommandSubstitutionBody*` - CommandSubstitutionBody
-
\[$`\] /
!`. - Redirection
-
RedirectionFD RedirectionOperator S* Word /
RedirectionFD<(Sequence)/
RedirectionFD>(Sequence) - RedirectionFD
-
[[:digit:]]*
- RedirectionOperator
-
</<>/>/>|/>>/>>|/<&/>&/<</<<-/<<< - ListSeparator
- Separator
- N
- S
-
[[:blank:]] /
Comment - Comment
-
#(!NL .)* - R
-
Bang / LeftBrace / RightBrace / Case / Do / Done / Elif / Else / Esac / Fi / For / If / In / Then / Until / While
- Bang
-
!D - LeftBrace
-
{D - RightBrace
-
}D - Case
-
caseD - Do
-
doD - Done
-
doneD - Elif
-
elifD - Else
-
elseD - Esac
-
esacD - Fi
-
fiD - For
-
forD - Function
-
functionD - If
-
ifD - In
-
inD - Then
-
thenD - Until
-
untilD - While
-
whileD - D
- SpecialChar
-
[
|&;<>()`\"'[:blank:]] / NL - NL
-
<newline>
- EOF
-
!.