UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

23 lines 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ErrorMarker = void 0; exports.initCommand = initCommand; const convert_values_1 = require("./lang-4.x/convert-values"); exports.ErrorMarker = 'err'; /** Command(s) to be issued at the start of each shell */ function initCommand(eol) { /* define the get function complete wrapped in a try so that we can handle failures gracefully on stdout * furthermore, we compile for performance reasons * Please note that we add a `flowr_output` assignment before to avoid issues with earlier R versions */ return 'flowr_output<-NULL;flowr_get_ast<-compiler::cmpfun(function(...){tryCatch({' /* the actual code to parse the R code, ... allows us to keep the old 'file=path' and 'text=content' semantics. we define flowr_output using the super assignment to persist it in the env! */ + 'flowr_output<<-getParseData(parse(...,keep.source=TRUE),includeText=TRUE);' /* json conversion of the output, dataframe="values" allows us to receive a list of lists (which is more compact)! * so we do not depend on jsonlite and friends, we do so manually (:sparkles:) */ + 'cat(paste0(sprintf("[%s,%s,%s,%s,%s,%s,%s,%s,%s]",flowr_output$line1,flowr_output$col1,flowr_output$line2,flowr_output$col2,flowr_output$id,flowr_output$parent,encodeString(flowr_output$token,quote="\\""),ifelse(flowr_output$terminal,"true","false"),encodeString(flowr_output$text,quote="\\"")),collapse=","))' /* error handling (just produce the marker) */ + `},error=function(e){cat("${exports.ErrorMarker}")});cat(${(0, convert_values_1.ts2r)(eol)})},options=compiler::setCompilerOptions(optimize=3));`; } //# sourceMappingURL=init.js.map