An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
May 29, 2020 08:17 pm GMT
Original Link: https://dev.to/awwsmm/i-wrote-a-brainf-interpreter-in-typescript-e96
I Wrote a BrainF*** Interpreter and REPL in TypeScript!
Photo by Robina Weermeijer on Unsplash
This was my first time ever coding in TypeScript, my first npm package, and more. Let me know if you have any comments or suggestions!
Try out the sample code on the GitHub repo!
awwsmm / BrainScript
A BrainF*** interpreter written in TypeScript
BrainScript
A BrainF*** (BF) interpreter and REPL, written in TypeScript.
Installation
Install from npm with
$ npm i brainscript
Or try it online at npm.runkit.com
var lib = require("brainscript")lib.bf("++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.")
Use
BrainScript provides a BF interpreter bf
which can be used in interactive or batch mode, as well as a BF REPL brain
.
bf
can be used to batch process BF code, returning any resulting output as a string
const output: string = bf("++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.")console.log(output) // Hello World!\n
...but it also provides basic interactive capabilities for programs which require user input
// input.tsconsole.log(bf(",."))
$ npx ts-node input.ts Please provide a single character for ',' input: : !!
brain
is an interactive REPL which accepts single- or
Original Link: https://dev.to/awwsmm/i-wrote-a-brainf-interpreter-in-typescript-e96
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To