diff --git a/src/program.h b/src/program.h index 54d5fbe..8124538 100644 --- a/src/program.h +++ b/src/program.h @@ -223,6 +223,7 @@ class Program : public deque, public Lexer, public Object { void RpnStrsize(); void RpnStrpos(); void RpnStrsub(); + void RpnEndl(); // test-core void RpnTest(); diff --git a/src/rpn-string.cc b/src/rpn-string.cc index 536ad42..d2cab75 100644 --- a/src/rpn-string.cc +++ b/src/rpn-string.cc @@ -94,3 +94,9 @@ void Program::RpnStrsub() { stack_.push(new String(stack_.value(2).substr(first, len))); stack_.erase(1, 3); } + +/// @brief endline character +/// +void Program::RpnEndl() { + stack_.push_front(new String("\n")); +} diff --git a/test/060-string.md b/test/060-string.md index 9ee9705..b32ec5b 100644 --- a/test/060-string.md +++ b/test/060-string.md @@ -305,3 +305,15 @@ -> stack should be "sub" `del` + +## endl 1 +`endl type` + +-> stack should be "string" + +`del` + +## endl 2 +`endl num` + +-> stack should be 10