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,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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
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