hirnfick
- compileToC
- compileToCpp
- compileToJsBase
- compileToJsDeno
- compileToJsNode
- compileToJsWeb
- compileToPascal
- compileToPython
- compileToQBasic
- compileToRust
▸ compileToC(source
, indentSize?
, indentChar?
): string
Converts a Brainfuck program to C.
Throws
BracketMismatchError if mismatching brackets are detected.
Name | Type | Default value | Description |
---|---|---|---|
source |
string |
undefined |
Brainfuck source to convert. |
indentSize |
number |
4 |
Indentation size. |
indentChar |
string |
' ' |
Indentation character. |
string
Generated C code.
▸ compileToCpp(source
, isMemoryDynamic?
, indentSize?
, indentChar?
): string
Converts a Brainfuck program to C++.
Throws
BracketMismatchError if mismatching brackets are detected.
Name | Type | Default value | Description |
---|---|---|---|
source |
string |
undefined |
Brainfuck source to convert. |
isMemoryDynamic |
boolean |
true |
Enable dynamic memory array. |
indentSize |
number |
4 |
Indentation size. |
indentChar |
string |
' ' |
Indentation character. |
string
Generated C++ code.
▸ compileToJsBase(source
, isMemoryDynamic
, enableUserInput
, indentSize
, indentChar
): Object
Converts a Brainfuck program to JavaScript.
Description
This function is used by compileToJsWeb, compileToJsNode and compileToJsDeno to generate their output. You can use it to write functions that generate output for other JavaScript-based platforms.
Throws
BracketMismatchError if mismatching brackets are detected.
Name | Type | Description |
---|---|---|
source |
string |
Brainfuck source to convert. |
isMemoryDynamic |
boolean |
Enable dynamic memory array. |
enableUserInput |
boolean |
Enable user input handling. |
indentSize |
number |
Indentation size. |
indentChar |
string |
Indentation character. |
Object
Name | Type |
---|---|
declaration |
string [] |
definition |
string [] |
src/compilers/javascript-base.ts:19
▸ compileToJsDeno(source
, isMemoryDynamic?
, mainFunctionName?
, indentSize?
, indentChar?
): string
Converts a Brainfuck program to JavaScript (Deno).
Throws
BracketMismatchError if mismatching brackets are detected.
Name | Type | Default value | Description |
---|---|---|---|
source |
string |
undefined |
Brainfuck source to convert. |
isMemoryDynamic |
boolean |
true |
Enable dynamic memory array. |
mainFunctionName |
string |
'main' |
Main function name. |
indentSize |
number |
2 |
Indentation size. |
indentChar |
string |
' ' |
Indentation character. |
string
Generated JavaScript code.
src/compilers/javascript-deno.ts:15
▸ compileToJsNode(source
, isMemoryDynamic?
, mainFunctionName?
, indentSize?
, indentChar?
): string
Converts a Brainfuck program to JavaScript (Node.js).
Throws
BracketMismatchError if mismatching brackets are detected.
Name | Type | Default value | Description |
---|---|---|---|
source |
string |
undefined |
Brainfuck source to convert. |
isMemoryDynamic |
boolean |
true |
Enable dynamic memory array. |
mainFunctionName |
string |
'main' |
Main function name. |
indentSize |
number |
2 |
Indentation size. |
indentChar |
string |
' ' |
Indentation character. |
string
Generated JavaScript code.
src/compilers/javascript-node.ts:15
▸ compileToJsWeb(source
, isMemoryDynamic?
, mainFunctionName?
, indentSize?
, indentChar?
): string
Converts a Brainfuck program to JavaScript (Web).
Throws
BracketMismatchError if mismatching brackets are detected.
Name | Type | Default value | Description |
---|---|---|---|
source |
string |
undefined |
Brainfuck source to convert. |
isMemoryDynamic |
boolean |
true |
Enable dynamic memory array. |
mainFunctionName |
string |
'main' |
Output function name. |
indentSize |
number |
2 |
Indentation size. |
indentChar |
string |
' ' |
Indentation character. |
string
Generated JavaScript function source.
src/compilers/javascript-web.ts:15
▸ compileToPascal(source
, programName?
, indentSize?
, indentChar?
): string
Converts a Brainfuck program to Pascal.
Throws
BracketMismatchError if mismatching brackets are detected.
Name | Type | Default value | Description |
---|---|---|---|
source |
string |
undefined |
Brainfuck source to convert. |
programName |
string |
'Hirnfick' |
Name of the generate program (i.e. 'program programName;'). |
indentSize |
number |
2 |
Indentation size. |
indentChar |
string |
' ' |
Indentation character. |
string
Generated Pascal code.
▸ compileToPython(source
, isMemoryDynamic?
): string
Converts a Brainfuck program to a Python.
Throws
BracketMismatchError if mismatching brackets are detected.
Name | Type | Default value | Description |
---|---|---|---|
source |
string |
undefined |
Brainfuck source to convert. |
isMemoryDynamic |
boolean |
true |
Enable dynamic memory array. |
string
Generated Python code.
▸ compileToQBasic(source
, isMemoryDynamic?
, indentSize?
, indentChar?
): string
Converts a Brainfuck program to QBasic.
Throws
BracketMismatchError if mismatching brackets are detected.
Name | Type | Default value | Description |
---|---|---|---|
source |
string |
undefined |
Brainfuck source to convert. |
isMemoryDynamic |
boolean |
false |
Enable dynamic memory array. |
indentSize |
number |
2 |
Indentation size. |
indentChar |
string |
' ' |
Indentation character. |
string
Generated QBasic code.
▸ compileToRust(source
, isMemoryDynamic?
, indentSize?
, indentChar?
): string
Converts a Brainfuck program to Rust.
Throws
BracketMismatchError if mismatching brackets are detected.
Name | Type | Default value | Description |
---|---|---|---|
source |
string |
undefined |
Brainfuck source to convert. |
isMemoryDynamic |
boolean |
true |
Enable dynamic memory array. |
indentSize |
number |
4 |
Indentation size. |
indentChar |
string |
' ' |
Indentation character. |
string
Generated Rust code.
▸ hasInfiniteLoops(source
): boolean
Checks whether a program contains infinite loops.
Name | Type | Description |
---|---|---|
source |
string |
Brainfuck source to check. |
boolean
True if the program is contains an infinite loop, false if it doesn't.
src/utils/syntax-checking.ts:30
▸ hasMismatchingLoopBoundaries(source
): boolean
Checks whether a program contains mismatching loop boundaries.
Name | Type | Description |
---|---|---|
source |
string |
Brainfuck source to check. |
boolean
True if the program contains mismatching loop boundaries, false if it doesn't.
src/utils/syntax-checking.ts:8
▸ cleanCode(source
): string
Strips comments from Brainfuck source and then cleans the code from anything that's not a Brainfuck command.
Name | Type | Description |
---|---|---|
source |
string |
Brainfuck code to clean up. |
string
Cleaned up Brainfuck code.
▸ genIndent(depth
, size
, char
): string
Generates an indentation string.
Name | Type | Description |
---|---|---|
depth |
number |
Indentation depth. |
size |
number |
Indentation size. |
char |
string |
Indentation character. |
string