Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ URL: https://github.com/datashield/DSLite/,
https://datashield.org/,
https://doi.org/10.1093/ije/dyu188
BugReports: https://github.com/datashield/DSLite/issues/
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
VignetteBuilder: knitr
Encoding: UTF-8
Expand All @@ -55,3 +54,4 @@ Collate:
'setupDSLiteServer.R'
'setupSURVIVALTest.R'
'testParse.R'
Config/roxygen2/version: 8.1.0
4 changes: 2 additions & 2 deletions R/DSLiteServer.R
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ DSLiteServer <- R6::R6Class(
}
}

if (!is.null(self$children)) {
for (child in self$children) {
if (!is.null(node$children)) {
for (child in node$children) {
if (!is.null(child)) {
replaceFunctionNode(child)
}
Expand Down
62 changes: 22 additions & 40 deletions R/lex-yacc.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ Lexer <- R6::R6Class(
tokens = TOKENS,
literals = LITERALS,

t_NAME = '[a-zA-Z_][a-zA-Z\\d_\\$\\.-]*',
t_NAME = '[a-zA-Z_][a-zA-Z\\d_\\$\\.]*',

t_STRING = '\'[a-zA-Z\\d_+-;:\\$]*\'',

t_DBLSTRING = '"[a-zA-Z\\d_\\.+-;:\\$]*"',

t_INTEGER = '\\d+L',

t_NUMBER = '[+-]?\\d+(\\.\\d+)?([eE][+-]?\\d+)?',
t_NUMBER = '\\d+(\\.\\d+)?([eE][+-]?\\d+)?',

t_PCTOP = '%[a-z]+%',
t_PCTOP = '%[a-z*/]*%',

t_NOTOP = '!',

Expand All @@ -38,10 +38,17 @@ Parser <- R6::R6Class(
tokens = TOKENS,
literals = LITERALS,
# Parsing rules
# From the loosest to the tightest binding, see ?Syntax
precedence = list(
c('right', '='),
c('left', '~'),
c('right', 'NOTOP'),
c('left', '+', '-'),
c('left', '*', '/', 'PCTOP', ':', '^'),
c('right', 'UMINUS', 'NOTOP')
c('left', '*', '/'),
c('left', 'PCTOP'),
c('left', ':'),
c('right', 'UMINUS'),
c('right', '^')
),

p_expression_named = function(doc='expression : NAME "=" expression', p) {
Expand All @@ -51,49 +58,23 @@ Parser <- R6::R6Class(
p$set(1, op)
},

p_expression_formula = function(doc='expression : NAME "~" formula_term', p) {
p_expression_formula = function(doc='expression : expression "~" expression', p) {
op <- FormulaNode$new(p$get(3))
op$add_child(SymbolNode$new(p$get(2)))
op$add_child(p$get(4))
p$set(1, op)
},

p_formula_term_binop = function(doc="formula_term : formula_term '+' formula_term
| formula_term '-' formula_term
| formula_term '*' formula_term
| formula_term ':' formula_term
| formula_term '^' formula_term
| formula_term PCTOP formula_term", p) {
op <- BinaryOpNode$new(p$get(3))
op$add_child(p$get(2))
op$add_child(p$get(4))
# formulas are not mapped to the configured methods
op$accept(list(visit = function(node) {
if (inherits(node, c("FunctionNode", "StringNode")))
stop(sprintf("Syntax error in formula at '%s'", node$name))
}))
p$set(1, op)
},

p_formula_term_name = function(doc='formula_term : NAME', p) {
p$set(1, SymbolNode$new(p$get(2)))
},

p_formula_term_number = function(doc='formula_term : NUMBER', p) {
p$set(1, NumericNode$new(p$get(2)))
},

p_formula_term_not = function(doc='formula_term : NOTOP formula_term', p) {
op <- UnaryOpNode$new("!")
op$add_child(p$get(3))
p$set(1, op)
},

p_formula_term_group = function(doc="formula_term : '(' formula_term ')'", p) {
gn <- GroupNode$new()
gn$add_child(p$get(3))
p$set(1, gn)
},

p_expression_binop = function(doc="expression : expression '+' expression
| expression '-' expression
| expression '*' expression
| expression '/' expression
| expression '^' expression
| expression ':' expression
| expression PCTOP expression", p) {
if (p$get(3) == ':') {
Expand All @@ -109,8 +90,9 @@ Parser <- R6::R6Class(
}
},

p_expression_uminus = function(doc="expression : '-' expression %prec UMINUS", p) {
op <- UnaryOpNode$new("-")
p_expression_uminus = function(doc="expression : '-' expression %prec UMINUS
| '+' expression %prec UMINUS", p) {
op <- UnaryOpNode$new(p$get(2))
op$add_child(p$get(3))
p$set(1, op)
},
Expand Down
92 changes: 48 additions & 44 deletions man/BinaryOpNode.Rd

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

Loading
Loading