Add io (#4)
parent
1ec9e925bc
commit
1282e6c8ec
|
@ -0,0 +1,6 @@
|
|||
> 0 2 5 * v
|
||||
v "Please enter two integers: " <
|
||||
> : v v "sum: " <
|
||||
^ , _ & & + 0 ^
|
||||
> : v
|
||||
^ , _ $ . 2 5 * , @
|
|
@ -0,0 +1,2 @@
|
|||
>#v v#!< this program outputs the lines it reads
|
||||
@,_,>~:^ in a bash console you can send an EOF with ctrl+D
|
|
@ -0,0 +1,3 @@
|
|||
> 0 2 5 * > ~ : 5 v
|
||||
| - * 2 <
|
||||
@ _ #! #, #:<
|
|
@ -398,6 +398,29 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class ReadCharSR : public Subroutine
|
||||
{
|
||||
public:
|
||||
virtual void run(VM *vm, Thread *th)
|
||||
{
|
||||
char ch;
|
||||
std::cin >> std::noskipws >> ch;
|
||||
th->push(ch);
|
||||
th->move();
|
||||
}
|
||||
};
|
||||
|
||||
class ReadNumSR : public Subroutine
|
||||
{
|
||||
public:
|
||||
virtual void run(VM *vm, Thread *th)
|
||||
{
|
||||
int i;
|
||||
std::cin >> i;
|
||||
th->push(i);
|
||||
th->move();
|
||||
}
|
||||
};
|
||||
|
||||
class TemplateSR : public Subroutine
|
||||
{
|
||||
|
@ -440,6 +463,8 @@ void assignStandardSR(Thread *th)
|
|||
th->setOperator('[', 22);
|
||||
th->setOperator('R', 23);
|
||||
th->setOperator('P', 24);
|
||||
th->setOperator('~', 25);
|
||||
th->setOperator('&', 26);
|
||||
|
||||
// TODO: & ~ M L
|
||||
}
|
||||
|
@ -469,4 +494,6 @@ void loadSubroutines(VM *vm) {
|
|||
vm->loadSubroutine(new BridgeSR);
|
||||
vm->loadSubroutine(new RtnSR);
|
||||
vm->loadSubroutine(new LoadSR);
|
||||
vm->loadSubroutine(new ReadCharSR);
|
||||
vm->loadSubroutine(new ReadNumSR);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue