2014-09-24 16:55:59 +02:00
|
|
|
void test();
|
|
|
|
|
2014-02-11 11:26:28 +01:00
|
|
|
//
|
|
|
|
void nop()
|
|
|
|
{
|
|
|
|
// nop
|
|
|
|
}
|
|
|
|
|
|
|
|
void good_bye()
|
|
|
|
{
|
2014-02-11 14:33:40 +01:00
|
|
|
ERR_CONTEXT(ret_good_bye);
|
2014-02-11 11:26:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void verbose()
|
|
|
|
{
|
|
|
|
MIN_ARGUMENTS(1);
|
2015-02-08 13:35:34 +01:00
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
2014-02-11 11:26:28 +01:00
|
|
|
g_verbose = (int)getf();
|
|
|
|
}
|
|
|
|
|
|
|
|
void help()
|
|
|
|
{
|
2014-09-24 16:55:59 +02:00
|
|
|
cout<<endl;
|
|
|
|
rpn_uname();
|
|
|
|
cout<<endl;
|
|
|
|
|
|
|
|
cout<<"HP28S Reverse Polish Notation language simulator"<<endl;
|
2014-09-03 14:03:19 +02:00
|
|
|
cout<<"syntax: rpn [command]"<<endl;
|
|
|
|
cout<<"with optional command = list of commands"<<endl;
|
2014-02-12 11:26:26 +01:00
|
|
|
for(unsigned int i=0; i<sizeof(_keywords)/sizeof(_keywords[0]); i++)
|
2014-02-11 11:26:28 +01:00
|
|
|
if (_keywords[i].comment.size() != 0)
|
2014-02-11 14:33:40 +01:00
|
|
|
cout<<_keywords[i].name<<"\t"<<_keywords[i].comment<<endl;
|
2014-02-11 11:26:28 +01:00
|
|
|
cout<<endl;
|
2014-09-06 22:31:01 +02:00
|
|
|
cout<<"Current verbosity is "<<g_verbose<<endl;
|
|
|
|
cout<<"Current float mode is ";
|
2015-02-07 14:04:10 +01:00
|
|
|
switch(number::s_mode)
|
2014-09-06 22:31:01 +02:00
|
|
|
{
|
2015-02-07 14:04:10 +01:00
|
|
|
case number::std: cout << "'std'"; break;
|
|
|
|
case number::fix: cout << "'fix'"; break;
|
|
|
|
case number::sci: cout << "'sci'"; break;
|
|
|
|
default: cout << "unknown"; break;
|
|
|
|
}
|
|
|
|
cout<<endl<<"Current float precision is "<<number::s_current_precision<<endl;
|
|
|
|
cout<<"Current binary mode is ";
|
|
|
|
switch(binary::s_mode)
|
|
|
|
{
|
|
|
|
case binary::dec: cout << "'dec'"; break;
|
|
|
|
case binary::hex: cout << "'hex'"; break;
|
|
|
|
case binary::oct: cout << "'oct'"; break;
|
|
|
|
case binary::bin: cout << "'bin'"; break;
|
2014-09-06 22:31:01 +02:00
|
|
|
default: cout << "unknown"; break;
|
|
|
|
}
|
|
|
|
cout<<endl<<endl;
|
2014-02-11 11:26:28 +01:00
|
|
|
}
|
|
|
|
|
2014-09-05 09:49:39 +02:00
|
|
|
void std()
|
|
|
|
{
|
|
|
|
if (stack_size()>=1)
|
|
|
|
{
|
2015-02-08 13:35:34 +01:00
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
2015-02-07 14:04:10 +01:00
|
|
|
number::s_default_precision = (int)getf();
|
2014-09-05 09:49:39 +02:00
|
|
|
}
|
2015-02-07 14:04:10 +01:00
|
|
|
number::s_current_precision = number::s_default_precision;
|
|
|
|
number::s_mode = number::std;
|
2014-09-06 22:31:01 +02:00
|
|
|
|
2015-02-07 14:04:10 +01:00
|
|
|
cout.precision(number::s_current_precision);
|
2014-09-05 09:49:39 +02:00
|
|
|
cout.unsetf(ios_base::floatfield);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fix()
|
|
|
|
{
|
|
|
|
MIN_ARGUMENTS(1);
|
2015-02-08 13:35:34 +01:00
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
2014-09-05 09:49:39 +02:00
|
|
|
|
2015-02-07 14:04:10 +01:00
|
|
|
number::s_current_precision = (int)getf();
|
|
|
|
number::s_mode = number::fix;
|
2014-09-06 22:31:01 +02:00
|
|
|
|
2015-02-07 14:04:10 +01:00
|
|
|
cout << setprecision(number::s_current_precision) << fixed;
|
2014-09-05 09:49:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void sci()
|
|
|
|
{
|
|
|
|
MIN_ARGUMENTS(1);
|
2015-02-08 13:35:34 +01:00
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
2014-09-05 09:49:39 +02:00
|
|
|
|
2015-02-07 14:04:10 +01:00
|
|
|
number::s_current_precision = (int)getf();
|
|
|
|
number::s_mode = number::sci;
|
2014-09-06 22:31:01 +02:00
|
|
|
|
2015-02-07 14:04:10 +01:00
|
|
|
cout << setprecision(number::s_current_precision) << scientific;
|
2014-09-05 09:49:39 +02:00
|
|
|
}
|
2014-09-24 16:55:59 +02:00
|
|
|
|
|
|
|
void rpn_version()
|
|
|
|
{
|
|
|
|
cout << version << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rpn_uname()
|
|
|
|
{
|
|
|
|
cout << uname << endl;
|
|
|
|
}
|