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.

Rascal is an experimental domain specific language (DSL) for arbitrary meta-programming, 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. Rascal is not limited to a particular object language, rather it has generic support for manipulating all languages and targeted libraries for specific languages.

Links to more information:

455 questions
3
votes
1 answer

Generic core binary relations of M3

In the paper "M3: a General Model for Code Analytics in Rascal" 3 Generic core binary relations for the M3 are given. These are: containment, declarations, and uses. Looking at the M3 source code in analysis::m3::Core, I see a lot more binary…
Nicasso
  • 265
  • 1
  • 7
3
votes
1 answer

Rascal - Rewrite AST using a visitor

I am trying to rewrite all the different Types in the AST to a single type (like char() for example). So far I am able to find the types, but I cannot seem to find a way to rewrite them. So the idea is to do something like this (this example doesn't…
Nicasso
  • 265
  • 1
  • 7
3
votes
2 answers

Why does this Rascal pattern matching code use so much memory and time?

I'm trying to write what I would think of as an extremely simple piece of code in Rascal: Testing if list A contains list B. Starting out with some very basic code to create a list of strings public list[str] makeStringList(int Start, int End) { …
Bouke
  • 104
  • 8
3
votes
2 answers

accessing regexp subtree in parsetree

I have the following Rascal module: module foo import IO; import ParseTree; extend lang::std::Layout; lexical CHAR = [ab]; start syntax CharList = CHAR hd (',' CHAR)+ tl ';'; My question is how to get to the individual elements of the tl part,…
Dennis
  • 171
  • 9
3
votes
1 answer

How to get a location of a number value?

Suppose I want to print all locations with a hard coded value, in a context were d is an M3 Declaration: top-down visit(d) { case \number(str numberValue) : println("hardcode value encountered at "); } The problem…
3
votes
1 answer

Returning values and statements from functions

I am wondering about the difference in behaviour between using the return statement and defining a function with the pattern foo() = Expression It's my understanding from: Funtions that a function body can be = Expression and return takes either…
josh
  • 1,544
  • 2
  • 16
  • 27
3
votes
1 answer

Rascal: what does the bool collectBindings in creating AST do?

I have a question about creating a AST in rascal. I normally do the following: model = createM3FromEclipseProject(|project://testproject|); decls = createAstsFromEclipseProject(model.id, false); At first i would set the collectBindings to true. But…
Phaeton
  • 79
  • 8
3
votes
1 answer

What is the function to jump from Rascal to a certain Location in IDE

If I have a Rascal visualization with location information (e.g. to start/endline of a Java Method), how can I jump into the IDE and highlight the selected lines? So essentially how can I get the same behavior as clicking on a printed loc in the…
robert
  • 1,921
  • 2
  • 17
  • 27
3
votes
1 answer

Why is the expression `super()` in the Java AST in Rascal?

One of the expressions in the Java AST declaration is Expression::super(). For which Java expression(s) is super() used? Take this example class: import java.util.ArrayList; import java.util.List; public class SuperTests extends ArrayList
caytekin
  • 171
  • 2
  • 12
3
votes
1 answer

The meaning of * and + in syntax specification

I am a bit confused by the meaning of * and + in syntax specification. I expect something like rascal>syntax Statement = "{" {Statement ";"}* "}"; to mean a block of statements separated and ended by semicolons. But in the documentation it…
day
  • 2,292
  • 1
  • 20
  • 23
3
votes
1 answer

Invoking java functions from RASCAL

can I invoke Java functions from Rascal. I want to write RASCAL analyser, but want access CFG nodes by calling a java function. Is this possible in Rascal. To put it simply, can I wrap the existing java application and invoke it from RASCAL
3
votes
1 answer

Is there any difference between `*x` and `x*`?

I found in some demo code, both *x and x* are used. Sometimes, the star is also used on types, like *int xs. In the help, only the pattern Var* is documented. Is there any difference between putting the star before or after a pattern variable?
day
  • 2,292
  • 1
  • 20
  • 23
3
votes
1 answer

Annotating a ADT/Node tree with "parent" labels in Rascal

I want to create a tree (using a Node or ADT) in which every node has an annotation pointing back to its parent. Below is an example with a simple linked list data structure: import util::Math; import IO; import Node; anno LinkedList…
pancake
  • 1,923
  • 2
  • 21
  • 42
3
votes
1 answer

What Rascal entities should be upper case?

What are the naming conventions in Rascal? It seems that modules, but not intermediate paths, tends to be upper case, also variable names. Does it make a difference? What is the convention and the rationale behind it?
3
votes
1 answer

Does my variable have an annotation?

How can I check if my variable has some annotation? I know this can be done for properties using the keyword has. Is there a similar way to do this for annotations?
Richard Bos
  • 774
  • 5
  • 18
1
2
3
30 31