#[non_exhaustive]pub enum SyntaxError {
Show 98 variants
IncompleteEscape,
InvalidEscape,
UnclosedParen {
opening_location: Location,
},
UnclosedSingleQuote {
opening_location: Location,
},
UnclosedDoubleQuote {
opening_location: Location,
},
UnclosedDollarSingleQuote {
opening_location: Location,
},
UnclosedParam {
opening_location: Location,
},
EmptyParam,
InvalidParam,
InvalidModifier,
MultipleModifier,
UnclosedCommandSubstitution {
opening_location: Location,
},
UnclosedBackquote {
opening_location: Location,
},
UnclosedArith {
opening_location: Location,
},
InvalidCommandToken,
MissingSeparator,
FdOutOfRange,
InvalidIoLocation,
MissingRedirOperand,
MissingHereDocDelimiter,
MissingHereDocContent,
UnclosedHereDocContent {
redir_op_location: Location,
},
UnclosedArrayValue {
opening_location: Location,
},
UnopenedGrouping,
UnclosedGrouping {
opening_location: Location,
},
EmptyGrouping,
UnopenedSubshell,
UnclosedSubshell {
opening_location: Location,
},
EmptySubshell,
UnopenedLoop,
UnopenedDoClause,
UnclosedDoClause {
opening_location: Location,
},
EmptyDoClause,
MissingForName,
InvalidForName,
InvalidForValue,
MissingForBody {
opening_location: Location,
},
UnclosedWhileClause {
opening_location: Location,
},
EmptyWhileCondition,
UnclosedUntilClause {
opening_location: Location,
},
EmptyUntilCondition,
IfMissingThen {
if_location: Location,
},
EmptyIfCondition,
EmptyIfBody,
ElifMissingThen {
elif_location: Location,
},
EmptyElifCondition,
EmptyElifBody,
EmptyElse,
UnopenedIf,
UnclosedIf {
opening_location: Location,
},
MissingCaseSubject,
InvalidCaseSubject,
MissingIn {
opening_location: Location,
},
UnclosedPatternList,
MissingPattern,
InvalidPattern,
EsacAsPattern,
UnopenedCase,
UnclosedCase {
opening_location: Location,
},
UnmatchedParenthesis,
MissingFunctionBody,
InvalidFunctionBody,
InAsCommandName,
CloseBracketBracketAsCommandName,
MissingPipeline(AndOr),
DoubleNegation,
BangAfterBar,
MissingCommandAfterBang,
MissingCommandAfterBar,
RedundantToken,
IncompleteControlEscape,
IncompleteControlBackslashEscape,
InvalidControlEscape,
OctalEscapeOutOfRange,
IncompleteHexEscape,
IncompleteShortUnicodeEscape,
IncompleteLongUnicodeEscape,
UnicodeEscapeOutOfRange,
UnsupportedFunctionDefinitionSyntax,
UnsupportedDoubleBracketCommand,
UnsupportedNamespaceCommand,
UnsupportedSelectCommand,
UnsupportedProcessRedirection,
UnsupportedArithmeticCommand,
UnsupportedExtendedGlob,
NonPortableCaseTerminator(Operator),
NonPortableRedirOperator(RedirOp),
IoTokenAsRedirOperand,
MissingSeparatorBeforeReservedWord,
ColonSuffixedCommandName,
NonPortableEscape,
TooLongHexEscape,
NonPortableForName,
NonPortableFunctionName,
NonPortableAssignmentName,
ArrayAssignment,
SpecialBuiltinFunctionName,
NonPortableParamModifier,
}Expand description
Types of syntax errors
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
IncompleteEscape
A backslash is at the end of the input.
InvalidEscape
A backslash is not followed by a character that makes a valid escape.
UnclosedParen
A ( lacks a closing ).
UnclosedSingleQuote
A single quotation lacks a closing '.
UnclosedDoubleQuote
A double quotation lacks a closing ".
UnclosedDollarSingleQuote
A $' lacks a closing '.
UnclosedParam
A parameter expansion lacks a closing }.
EmptyParam
A parameter expansion lacks a name.
InvalidParam
A parameter expansion has an invalid name.
InvalidModifier
A modifier does not have a valid form in a parameter expansion.
MultipleModifier
A braced parameter expansion has both a prefix and suffix modifier.
UnclosedCommandSubstitution
A command substitution started with $( but lacks a closing ).
UnclosedBackquote
A command substitution started with ` but lacks a closing `.
UnclosedArith
An arithmetic expansion lacks a closing )).
InvalidCommandToken
A command begins with an inappropriate keyword or operator token.
MissingSeparator
A separator is missing between commands.
FdOutOfRange
The file descriptor specified for a redirection cannot be used.
InvalidIoLocation
An I/O location prefix attached to a redirection has an unsupported format.
MissingRedirOperand
A redirection operator is missing its operand.
MissingHereDocDelimiter
A here-document operator is missing its delimiter token.
MissingHereDocContent
A here-document operator is missing its corresponding content.
UnclosedHereDocContent
A here-document content is missing its delimiter.
UnclosedArrayValue
An array assignment started with =( but lacks a closing ).
UnopenedGrouping
A } appears without a matching {.
UnclosedGrouping
A grouping is not closed.
EmptyGrouping
A grouping contains no commands.
UnopenedSubshell
A ) appears without a matching (.
UnclosedSubshell
A subshell is not closed.
EmptySubshell
A subshell contains no commands.
UnopenedLoop
A do appears outside a loop.
UnopenedDoClause
A done appears outside a loop.
UnclosedDoClause
A do clause is not closed.
EmptyDoClause
A do clause contains no commands.
MissingForName
The variable name is missing in a for loop.
InvalidForName
The variable name is not a valid word in a for loop.
InvalidForValue
A value is not a valid word in a for loop.
MissingForBody
A for loop is missing a do clause.
UnclosedWhileClause
A while loop is missing a do clause.
EmptyWhileCondition
A while loop’s condition is empty.
UnclosedUntilClause
An until loop is missing a do clause.
EmptyUntilCondition
An until loop’s condition is empty.
IfMissingThen
An if command is missing the then clause.
EmptyIfCondition
An if command’s condition is empty.
EmptyIfBody
An if command’s body is empty.
ElifMissingThen
An elif clause is missing the then clause.
EmptyElifCondition
An elif clause’s condition is empty.
EmptyElifBody
An elif clause’s body is empty.
EmptyElse
An else clause is empty.
UnopenedIf
An elif, else, then, or fi appears outside an if command.
UnclosedIf
An if command is not closed.
MissingCaseSubject
The case command is missing its subject.
InvalidCaseSubject
The subject of the case command is not a valid word.
MissingIn
The case command is missing in after the subject.
UnclosedPatternList
The ) is missing in a case item.
MissingPattern
The pattern is missing in a case item.
InvalidPattern
The pattern is not a valid word token.
EsacAsPattern
this error no longer occurs
The first pattern of a case item is esac.
UnopenedCase
An esac or ;; appears outside a case command.
UnclosedCase
A case command is not closed.
UnmatchedParenthesis
The ( is not followed by ) in a function definition.
MissingFunctionBody
The function body is missing in a function definition command.
InvalidFunctionBody
A function body is not a compound command.
InAsCommandName
The keyword in is used as a command name.
CloseBracketBracketAsCommandName
The keyword ]] is used as a command name.
MissingPipeline(AndOr)
A pipeline is missing after a && or || token.
DoubleNegation
Two successive ! tokens.
BangAfterBar
A | token is followed by a !.
MissingCommandAfterBang
A command is missing after a ! token.
MissingCommandAfterBar
A command is missing after a | token.
RedundantToken
There is a redundant token.
IncompleteControlEscape
A control escape (\c...) is incomplete in a dollar-single-quoted string.
IncompleteControlBackslashEscape
A control-backslash escape (\c\\) is incomplete in a dollar-single-quoted string.
InvalidControlEscape
A control escape (\c...) does not have a valid control character.
OctalEscapeOutOfRange
An octal escape is out of range (greater than \377) in a dollar-single-quoted string.
IncompleteHexEscape
An hexadecimal escape (\x...) is incomplete in a dollar-single-quoted string.
IncompleteShortUnicodeEscape
A Unicode escape (\u...) is incomplete in a dollar-single-quoted string.
IncompleteLongUnicodeEscape
A Unicode escape (\U...) is incomplete in a dollar-single-quoted string.
UnicodeEscapeOutOfRange
A Unicode escape (\u... or \U...) is out of range in a dollar-single-quoted string.
UnsupportedFunctionDefinitionSyntax
The unsupported version of function definition syntax is used.
UnsupportedDoubleBracketCommand
A [[ ... ]] command is used.
UnsupportedNamespaceCommand
A namespace command is used.
UnsupportedSelectCommand
A select command is used.
UnsupportedProcessRedirection
A process redirection (>(...) or <(...)) is used.
UnsupportedArithmeticCommand
A ((...)) arithmetic command is used at the beginning of a command
while the portable option is on.
yash-rs parses (( as nested subshells, but other shells parse it as an
arithmetic command, which yash-rs does not support. The portable option
rejects this ambiguous form; insert a space (( () for nested subshells.
UnsupportedExtendedGlob
A !(...) extended glob is used at the beginning of a command while the
portable option is on.
yash-rs parses !( as the ! reserved word followed by a subshell, but
other shells parse it as an extended glob, which yash-rs does not support.
The portable option rejects this ambiguous form; insert a space (! ().
NonPortableCaseTerminator(Operator)
A ;;& or ;| case terminator is used while the portable option is on.
The operator is the offending terminator (SemicolonSemicolonAnd or
SemicolonBar).
NonPortableRedirOperator(RedirOp)
A non-portable redirection operator (>>| or <<<) is used while the
portable option is on.
The operator is the offending redirection operator (Pipe or String).
IoTokenAsRedirOperand
An IO_NUMBER or IO_LOCATION token appears as a redirection operand
while the portable option is on.
This happens when a token that should be a redirection operand is
immediately followed by a redirection operator without a separating
space, so yash-rs lexes it as an IO_NUMBER or IO_LOCATION token (as
in the 1 in < 1>file). POSIX does not recognize such a token as a
redirection operand, so this form is not portable.
MissingSeparatorBeforeReservedWord
A reserved word follows a subshell or a redirection without a separator
while the portable option is on (as in { ( : ) } or
for i in 1; do ( : ) done).
POSIX recognizes a reserved word only when it is the first word of a
command or follows another reserved word. A subshell ends with the )
operator and a redirection ends with a word, so a clause-delimiting
reserved word (such as }, done, or fi) that immediately follows one
is not portably recognized.
ColonSuffixedCommandName
A command name ends with a : while the portable option is on.
POSIX reserves words whose final character is a : for possible future
use, so such a word produces unspecified results when used where a
reserved word would be recognized (such as a command name). The lone
: (the colon built-in) is not affected.
NonPortableEscape
A non-portable escape sequence is used in a dollar-single-quoted string
while the portable option is on.
POSIX specifies a limited set of escape sequences for $'...'. This is
raised for yash extensions such as \E, \?, \u, \U, and \c@.
TooLongHexEscape
A \x escape in a dollar-single-quoted string is followed by more than
two hexadecimal digits while the portable option is on.
POSIX leaves the result unspecified if more than two hexadecimal digits
follow \x, so such an escape is not portable.
NonPortableForName
A for loop variable name is not a portable name while the portable
option is on.
POSIX requires the name to be an unquoted NAME token consisting
solely of underscores, digits, and alphabetics from the portable
character set, not starting with a digit. This is raised when the name
is quoted, contains an expansion, or otherwise does not meet this
requirement.
NonPortableFunctionName
A function name is not a portable name while the portable option is
on.
POSIX requires the name to be an unquoted NAME token consisting
solely of underscores, digits, and alphabetics from the portable
character set, not starting with a digit. This is raised when the name
is quoted, contains an expansion, or otherwise does not meet this
requirement.
NonPortableAssignmentName
An assignment name is not a portable name while the portable option
is on.
A portable name consists solely of underscores, digits, and alphabetics from the portable character set, not starting with a digit. This is raised when the assignment name does not meet this form, since other POSIX-conforming shells may not support it.
ArrayAssignment
An array assignment (name=(...)) is used while the portable option
is on.
Array assignment is a yash extension that POSIX does not specify, so other POSIX-conforming shells may not support it.
SpecialBuiltinFunctionName
A function name is the same as a special built-in utility name while
the portable option is on.
POSIX does not allow a function to have the same name as a special
built-in utility. See
POSIX_SPECIAL_BUILTIN_NAMES
for the list of names this applies to.
NonPortableParamModifier
A parameter expansion combines a special parameter with a modifier whose
result POSIX leaves unspecified, while the portable option is on.
POSIX leaves the result unspecified for a length or switch modifier
applied to the special parameter * or @ (as in ${#*} or
${@:-x}), and for a trim modifier applied to the special parameter
#, *, or @ (as in ${#%x} or ${*#x}).
Implementations§
Source§impl SyntaxError
impl SyntaxError
Sourcepub fn footnotes(&self) -> &'static [(FootnoteType, &'static str)]
pub fn footnotes(&self) -> &'static [(FootnoteType, &'static str)]
Returns footnotes that supplement the error message.
Each item pairs a FootnoteType with its text. The footnotes are to
be rendered after the error’s source code snippet. The slice is empty
for errors that need no footnote.
Returns a location related with the error cause and a message describing the location.
Trait Implementations§
Source§impl Clone for SyntaxError
impl Clone for SyntaxError
Source§fn clone(&self) -> SyntaxError
fn clone(&self) -> SyntaxError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SyntaxError
impl Debug for SyntaxError
Source§impl Display for SyntaxError
impl Display for SyntaxError
impl Eq for SyntaxError
Source§impl Error for SyntaxError
impl Error for SyntaxError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<SyntaxError> for ErrorCause
impl From<SyntaxError> for ErrorCause
Source§fn from(source: SyntaxError) -> Self
fn from(source: SyntaxError) -> Self
Source§impl PartialEq for SyntaxError
impl PartialEq for SyntaxError
impl StructuralPartialEq for SyntaxError
Auto Trait Implementations§
impl !RefUnwindSafe for SyntaxError
impl !Send for SyntaxError
impl !Sync for SyntaxError
impl !UnwindSafe for SyntaxError
impl Freeze for SyntaxError
impl Unpin for SyntaxError
impl UnsafeUnpin for SyntaxError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more