search for: parse_ok

Displaying 19 results from an estimated 19 matches for "parse_ok".

Did you mean: parse_at
2008 Sep 03
8
suggestion of new API function for embedded programming.
...n or static parse functions (R_ParseBuffer, R_Parse1Buffer, etc.) which take an IoBuffer* and returns a parsed tree. If one or more of these functions were exported to the Rembedded.h API we could do something like the following: R_Expr = R_Parse1Buffer(&R_ConsoleIob, 0, &status); if (PARSE_OK==status) { ... value = eval(R_CurrentExpr, rho); ... } or possibly simplifying the interface to take the CMDL string: R_Expr = R_Parse1Line("t.test(x,conf.level=(1-p))$conf.int[2]", &status); I think this would be a useful addition to the embedding interface, and ho...
2008 Aug 04
2
Parsing code with newlines
...de) { SEXP cmdSexp, cmdExpr = R_NilValue; ParseStatus status; PROTECT (cmdSexp = allocVector (STRSXP, 1)); SET_STRING_ELT (cmdSexp, 0, mkChar (code)); PROTECT (cmdExpr = R_ParseVector (cmdSexp,-1,&status, R_NilValue)); UNPROTECT_PTR (cmdSexp); if (status != PARSE_OK) { return (void*)0; } else { return (void*)cmdExpr; } } Regards, Peter [[alternative HTML version deleted]]
2019 Apr 05
2
Parsing code with newlines
...Call.h" #include <R_ext/Parse.h> int main(int argc, char *argv[]) { SEXP e, tmp; int hadError; ParseStatus status; init_R(argc, argv); PROTECT(tmp = mkString("\n\r ls()")); PROTECT(e = R_ParseVector(tmp, 1, &status, R_NilValue)); if (status != PARSE_OK) { printf("boo boo\n"); } else { PrintValue(e); R_tryEval(VECTOR_ELT(e,0), R_GlobalEnv, &hadError); } UNPROTECT(2); end_R(); return(0); } -- Mikhail
2013 Oct 16
1
Parallel R expression evaluations
...(rscript); SEXP cmdSexp, cmdexpr, sresult = R_NilValue; ParseStatus status; R_len_t i=0; PROTECT(cmdSexp = Rf_allocVector(STRSXP, 1)); SET_STRING_ELT(cmdSexp, 0, cmd1); // parsing vector for R expressions cmdexpr = PROTECT(R_ParseVector(cmdSexp, -1, &status, R_NilValue)); if (status != PARSE_OK) { UNPROTECT(2); // error handling return; } for(i = 0; i < Rf_length(cmdexpr); i++) { int error; sresult = R_tryEval(VECTOR_ELT(cmdexpr, i), R_GlobalEnv, &error); // R expression evaluation if(error) // checking for error { // error handling return; } } UNPROT...
2003 Aug 24
1
declarations in non-exported headers and embedding R
...================== Here are the specifics: ----------------------------------------------------------- From non-exported header file ${R_HOME}/src/include/Parse.h ----------------------------------------------------------- extern SEXP R_ParseVector(SEXP, int, int *); #define PARSE_NULL 0 #define PARSE_OK 1 #define PARSE_INCOMPLETE 2 #define PARSE_ERROR 3 #define PARSE_EOF 4 ----------------------------------------------------------- From non-exported header file ${R_HOME}/src/include/Defn.h ----------------------------------------------------------- extern void R_PreserveObject(SEXP); extern...
2006 Nov 27
1
R.DLL mapping by P/Invoke
...LL", /*CallingConvention = CallingConvention.Cdecl,*/ CharSet = CharSet.Ansi)] static extern void Rf_setVar(IntPtr symbol, IntPtr value, IntPtr env); #endregion #region <R.DLL interop types> enum RParseStatus { PARSE_NULL, PARSE_OK, PARSE_INCOMPLETE, PARSE_ERROR, PARSE_EOF }; enum SaType { SA_NORESTORE = 0,/* = 0 */ SA_RESTORE, SA_DEFAULT,/* was === SA_RESTORE */ SA_NOSAVE, SA_SAVE,...
2009 Jan 08
1
Callbacks seems to get GCed.
...p, cmdExpr = R_NilValue; ParseStatus status; int i,errorOccurred; SEXP e; PROTECT (cmdSexp = allocVector (STRSXP, 1)); SET_STRING_ELT (cmdSexp, 0, mkChar (code)); PROTECT (cmdExpr = R_ParseVector (cmdSexp,-1,&status,R_NilValue)); UNPROTECT_PTR (cmdSexp); if (status == PARSE_OK) { for (i = 0; i < length (cmdExpr); i++) { PROTECT(e = VECTOR_ELT (cmdExpr,i)); R_tryEval(e, R_GlobalEnv, &errorOccurred); UNPROTECT_PTR(e); if (errorOccurred) { return; } } } } void initR() { char *argv[] = {"REmbeddedPascal&quo...
2007 Oct 17
0
Using R.dll in .NET IPC
...LL", /*CallingConvention = CallingConvention.Cdecl,*/ CharSet = CharSet.Ansi)] static extern void Rf_setVar(IntPtr symbol, IntPtr value, IntPtr env); #endregion #region <R.DLL interop types> enum RParseStatus { PARSE_NULL, PARSE_OK, PARSE_INCOMPLETE, PARSE_ERROR, PARSE_EOF }; enum SaType { SA_NORESTORE = 0,/* = 0 */ SA_RESTORE, SA_DEFAULT,/* was === SA_RESTORE */ SA_NOSAVE, SA_SAVE,...
2009 Sep 03
1
Running an expression 1MN times using embedded R
...P rexpress(const char* cmd) { SEXP cmdSexp, cmdexpr, ans = R_NilValue; int i,Rerr; ParseStatus status; PROTECT(cmdSexp = Rf_allocVector(STRSXP, 1)); SET_STRING_ELT(cmdSexp, 0, Rf_mkChar(cmd)); cmdexpr = PROTECT(R_ParseVector(cmdSexp, -1, &status, R_NilValue)); if (status != PARSE_OK) { UNPROTECT(2); return(R_NilValue); } for(i = 0; i < Rf_length(cmdexpr); i++) ans = R_tryEval(VECTOR_ELT(cmdexpr, i),NULL,&Rerr); UNPROTECT(2); return(ans); } int embedR(int argc, char **argv){ structRstart rp; Rstart Rp = &rp; R_DefParams(Rp); R...
2019 Apr 10
0
Parsing code with newlines
...nt argc, char *argv[]) > { > SEXP e, tmp; > int hadError; > ParseStatus status; > > init_R(argc, argv); > > PROTECT(tmp = mkString("\n\r ls()")); > PROTECT(e = R_ParseVector(tmp, 1, &status, R_NilValue)); > if (status != PARSE_OK) > { > printf("boo boo\n"); > } > else > { > PrintValue(e); > R_tryEval(VECTOR_ELT(e,0), R_GlobalEnv, &hadError); > } > UNPROTECT(2); > > end_R(); > return(0); > } > > >...
2004 Apr 06
1
A question about embedded R
Hello everyone, I met a strange problem when I call R expression from C++, here is the details: I edited a function eval_R_command(); double eval_R_command(const char *funcName) { SEXP exp,e; ParseStatus status = PARSE_OK; int i,n; double val; PROTECT(exp=NEW_CHARACTER(1)); SET_STRING_ELT(exp, 0, COPY_TO_USER_STRING(funcName)); PROTECT(e = R_ParseVector(exp, 1, &status)); n = GET_LENGTH(e); for(i = 0; i < n ; i++) val = (double)REAL(eval(VECTOR_ELT(e,i), R_GlobalEnv))[...
2000 Oct 03
0
FW: Parse Errors
...h as "plo(x)" the program crashes. There is code in R_Proxy_evaluate to test for a parse error before actually generating code and issuing the command - He calls R_Parse1Buffer(&lBuffer,0,&lStatus) and then tests the value of lStatus for parse error. The trouble is that lStatus == PARSE_OK even though the command is invalid, so the evaluation continues until eval() is called, at which point R terminates and crashes the program. (It does write an error message to the console first, but crashes after that.) Is there a way to handle this? The same command can be issued inside RGui.exe...
2008 Jan 02
1
setting the seed in standalone code using Rlib
...char cmd[256]; SEXP cmdSexp; SEXP cmdExp; ParseStatus status; sprintf(cmd, "set.seed(%u)", seed); PROTECT(cmdSexp = allocVector(STRSXP, 1)); SET_STRING_ELT(cmdSexp, 0, mkChar(cmd)); cmdExp = PROTECT(R_ParseVector(cmdSexp, -1, &status, R_NilValue)); assert(status == PARSE_OK); eval(VECTOR_ELT(cmdExp, 0), R_GlobalEnv); UNPROTECT(2); #else set_seed(seed, seed); #endif } /* Test */ extern int Rf_initEmbeddedR(int argc, const char *argv[]); int main(int numArgs, char** args) { const char *argv[]= {"setseed", "--gui=none", "--silent...
2008 Jul 18
0
Rcpp from C++
...ot;print(c)"; for (int CommandInd = 0; CommandInd<4; CommandInd++) { PROTECT(cmdSexp = allocVector(STRSXP, 1)); SET_STRING_ELT(cmdSexp, 0, mkChar(cArr[CommandInd])); cmdexpr = PROTECT(R_ParseVector(cmdSexp, -1, &status, R_NilValue)); if (status != PARSE_OK) { UNPROTECT(2); error("invalid call!"); } for(int i = 0; i < length(cmdexpr); i++) { ans = eval(VECTOR_ELT(cmdexpr, i), R_GlobalEnv); Rf_PrintValue(ans); } } hope that helps best peter P.S.: let me k...
2000 Oct 03
2
Parse Errors
...h as "plo(x)" the program crashes. There is code in R_Proxy_evaluate to test for a parse error before actually generating code and issuing the command - He calls R_Parse1Buffer(&lBuffer,0,&lStatus) and then tests the value of lStatus for parse error. The trouble is that lStatus == PARSE_OK even though the command is invalid, so the evaluation continues until eval() is called, at which point R terminates and crashes the program. (It does write an error message to the console first, but crashes after that.) Is there a way to handle this? The same command can be issued inside RGui.exe...
2000 Oct 03
2
Parse Errors
...h as "plo(x)" the program crashes. There is code in R_Proxy_evaluate to test for a parse error before actually generating code and issuing the command - He calls R_Parse1Buffer(&lBuffer,0,&lStatus) and then tests the value of lStatus for parse error. The trouble is that lStatus == PARSE_OK even though the command is invalid, so the evaluation continues until eval() is called, at which point R terminates and crashes the program. (It does write an error message to the console first, but crashes after that.) Is there a way to handle this? The same command can be issued inside RGui.exe...
2019 Apr 10
1
Parsing code with newlines
...t; SEXP e, tmp; >> int hadError; >> ParseStatus status; >> >> init_R(argc, argv); >> >> PROTECT(tmp = mkString("\n\r ls()")); >> PROTECT(e = R_ParseVector(tmp, 1, &status, R_NilValue)); >> if (status != PARSE_OK) >> { >> printf("boo boo\n"); >> } >> else >> { >> PrintValue(e); >> R_tryEval(VECTOR_ELT(e,0), R_GlobalEnv, &hadError); >> } >> UNPROTECT(2); >> >> end_R();...
2007 Jan 18
0
Emulating a REPL in frontends
...b); if(c == ';' || c == '\n') break; } R_PPStackTop = 0; R_CurrentExpr = R_Parse1Buffer(&R_ConsoleIob, 0, &status); if(parse_status) *parse_status = status; switch(status) { case PARSE_NULL: R_IoBufferWriteReset(&R_ConsoleIob); break; case PARSE_OK: R_IoBufferReadReset(&R_ConsoleIob); R_CurrentExpr = R_Parse1Buffer(&R_ConsoleIob, 1, &status); R_Visible = FALSE; R_EvalDepth = 0; PROTECT(R_CurrentExpr); R_Busy(1); value = eval(R_CurrentExpr, rho); if(set_last_sym_value) SET_SYMVALUE(R_LastvalueSymbol, value); if ((prin...
2010 Jan 07
1
Segfault in GetNewPage, memory.c.
...CAMLprim value parse_sexp (value s) { > CAMLparam1(s); > SEXP text ; > SEXP pr ; > ParseStatus status; > PROTECT(text = mkString(String_val(s))); > PROTECT(pr=R_ParseVector(text, 1, &status, R_NilValue)); > UNPROTECT(2); > switch (status) { > case PARSE_OK: > break; > case PARSE_INCOMPLETE: > case PARSE_EOF: > caml_raise_with_string(*caml_named_value("Parse_incomplete"), (String_val(s))); > case PARSE_NULL: > case PARSE_ERROR: > caml_raise_with_string(*caml_named_value("Parse_error&...