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
2
votes
2 answers

Parsing, matching and keywords

I am working with the Java15 grammar and have a couple questions about how Rascal's parser works and why some things aren't working. Given a concrete syntax: module tests::Concrete start syntax CompilationUnit = compilationUnit: TypeDec*…
josh
  • 1,544
  • 2
  • 16
  • 27
2
votes
1 answer

Modifying Java syntax

I am looking to use Rascal's existing Java AST provided in the m3 library but I would like to extend this to add some features. We are working with a Java-like language (about 95% Java and 5% our specific features). Ideally, I'd like to be able to…
josh
  • 1,544
  • 2
  • 16
  • 27
2
votes
1 answer

Processing complex lexicals in Rascal

What's the best practice for dealing with complex literals in Rascal? Two examples from JavaScript (my DSL has similar cases): Strings with \ escapes - have to be unescaped into actual value. Regular expression literals - need their own…
Nikita Nemkin
  • 2,780
  • 22
  • 23
2
votes
2 answers

Running a Rascal program from outside the REPL

I'd really like to be able to run some Rascal's program from outside the REPL (e.g. as part of a script, or called from another program). What I'm using Rascal for is and intermediate stage in a larger framework so I am wondering what the best way…
josh
  • 1,544
  • 2
  • 16
  • 27
2
votes
1 answer

Use pattern matching in function parameters

I am wondering if it's possible to specify the exact constructor of a node that is being passed as a parameter to a function. For example if, in the lang::java::m3::AST::Declaration ADT, I'm passing a node that I know has to be a \class() to a…
josh
  • 1,544
  • 2
  • 16
  • 27
2
votes
0 answers

Java AST to .java file Rascal

I am wondering if there are mechanics in place to translate from a Java AST back to a Java source file inside the lang::java::m3 library. thanks!
josh
  • 1,544
  • 2
  • 16
  • 27
2
votes
1 answer

Parsing and implementing a lambda calculus in Rascal

I am trying to implement a lambda calculus inside of Rascal but am having trouble getting the precedence and parsing to work the way I would like it to. Currently I have a grammar that looks something like: keyword Keywords= "if" | "then" | "else" …
josh
  • 1,544
  • 2
  • 16
  • 27
2
votes
1 answer

use pattern to bind to parameters of a constructor while visiting nodes in Rascal

I am trying to do a top-down visit of an Algebraic Data Type. When I find a node of a certain type, I would also like to bind to the nodes of that particular node, for e.g. data Script=script(list[Stmt] body | ... data Stmt =exprstmt(Expr expr)|…
apil.tamang
  • 2,545
  • 7
  • 29
  • 40
2
votes
2 answers

purpose of @doc annotations and generating doc from Rascal Modules

I find plenty of @doc annotations through the Rascal Modules, but don't know how they work. I tried to create javadoc but that's not directly supported. I feel that there must be a way to generate a collection of docs by running a process through…
apil.tamang
  • 2,545
  • 7
  • 29
  • 40
2
votes
2 answers

How to traverse an AST created with clang in Rascal

I try to use Rascal to compute metrics out of an AST that is created with Clang out of Objective C code. Since the structure of the Clang AST differs from the one that is used in Rascal, i think it needs some refactoring or workarounds to work with…
T.J.
  • 35
  • 5
2
votes
1 answer

Capitalize a string in rascal

How can I capitalize a string in rascal? In the documentation of the string library, I can not find any method to capitalize a string. http://tutor.rascal-mpl.org/Rascal/Rascal.html#/Rascal/Expressions/Values/String/String.html
Jaap
  • 23
  • 3
2
votes
1 answer

IllegalArgumentException at createM3FromEclipseProject

With Rascal I am trying to create a M3 model of another eclipse project. The java project I try to load is called eLib, it is opened in eclipse, I also can run the project. The project is located in my workspace. However, if I use the following…
2
votes
1 answer

Function patterns, nodes and value types in Rascal

Why does the following work: rascal>int increment(int x) = x + 1; int (int): int increment(int); rascal>int s = 5; int: 5 rascal>increment(s); int: 6 rascal>value vs = s; value: 5 rascal>increment(vs); int: 6 ...while this fails: rascal>data…
pancake
  • 1,923
  • 2
  • 21
  • 42
2
votes
1 answer

Rascal MPL Treemap squarification

How should I get the Rascal treemap to squarify? Currently it is not squaring correctly as seen in the image below. In the source code of the Treemap file I can see the comment Based on Mark Bruls; Kees Huizing and Jarke J. vanWijk. "Squarified…
Bas
  • 26,772
  • 8
  • 53
  • 86
2
votes
1 answer

Types for pattern variables

I found that sometimes I must give types explicitly for pattern variables, otherwise Rascal would not work as expected. The following session in the Console says it all: rascal>data foo = bar(int); ok rascal>int x = 1; int: 1 rascal>[x | bar(x)…
day
  • 2,292
  • 1
  • 20
  • 23