Read/evaluate froth code from R
froth-parse-source.Rd
Function to run froth code from R.
Arguments
- inputline
A string to parse with froth
- filepath
Path to a file containing froth or FORTH code to parse with froth
Details
These functions run the froth interpreter on strings read in either as arguments (froth.parse
) or from a file (froth.source
). Both functions will run froth code without having to enter the REPL.
Author
Aidan Lakshman ahl27@pitt.edu
Examples
## Add two numbers
froth.parse("1 2 + .")
#> 3
## source a function to print a ASCII table called 'rect'
tf <- tempfile()
defn <- ': RECT 256 0 DO I 16 MOD 0= IF CR THEN ." * " LOOP ;'
writeLines(defn, con=tf)
froth.source(tf)
froth.parse('rect')
#>
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *
#> * * * * * * * * * * * * * * * *