[ruby-function]

def checkSyntax( script );

catch(:x) { eval("throw :x;"+ script ); };

return true;

rescue Exception => e;

return false;

end;


[ruby-expression]

begin catch(:x) { eval("throw :x;"+ script ); };true; rescue Exception => e; false; end


[C]

// ruby 1.8.5

extern "C" void *rb_compile_cstr (const char*, const char*, int, int);

bool checkSyntax( const char* script )
{
return ( NULL != rb_compile_cstr("checkSyntax", script, strlen(script), 0) );
}

[console]
ruby -c -e script
ex) ruby -c -e "kkk=10"