mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 20:34:44 +00:00
Add stream.er
This commit is contained in:
parent
48f8ef3788
commit
f3a5d31ec4
4 changed files with 24 additions and 10 deletions
|
@ -1081,10 +1081,15 @@ pub struct Call {
|
||||||
|
|
||||||
impl NestedDisplay for Call {
|
impl NestedDisplay for Call {
|
||||||
fn fmt_nest(&self, f: &mut std::fmt::Formatter<'_>, level: usize) -> std::fmt::Result {
|
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)
|
self.args.fmt_nest(f, level + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl_display_from_nested!(Call);
|
impl_display_from_nested!(Call);
|
||||||
|
|
||||||
|
|
|
@ -1017,10 +1017,14 @@ impl NestedDisplay for Call {
|
||||||
if let Some(attr_name) = self.attr_name.as_ref() {
|
if let Some(attr_name) = self.attr_name.as_ref() {
|
||||||
write!(f, "{}", attr_name)?;
|
write!(f, "{}", attr_name)?;
|
||||||
}
|
}
|
||||||
|
if self.args.is_empty() {
|
||||||
|
write!(f, "()")
|
||||||
|
} else {
|
||||||
writeln!(f, ":")?;
|
writeln!(f, ":")?;
|
||||||
self.args.fmt_nest(f, level + 1)
|
self.args.fmt_nest(f, level + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl_display_from_nested!(Call);
|
impl_display_from_nested!(Call);
|
||||||
|
|
||||||
|
|
|
@ -2173,11 +2173,14 @@ impl Parser {
|
||||||
self.skip(); // |>
|
self.skip(); // |>
|
||||||
|
|
||||||
fn get_stream_op_syntax_error(loc: Location) -> ParseError {
|
fn get_stream_op_syntax_error(loc: Location) -> ParseError {
|
||||||
ParseError::syntax_error(0, loc, switch_lang!(
|
ParseError::syntax_error(
|
||||||
|
0,
|
||||||
|
loc,
|
||||||
|
switch_lang!(
|
||||||
"japanese" => "パイプ演算子の後には関数・メソッド・サブルーチン呼び出しのみが使用できます。",
|
"japanese" => "パイプ演算子の後には関数・メソッド・サブルーチン呼び出しのみが使用できます。",
|
||||||
"english" => "Only a call of function, method or subroutine is available after stream operator.",
|
"english" => "Only a call of function, method or subroutine is available after stream operator.",
|
||||||
),
|
),
|
||||||
None
|
None,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
compiler/erg_parser/tests/stream.er
Normal file
2
compiler/erg_parser/tests/stream.er
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
print!(1 + 1 |> f())
|
||||||
|
print!(1 + 1 |> .abs())
|
Loading…
Add table
Add a link
Reference in a new issue