Questions tagged [rascal]
Rascal is an experimental domain specific language for metaprogramming, such as static code analysis, program transformation and implementation of domain specific languages. It includes primitives from relational calculus and term rewriting. Its syntax and semantics are based on procedural (imperative) and functional programming.
383
questions
2
votes
1answer
34 views
Performance textfield over scaleSlider
I'm trying to create something that looks like an interactive bar-chart. I'm using a method that creates a figure based on a list of boxes.
I'm using scaleSlider to interactively change the number of ...
2
votes
1answer
44 views
Issue with createM3FromEclipseFile
I'm using a simple method that reads a location and does some stuff;
public void readMyFile(loc file) {
M3 model = createM3FromEclipseFile(file);
println(model);
// do some stuff;
}
The ...
1
vote
1answer
32 views
How to create a set containing different types
How can I create a set containing a loc, int and string?
In the example below it seems my map is converted to the container type ' value'. I would like to use the characteristics of a set;
Only one ...
2
votes
1answer
26 views
Get the name of a class and method as a string
To get the name of a project as a string I can use:
loc project = |project://Test/|;<br/>
str name = project.authority;
Is there something similar available for classes or methods?
I would like ...
2
votes
1answer
44 views
How to initialize a tuple containing an list of expressions in Rascal
I'm trying to create a method that recursively looks for a For-loop. I need to initialize the return value first (a tuple) but how do I do this exactly?
I've tried: tuple[list[Expression],Statement] = ...
2
votes
2answers
33 views
Can Rascal return the operating system in method?
In java I would use: System.getProperty("os.name") to get Java to return the operating system.
Is something similar possible in Rascal?
My goal is to write a method to write text files to a ...
2
votes
1answer
54 views
Get input from user with Rascal
Rascal is currently hosting my simple web server. Here I have an input for users using HTML textarea tag, and a submit button. However, I can't figure out how to request that input data from users ...
1
vote
1answer
58 views
How to get the the grammar from the parsetree in Rascal?
I am pretty new to this, but I have started coding Rascal and I have been stuck for a long time. I am trying to get the grammar of a parse tree, but I can't seem to manage to retrieve it.
You know the ...
2
votes
1answer
57 views
How to cite Rascal in a paper?
I'm writing a paper and want to cite Rascal. Which is the preferred paper I should cite? Or should I just cite a link to the website? There are no publications mentioned on the website. The Wikipedia ...
1
vote
2answers
62 views
Get children count of a tree node
The docs for Node only mention following methods:
Equal, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, NotEqual, Slice, Subscription
It does mention how to access child by index using ...
1
vote
1answer
42 views
Dominator Tree of a Rascal Graph
Is there a way to calculate the dominator tree from the Graph type using a more imperative approach? The language has a support to create such data structure directly?
I'm trying to extract a ...
2
votes
0answers
44 views
Rascal : NullPointerException at createM3FromEclipseProject
The following code with Rascal will not work:
module Exercise1
import IO;
import IO;
import lang::java::jdt::m3::Core;
public void testing()
{
M3 model = createM3FromEclipseProject(|project://...
1
vote
1answer
86 views
Iterate over a map in Rascal
I'm trying to create a map comprehension over a map in this structure:
map[Node, set[Node]]
And my map comprehension is something like:
(currentNode: {currentNode} | <currentNode, _> <- ...
1
vote
1answer
39 views
Rascal: Doesn't Find JDK on Windows commandline
I'm trying to run Rascal on Windows from the command line, with the command given on the webpage, but I get this exception:
$ java -Xmx1G -Xss32m -jar rascal-0.18.2.jar
Version: 0.18.2
INFO: detected |...
1
vote
2answers
79 views
Can't start main class when classpath order changes
I am trying to start rascal with clair from the command line, however I do not understand why this happens:
java -cp "rascal-0.18.0.jar;clair_0.1.0.202005281059.jar;org.eclipse.cdt.core_6.11.0....
1
vote
1answer
43 views
Documentation: list of operators
Is there somewhere I can find a list of operators.
If "+", "-", "/", "%", "==", "<=", "<",... and even "<-" are common to most languages, there are some like "::", "| (ADT)", "| (Set)" or "...
1
vote
2answers
42 views
Which alternative is that instance of a ADT?
I have defined an AlgebraicDataType and an instance of it:
data Expr = const(int n)
| var(str name)
| add(Expr lhs, Expr rhs)
| mult(Expr lhs, Expr rhs)
;
I ...
1
vote
1answer
37 views
ModuleNameMismatch mystery
Using rascal from the command line, when I type:
import demo::hello
I receive a ModuleNameMismatch error, although the current directory (the one in which I type java -jar rascal-shell-stable.jar) ...
1
vote
1answer
45 views
Remove unecessary layout symbol from expression
I am trying to achieve this in rascal :
select a from myTable; => select a from myTable
Basically I just want to remove the unnecessary Layout of expression and also the commentaries in ...
2
votes
1answer
32 views
Unregistering M3 models
What is the current preferred way of unregistering M3 models from the Registry?
In my project I'm using Rascal to analyse ~100 large java programs and my JVM is slowly running out of memory. I found ...
1
vote
1answer
41 views
Rascal: What is the difference between “label” and “name” in the Syntax Definition documentation?
The SyntaxDefinition documentation page of Rascal has two sections, where one speaks about "labels" (starting with "Each alternative of a syntax definition is defined by a list of Symbols."), the ...
1
vote
2answers
63 views
Rascal: Can a Function return a Function
The Rascal documentation has an example of a function that takes a function as an argument:
int f(int x, int (int) multi){ return multi(x); }
Conversely, what is the syntax for a function that ...
1
vote
1answer
29 views
Rascal: Containing Imported Symbols
I work with multiple grammars in the repl. The grammars use same names for some of their rules.
One of the documentation recipes mentions full qualification, to disambiguate type annotations in ...
1
vote
1answer
34 views
Rascal: Grammar Stack Trace
When parsing a file with a specific grammar and the parse fails, I get a corresponding error message with the location in the source file that offended the grammar.
What I would like to look at in ...
1
vote
1answer
55 views
Rascal: TrafoFields Syntax error: concrete syntax fragment
I'm trying to re-create Tijs' CurryOn16 example "TrafoFields" scraping the code from the video, but using the Java18.rsc grammar instead of his Java15.rsc. I've parsed the Example.java successfully in ...
0
votes
1answer
49 views
Rascal: Tree Representation in Repl
I understand the default tree representation in the Rascal repl has changed. Following the recipe for the EXP Combined example I get
rascal>import demo::lang::Exp::Combined::Manual::Parse;
ok
...
1
vote
1answer
51 views
Rascal: Grammar to Parse BNF
I want to write a concrete grammar to parse BNF-like syntax definitions.
Looking at the EXP Concrete Syntax recipe I created this very simple first version:
module BNFParser
lexical Identifier = [a-...
1
vote
1answer
25 views
Regexp Matching in Reducer
I'm looking at reducers.
There is a nice example in the Tutor for counting words:
(0 | it + 1 | /\w+/ := S)
where S is some longer string with several words. The reducer returns the count of such ...
2
votes
1answer
47 views
Finding Java Grammars
I'm making my way into Rascal - nice work!
I'm halfway through the Tutor and might be getting ahead of myself, but one of my interests is refactoring Java. I've watched Tijs van der Storm's Curry On ...
1
vote
0answers
76 views
How to make URI locations from AST to map on a file read
In ClaiR it is not (yet) possible to write changes made in the AST back to file.
For this reason, I create a list lrel[int, int, str] changes = []; with startposition and endposition of the substring ...
1
vote
1answer
164 views
How to read/write a location from/to a json file with Rascal
We are using the lang::json::IO::writeJSON() function to serialize some data to a JSON file.
This worked great until we tried to store a method location.
A location contains the start line and column ...
0
votes
1answer
62 views
Why does the RASCAL IDE extension for Eclipse not work?
I've tried to use this example of the RASCAL documentation:
http://tutor.rascal-mpl.org/Rascal/Libraries/util/IDE/Menus/Menus.html#/Rascal/Libraries/util/IDE/IDE.html
After registering the language ...
0
votes
1answer
30 views
How can you define alternative literals in a syntax definition?
I am attempting to define a syntax to parse data definitions in COBOL and had a particular definition for picture clauses like this:
syntax PictureClause = pic: "PIC" PictureStringType ...
1
vote
2answers
56 views
Is it possible to create a Q-Q plot when lacking a coordinate system?
I'm looking to create a Q-Q plot within Rascal using the Vis library. I have been told there is no positional system. Is this true? If true, how would I go about plotting this or any scatterplot? Does ...
1
vote
1answer
65 views
Figure information when MouseDown event
Is there any possibility to get extra information about the Figure, which was clicked, when dealing with an onMouseDown event? I mean, extra variables that can be included when the Figure was ...
0
votes
1answer
36 views
Get string value out of a KeySym value
Is there a way to get the string value out of a KeySym value?
For example, out of keyPrintable("a").
1
vote
1answer
48 views
Horizontal axis for bar chart
According to a pdf, which was shared in a previous post about tooltips, on page 70, it mentions the possibility to draw bar charts. However, a picture mentions "work in progress" and indeed, Rascal ...
2
votes
1answer
52 views
Resolve a physical location to a logical location
I already found the resolveLocation() function to convert a logical location to a physical location. Does there also exist a function to convert a physical location to a logical location?
In that ...
1
vote
1answer
34 views
Does Rascal have a shorthand for integer max value or real max value?
Is there a shorthand in Rascal to get the max integer value?
e.g. in Java's Integer.MAX_VALUE, or C#'s Int32.MaxValue
1
vote
1answer
51 views
Location and unclear parameters
The optional parameters for a Location seem to be duplicate information:
Offset/Length define the starting character and end character of the selection
Begin/end line/column seem to be used for the ...
1
vote
2answers
85 views
Erronous Declaration when getting method from AST
I'm trying to get the Declaration of methods using AST, so I can traverse it, looking for certain statements. It worked before, but I can't get it to work anymore, the Declaration I'm getting looks to ...
1
vote
1answer
59 views
treemap can't render box when containing text that is too large
When creating a treemap structure with boxes, boxes with a text that is larger than the box itself are not drawn.
Below the same treemap is show twice: once with text, once without text.
treemap with ...
1
vote
1answer
31 views
calculating sum of ListRelation range
I have a ListRelation called PLOCs of type:
lrel[loc, int] PLOCs = [<a, calcPLOC(a)> | a <- files];
where files is a set of locations, and calcPLOC calculates an integer based on that ...
1
vote
1answer
181 views
How to use context free grammars?
Could someone help me with using context free grammars. Up until now I've used regular expressions to remove comments, block comments and empty lines from a string so that it can be used to count the ...
0
votes
1answer
41 views
Rascal: String split function
Is it possible to keep the literal separator while using split() on a string in rascal?
For example,
split("/*", line)
0
votes
1answer
37 views
If statement fails with regex comparison
public list[str] deleteBlockComments(list[str] fileLines)
{
bool blockComment = false;
list[str] sourceFile = [];
for(fileLine <- fileLines)
{
fileLine = trim(fileLine);
...
1
vote
1answer
39 views
Remove (delete) node from a tree
Is it possible to remove a node from a tree in Rascal?
Take the ColoredTree for an example.
How do you write a function deleteNode? For example:
public ColoredTree deleteNode(ColoredTree t){
...
0
votes
1answer
49 views
regular expression for removing empty lines produces wrong results
Can someone help me solve the problem I'm having with a regular expression? I have a file containing the following code:
I'm using a visit to find matches and replace them so that I can remove the ...
1
vote
1answer
51 views
Unexplained “CallFailed” exception when calling constructor function
i have the following method to normalize Java M3 nodes:
public node normalizeNodeDec(ast) {
return top-down visit (ast) {
case \method(x, _, y, z, q) => \method(Type::short(), "methodName", y, ...
2
votes
1answer
56 views
Nested descendant pattern matches
I'm trying to find all method calls and the classes that contain them. If I understand correctly, pattern matches perform backtracking to match in all possible ways.
Take the following java code.
...