Skip to content

Commit

Permalink
added ottr::valid_syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispyles committed Sep 3, 2021
1 parent a9e6e11 commit cec1b94
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ottr
Title: An R Autograding Extension for Otter-Grader
Version: 1.1.0
Version: 1.1.1
Authors@R:
person(given = "Christopher",
family = "Pyles",
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export(TestCase)
export(check)
export(export)
export(run_autograder)
export(valid_syntax)
15 changes: 15 additions & 0 deletions R/ottr.r
Original file line number Diff line number Diff line change
Expand Up @@ -529,3 +529,18 @@ export = function(notebook_path, export_path=NULL, display_link=TRUE) {
", export_path, export_path))
}
}


#' Determine whether a code snippet has any syntax errors.
#'
#' @param script The code snippet
#' @return Whether the code snippet is valid (can be parsed with `parse`)
#' @export
valid_syntax = function(script) {
error = FALSE
tryCatch(
parse(text = script),
error = function(e) error <<- TRUE
)
return(!error)
}
17 changes: 17 additions & 0 deletions man/valid_syntax.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cec1b94

Please sign in to comment.