master
theFox6 2021-02-16 21:51:05 +01:00 committed by GitHub
parent 1ec9e925bc
commit 1282e6c8ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 0 deletions

6
misc/addinput.rf Normal file
View File

@ -0,0 +1,6 @@
> 0 2 5 * v
v "Please enter two integers: " <
> : v v "sum: " <
^ , _ & & + 0 ^
> : v
^ , _ $ . 2 5 * , @

2
misc/cat.rf Normal file
View File

@ -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

3
misc/reverseln.rf Normal file
View File

@ -0,0 +1,3 @@
> 0 2 5 * > ~ : 5 v
| - * 2 <
@ _ #! #, #:<

View File

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