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

Ambiguity error while rendering parse tree

In Rascal, when rendering a parse tree, on an ambiguous grammar, why do I sometimes get an error message stating "Ambiguity" at some location instead of Rascal just rendering a parse forest and showing the ambiguity? I always just call…
0
votes
1 answer

Use case-insensitve keywords in Rascal (workaround)

Does anyone know a way how I could reserve keyword in a case-insensitve way in Rascal? Due to issue #968 as reported on GitHub (https://github.com/usethesource/rascal/issues/968) I cannot simply use single quotes. This issue will probably be solved.…
0
votes
1 answer

Is it possible to define your own operators in Rascal?

I'm writing some test helper functions to make the output more sensible: bool tstEq(first, second) { if(first == second) return true; else { println(" was not equal to "); return false; } } Is it possible to do…
Tim
  • 221
  • 3
  • 12
0
votes
1 answer

Ambuigity with reserved keyword (?)

I have the following syntax definition with two reserved keywords and two similar statements: module Test // parse(#Statement,"do c") succeeds // parse(#Statement,"define c") gives an ambiguity start syntax Statement = do: "do" Identifier+ …
0
votes
1 answer

How can I build a list of multiple regex matches in Rascal?

I have a str value containing a fair amount of text, and I match it against a regex. The str contains multiple matches of the regex, but of course I only get the first. How can I enumerate over the other matches, of better, how can I collect them…
Bob Polis
  • 23
  • 3
0
votes
1 answer

getMethodASTEclipse() returns undeclared variable

I am completely new to Rascal and am trying to create ASTs from an eclipse project using the following code Module FirstTryAST import lang::java::m3::Core; import lang::java::jdt::m3::Core; import Set; import Relation; import IO; import…
avk
  • 871
  • 1
  • 9
  • 22
0
votes
1 answer

Rascal slow at importing modules

I am running Rascal from the REPL and it seems like it takes a pretty long time to import some modules. For example import lang::java::\syntax::Java15; takes seconds to run. I've also noticed cases where modules that depend on other modules don't…
josh
  • 1,544
  • 2
  • 16
  • 27
0
votes
1 answer

Inferred types of constructor keyword parameters in Rascal pattern matches

I suppose I do not fully understand the concept of keywords in Rascal in relation to pattern matching (as the following notations are in fact supported by Rascal). Say I have defined a datatype Exp and a function demoFun1 (assuming that in this case…
0
votes
1 answer

ADTs and values

In Rascal, say I have the code: value x = 2; data Exp = con(int n); Is there a way to call con(x), while x is a value (but actually an integer), without knowing on beforehand what the type of con's first argument is supposed to be (thus without…
0
votes
2 answers

How to get the files from an Eclipse project?

The function set[loc] visibleFiles(loc l) from from util::FileSystem allows you to get the files from a directory. However it does not work if the location is an Eclipse project. Suppose we apply visibleFiles(|project://HelloWorld/|); then we get…
0
votes
1 answer

Using a map type in Abstract Syntax

I am looking to abstract part of a parse tree into a map. Specifically I want something concrete like this: syntax RecType = RECORD: "{" {(Ident "=" Num) ";"}* "}" Where let's just say Ident and Num and str and int, respectively. To be abstracted…
josh
  • 1,544
  • 2
  • 16
  • 27
0
votes
1 answer

curious: Why is IndexOutOfBounds exception different from emptyList exception in Rascal?

Consider calling function foobar with arguments, list[int] exampleA=[1,2,3]; list[int] exampleB=[]; //call with under-sized list foobar(exampleA); //everything ok, exception caught and handled //call with empty list foobar(exampleB); //throws an…
apil.tamang
  • 2,545
  • 7
  • 29
  • 40
0
votes
1 answer

Building Rascal from source

I'm thinking it might be easiest if I modify the Java syntax used in Rascal to better fit our Java-like language. Is there a way I can build Rascal from the source? I've cloned the repo from Github and imported it as a project into Eclipse but there…
josh
  • 1,544
  • 2
  • 16
  • 27
0
votes
0 answers

rascal catching runtime exceptions

Trying to catch an assertion failed exception with a message. Found the error after some annoying crashes. Not particularly fond of why the following message was generated, instead of simply telling the user that he/she forgot a "semi-colon" at the…
apil.tamang
  • 2,545
  • 7
  • 29
  • 40
0
votes
1 answer

Predictive editor for Rascal grammar

I'm trying to write a predictive editor for a grammar written in Rascal. The heart of this would be a function taking as input a list of symbols and returning as output a list of symbol types, such that an instance of any of those types would be a…
Steve
  • 17
  • 2