Add stream.er

This commit is contained in:
Shunsuke Shibayama 2022-11-16 08:27:33 +09:00
parent 48f8ef3788
commit f3a5d31ec4
4 changed files with 24 additions and 10 deletions

View file

@ -1081,9 +1081,14 @@ pub struct Call {
impl NestedDisplay for Call {
fn fmt_nest(&self, f: &mut std::fmt::Formatter<'_>, level: usize) -> std::fmt::Result {
writeln!(f, "({}){}:", self.obj, fmt_option!(self.attr_name),)?;
writeln!(f, "({}){}", self.obj, fmt_option!(self.attr_name),)?;
if self.args.is_empty() {
write!(f, "()")
} else {
writeln!(f, ":")?;
self.args.fmt_nest(f, level + 1)
}
}
}
impl_display_from_nested!(Call);

View file

@ -1017,9 +1017,13 @@ impl NestedDisplay for Call {
if let Some(attr_name) = self.attr_name.as_ref() {
write!(f, "{}", attr_name)?;
}
if self.args.is_empty() {
write!(f, "()")
} else {
writeln!(f, ":")?;
self.args.fmt_nest(f, level + 1)
}
}
}
impl_display_from_nested!(Call);

View file

@ -2173,11 +2173,14 @@ impl Parser {
self.skip(); // |>
fn get_stream_op_syntax_error(loc: Location) -> ParseError {
ParseError::syntax_error(0, loc, switch_lang!(
ParseError::syntax_error(
0,
loc,
switch_lang!(
"japanese" => "パイプ演算子の後には関数・メソッド・サブルーチン呼び出しのみが使用できます。",
"english" => "Only a call of function, method or subroutine is available after stream operator.",
),
None
None,
)
}

View file

@ -0,0 +1,2 @@
print!(1 + 1 |> f())
print!(1 + 1 |> .abs())