Skip to content
Snippets Groups Projects
Commit 71e27e03 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

allow arbitrary user-defined binary ops

parent c6c7baa1
No related branches found
No related tags found
No related merge requests found
...@@ -94,6 +94,7 @@ public class ParserGeneration { ...@@ -94,6 +94,7 @@ public class ParserGeneration {
"pass along TruffleRLanguage", "pass along TruffleRLanguage",
"convert line endings", "convert line endings",
"handle four and more dots as identifier", "handle four and more dots as identifier",
"allow greek characters in identifiers" "allow greek characters in identifiers",
"allow everything but newlines in %<ident>% operators"
}; };
} }
...@@ -695,7 +695,7 @@ ID ...@@ -695,7 +695,7 @@ ID
| '`' BACKTICK_NAME | '`' BACKTICK_NAME
; ;
OP : '%' OP_NAME+ '%' ; OP : '%' (~('%' | '\n' | '\r' | '\f'))+ '%' ;
fragment BACKTICK_NAME fragment BACKTICK_NAME
@init { final StringBuilder buf = new StringBuilder(); } @init { final StringBuilder buf = new StringBuilder(); }
......
...@@ -160766,6 +160766,22 @@ non-integer value 12345678909876543212L qualified with L; using numeric value ...@@ -160766,6 +160766,22 @@ non-integer value 12345678909876543212L qualified with L; using numeric value
#'\ ' == ' ' #'\ ' == ' '
[1] TRUE [1] TRUE
   
##com.oracle.truffle.r.test.parser.TestParser.testUserOp#
#`%!@#$^&*()%` <- function(a,b) 1; 10 %!@#$^&*()% 20
[1] 1
##com.oracle.truffle.r.test.parser.TestParser.testUserOp#
#`%5%` <- function(a,b) 1; 10 %5% 20
[1] 1
##com.oracle.truffle.r.test.parser.TestParser.testUserOp#
#`%foo%` <- function(a,b) 1; 10 %foo% 20
[1] 1
##com.oracle.truffle.r.test.parser.TestParser.testUserOp#
#`%Š%` <- function(a,b) 1; 10 %Š% 20
[1] 1
##com.oracle.truffle.r.test.rffi.TestUserRNG.testUserRNG# ##com.oracle.truffle.r.test.rffi.TestUserRNG.testUserRNG#
#{ dyn.load("tmptest/userrng/liburand.so"); RNGkind("user"); print(RNGkind()); set.seed(4567); runif(10) } #{ dyn.load("tmptest/userrng/liburand.so"); RNGkind("user"); print(RNGkind()); set.seed(4567); runif(10) }
[1] "user-supplied" "Inversion" [1] "user-supplied" "Inversion"
...@@ -150,6 +150,14 @@ public class TestParser extends TestBase { ...@@ -150,6 +150,14 @@ public class TestParser extends TestBase {
assertEval("{ ...... <- 42; cat(......); }"); assertEval("{ ...... <- 42; cat(......); }");
} }
@Test
public void testUserOp() {
assertEval("`%foo%` <- function(a,b) 1; 10 %foo% 20");
assertEval("`%5%` <- function(a,b) 1; 10 %5% 20");
assertEval("`%Š%` <- function(a,b) 1; 10 %Š% 20");
assertEval("`%!@#$^&*()%` <- function(a,b) 1; 10 %!@#$^&*()% 20");
}
/** /**
* Recursively look for .r source files in the args[0] directory and parse them. * Recursively look for .r source files in the args[0] directory and parse them.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment