mirror of
https://github.com/Noratrieb/brainfuck.git
synced 2026-03-16 00:46:04 +01:00
interpreter
This commit is contained in:
parent
b30fa04dcc
commit
e815fd8c66
8 changed files with 647 additions and 19 deletions
23
ibfi-ts/src/components/CodeInput.tsx
Normal file
23
ibfi-ts/src/components/CodeInput.tsx
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import React, {useState} from 'react';
|
||||
|
||||
interface CodeInputProps {
|
||||
setInput: ((input: string) => void),
|
||||
}
|
||||
|
||||
const CodeInput = ({setInput}: CodeInputProps) => {
|
||||
const [fontSize, setFontSize] = useState(40);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="bf-input">
|
||||
<div>
|
||||
<label htmlFor="bf-input-fontsize-range">Font Size</label>
|
||||
<input type="range" id="bf-input-fontsize-range" onChange={v => setFontSize(+v.target.value)}/>
|
||||
</div>
|
||||
<textarea onChange={e => setInput(e.target.value)} style={{fontSize}} className="code-input" placeholder="Input your code here..."/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CodeInput;
|
||||
15
ibfi-ts/src/components/ProgramOutput.tsx
Normal file
15
ibfi-ts/src/components/ProgramOutput.tsx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import React from 'react';
|
||||
|
||||
interface ProgramOutputProps {
|
||||
text: string
|
||||
}
|
||||
|
||||
const ProgramOutput = ({text}: ProgramOutputProps) => {
|
||||
return (
|
||||
<div className="bf-output">
|
||||
<textarea readOnly className="output-area" value={text}/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProgramOutput;
|
||||
28
ibfi-ts/src/components/RunInfo.tsx
Normal file
28
ibfi-ts/src/components/RunInfo.tsx
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import React from 'react';
|
||||
import Interpreter from "../brainfuck/Interpreter";
|
||||
|
||||
interface RunInfoProps {
|
||||
nextHandler: () => void,
|
||||
prevHandler: () => void,
|
||||
startHandler: () => void,
|
||||
interpreter: Interpreter | null,
|
||||
}
|
||||
|
||||
const RunInfo = ({interpreter, ...props}: RunInfoProps) => {
|
||||
return (
|
||||
<div className="bf-run">
|
||||
<div>
|
||||
<button onClick={props.startHandler}>Start</button>
|
||||
<button onClick={props.nextHandler}>Next</button>
|
||||
<button onClick={props.prevHandler}>Previous</button>
|
||||
</div>
|
||||
|
||||
{interpreter &&
|
||||
<div>Pointer: {interpreter.pointer} value {interpreter.value}</div>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
;
|
||||
|
||||
export default RunInfo;
|
||||
Loading…
Add table
Add a link
Reference in a new issue