Skip to content
Permalink
Browse files

update parser for R

  • Loading branch information...
sdpython committed May 15, 2017
1 parent afaf0af commit a080b8cd6d5e24e345af805f0fd4df5365a214de
@@ -4,7 +4,6 @@ b = 3


def mySecFun(v, M):

u = tuple(0, 0, 0, 0)

for i in range(1, length(v)):
@@ -2,6 +2,5 @@ from python2r_helper import inlineif


def onefunction():

od = tempfile("od", fileext=".pdf") # ccc
on_exit(inlineif(file_exists(od), ul(od)), add=True)
@@ -2,6 +2,5 @@ import patsy


def onefunction():

form = " v1 ~ v2 + v3 "
ex = quote()
@@ -1,5 +1,4 @@
def onefunction():

if exists("dada", fct()):
fct2("aa", fct3())
else:
@@ -1,3 +1,2 @@
def onefunction():

names(df) .set(names(df))
@@ -1,3 +1,2 @@
def onefunction():

r = df[5, :]
@@ -2,5 +2,4 @@ import patsy


def onefunction():

lm = lr(formula="( cf == 1 ) ~ age + pa ", data=it)
@@ -1,3 +1,2 @@
def onefunction():

checkEquals(d % 1, tuple(0, 0))
@@ -1,3 +1,2 @@
def onefunction():

length = do(p=range(1, 10))
@@ -1,5 +1,4 @@
def nb(y=1930):

debut = 1816
MatDFemale = matrix(D . Female, nrow=111)
colnames(MatDFemale) .set(debut + range(0, 198))
@@ -0,0 +1,7 @@
from python2r_helper import ImplicitColumn
from python2r_helper import bquote


def some():
t = bquote(list(a=~ (age == ImplicitColumn . whichAge)))
r = bquote(~ (age == ImplicitColumn . whichAge))
@@ -0,0 +1,5 @@
some = function()
{
t <- bquote(list(a = !(age == .(whichAge))))
r <- bquote(!(age == .(whichAge)))
}
@@ -4,11 +4,9 @@ from python2r_helper import within


def test_machine_chouette_something():

# some other comment

def func(infile, csch, predmod):

impnode = zoo_test(infile="$infile", dot="$dotdot", csch=csch)
obj = waouh(
impnode, nono, trnode, inputs=list(
@@ -0,0 +1,3 @@
def onefunction():
df[["v"]] = I(sapply(seq(nrow(df)), lambda i,
r: r[seq(i % length(lett))], r))
@@ -0,0 +1,4 @@
onefunction <- function()
{
df[["v"]] <- I(sapply(seq(nrow(df)), function(i, r) r[seq(i%%length(lett))], r))
}
@@ -2,6 +2,5 @@ from python2r_helper import within


def onefunc():

binaryDf = within(iris, " isSetosa = Species == \"setosa\" ")

@@ -2,6 +2,5 @@ from python2r_helper import dotry


def onefunc():

m = dotry(func(infile=bf, csh=csh, pmod=""))

@@ -2,6 +2,5 @@ from python2r_helper import inlineif


def onefunc():

on_exit(inlineif(file_exists(filename), afunction(filename)), add=True)

@@ -2,6 +2,5 @@ from python2r_helper import within


def onefunc():

df = within(df, " age = as_character ( age ) ",
" car_age = as_character ( car_age ) ")
@@ -2,7 +2,6 @@ from python2r_helper import inlineif


def onefunc():

exj = afunction(
obj,
s=s,
@@ -1,7 +1,6 @@
def onefunction():

def func(ind, outv=False):

cols = tuple(l, cf, nf)
if outv:
cols = tuple(cols, "cf")
@@ -2,5 +2,4 @@ from python2r_helper import inlineif


def onefunction():

ou = inlineif(length(grep("^some", basename(du))) > 0, od, "")
@@ -1,5 +1,5 @@
"""
@brief test log(time=3s)
@brief test log(time=5s)
You should indicate a time in seconds. The program ``run_unittests.py``
will sort all test files by increasing time and run them.
@@ -64,7 +64,8 @@ expr
| expr ('&'|'&&') expr
| expr ('|'|'||') expr
| formula_simple
| functiondef '(' NL* formlist? NL* ')' expr // define function
| functiondefbody
| functiondeflambda
| functioncall
| NL* '{' NL* exprlist NL* '}' NL* // compound statement
| returnexpr
@@ -74,13 +75,34 @@ expr
| whileexpr
| repeatexpr
| '?' expr // get help on expr, usually string or ID
| implicit_column_name
| nextexpr
| 'break'
| ('(' expr ')')
| constant
| identifier
;

functiondefbody
: functiondefargs NL* '{' NL* exprlist NL* '}' // define function
;

functiondeflambda
: functiondefargslambda expr // define function
;

functiondefargslambda
: functiondef '(' NL* formlist? NL* ')'
;

functiondefargs
: functiondef '(' NL* formlist? NL* ')'
;

implicit_column_name
: '.' '(' identifier ')'
;

affectation
: affectop NL? expr
;
@@ -139,7 +161,7 @@ intersections
;

intersection_simple
: identifier '%in%' expr
: (identifier | constant) '%in%' expr
;

intersection_complexe
@@ -208,7 +230,7 @@ formula_simple
;

formula_simple_A
: identifier formop ( sublistadd | '.' )
: identifier? formop ( sublistadd | '.' )
;

formula_simple_B
@@ -222,6 +244,8 @@ formula_simple_C
: '(' expr ')' formop ( sublistadd | '.' )
;

PARENTHESIS : '(' | ')' ;

affectop
: '<-'
| '<<-'
@@ -331,7 +355,7 @@ HEX_ESCAPE
;

ID : '.' (LETTER|'_'|'.') (LETTER|DIGIT|'_'|'.')*
| LETTER (LETTER|DIGIT|'_'|'.')*
| '_'? LETTER (LETTER|DIGIT|'_'|'.')*
;

fragment LETTER : [a-zA-Z] ;
@@ -58,15 +58,16 @@ T__56=57
T__57=58
T__58=59
T__59=60
HEX=61
INT=62
FLOAT=63
COMPLEX=64
STRING=65
ID=66
USER_OP=67
NL=68
WS=69
PARENTHESIS=61
HEX=62
INT=63
FLOAT=64
COMPLEX=65
STRING=66
ID=67
USER_OP=68
NL=69
WS=70
';'=1
'[['=2
']'=3
@@ -78,32 +79,32 @@ WS=69
'&&'=9
'|'=10
'||'=11
'('=12
')'=13
'{'=14
'}'=15
'?'=16
'break'=17
','=18
'='=19
'...'=20
'NULL'=21
':'=22
'%in%'=23
'NA'=24
'Inf'=25
'NaN'=26
'TRUE'=27
'FALSE'=28
'next'=29
'repeat'=30
'while'=31
'for'=32
'in'=33
'if'=34
'else'=35
'return'=36
'.'=37
'{'=12
'}'=13
'?'=14
'break'=15
'('=16
')'=17
'.'=18
','=19
'='=20
'...'=21
'NULL'=22
':'=23
'%in%'=24
'NA'=25
'Inf'=26
'NaN'=27
'TRUE'=28
'FALSE'=29
'next'=30
'repeat'=31
'while'=32
'for'=33
'in'=34
'if'=35
'else'=36
'return'=37
'within'=38
'<-'=39
'<<-'=40
Oops, something went wrong.

0 comments on commit a080b8c

Please sign in to comment.
You can’t perform that action at this time.