transpile

A function that takes two file names and outputs the constant folding of the input

transpile(input_file: string, output_file: string)
Parameters
input_file (string) The file from which to read the code
output_file (string) The file to which to write the code with the logs etc.

constantFolding

A function that takes a code and returns the same code but with constant folding

constantFolding(code: string): string
Parameters
code (string) A string of code that will be parsed
Returns
string: The code with constant folding

replaceByLiteral

A function that converts an operation and then replaces it with the ast of the result

replaceByLiteral(n: Object)
Parameters
n (Object) Node with the operation

replaceByConcat

A function that converts a concat operation and then replaces it with the ast of the result

replaceByConcat(n: Object)
Parameters
n (Object) Node with the operation

replaceByJoin

A function that converts a join array operation and then replaces it with the ast of the result

replaceByJoin(n: Object)
Parameters
n (Object) Node with the operation

replaceByLength

A function that converts a call to length member and then replaces it with the ast of the result

replaceByLength(n: Object)
Parameters
n (Object) Node with the operation

replaceByPos

A function that converts a position operation and then replaces it with the ast of the result

replaceByPos(n: Object)
Parameters
n (Object) Node with the operation

replaceByShift

A function that converts a shift call and then replaces it with the ast of the result

replaceByShift(n: Object)
Parameters
n (Object) Node with the operation

replaceBySlice

A function that converts a slice and then replaces it with the ast of the result

replaceBySlice(n: Object)
Parameters
n (Object) Node with the operation

replaceByPop

A function that converts a pop call and then replaces it with the ast of the result

replaceByPop(n: Object)
Parameters
n (Object) Node with the operation

replaceByReverse

A function that converts a reverse call and then replaces it with the ast of the result

replaceByReverse(n: Object)
Parameters
n (Object) Node with the operation

replaceByActualPos

A function that converts a position operation with chars and then replaces it with the ast of the result

replaceByActualPos(n: Object, type: any)
Parameters
n (Object) Node with the operation
type (any)