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
7
votes
1 answer

Is there a unit testing framework for Rascal?

I did not see one in the standard library documentation. A Google search gives as the top hit "Rascal Unit travel pet sterilization and wellness clinic princing [sic] information."
7
votes
1 answer

Debugging Rascal code

So i've been using Rascal for a while now, but I was wondering if there is support debugging without using println and the terminal? So like with c# in Visual Studio, stepping through the code, into functions and so on. For me this would be a big…
Richard Bos
  • 774
  • 5
  • 18
5
votes
1 answer

How to void name conflicts among modules in Rascal?

How can I avoid name conflicts among modules? From the documentation, it seems currently there is no principled name management among modules in Rascal. When importing a module, all names declared public in the imported module come into scope. Is…
day
  • 2,292
  • 1
  • 20
  • 23
4
votes
2 answers

Obtaining Cyclomatic Complexity

I am looking into calculating the cyclomatic complexity of java methods using Rascal. One approach to this would be: getting the AST from the method use visit pattern on this tree check for the following keywords which all increase the CC with one:…
Lorenzo.A
  • 67
  • 4
4
votes
2 answers

Count the number of methods in a Java file

I am trying to parse a Java file and count the method declarations in it. Right now I am using the following code: import ParseTree; import lang::java::\syntax::Java15; import IO; public int countMethods(loc file) { int n = 0; try { …
shad
  • 43
  • 4
4
votes
1 answer

Initiate Rascal tests from shell for CI purposes

If I want to start all tests within a module, I simply write: > import Example; > :test and all of the test bool functions run. However, I want to start them using the Rascal .jar for CI purposes. Is there any flag that I can use? For example: $…
4
votes
1 answer

Accessing _all_ downstream annotations of a node in Rascal

I read this question while trying to do something similar. The answer given there does not solve my problem. I want to use a visit statement to determine the 'mass' of each subtree, so for each node I want to sum the masses of all descendants. For…
Anson
  • 55
  • 6
4
votes
1 answer

How to cast a value type to Map in Rascal?

I have a variable of type value that stores a map, but I can not access the values by providing the keys: rascal>a value: ("s":"s") rascal>a["s"] |stdin:///|(2,3,<1,2>,<1,5>): subscript not supported on value at |stdin:///|(2,3,<1,2>,<1,5>) ☞…
4
votes
1 answer

How to use SDF's {avoid} in rascal MPL

I'm trying to design an island grammar using Rascal MPL, but I ran into a problem: When implementing an Island Grammar in SDF a very common approach is to define a "catch-all" water production using the {avoid} attribute. This prevents the parser…
4
votes
1 answer

Why does [1..5] in Rascal return [1,2,3,4]?

I expect it to return [1,2,3,4,5] as in Haskell.
3
votes
1 answer

How to serialize/deserialize data to file in Rascal MPL

I need a way to serialize data in Rascal as some operations may be relatively slow and some quick form of caching is desired. For example the construction of ASTs. I'm using the following segment of code to construct ASTs from the project at the…
Teun M.
  • 133
  • 9
3
votes
1 answer

Possible bug? using mapper on a list of list with the function size

I have encountered an issue in which I get an error in runtime on code which is valid according to the compiler. The code is pretty simple. This also happens when you have a set[set[str]], but here I have listed the list[list[str]] version. I do…
Bolderax
  • 43
  • 4
3
votes
1 answer

Constructing a location from a string

I receive the following string to my webserver: "|project://Detector/src/exporter.rsc|(1762,28,<45,10>,<45,38>)" using the toLocation() function to convert this to a location will result into an MalFormedURI error. I can use the toLocation()…
bartos92
  • 35
  • 4
3
votes
1 answer

Pie chart howto in Rascal

I was wondering if there is an option to create pie charts in Rascal. It could be done by making separate pie slices but there is no angular option with the ellipse() method. There was a former Wedge() method, but that has been removed from the…
Evert
  • 31
  • 1
3
votes
1 answer

Extracting facts from M3 models

I am trying to extract some facts about type declarations from Java M3 models. From a set of M3 files, I tried to use a comprehension, such as > [type(m) | m <- models]; Though I got: Undeclared variable: types Then I just tried to obtain facts…
1
2 3
30 31