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

Rascal error when specifying grammar

I have a simple file in rascal for specifying a toy grammar module temp import IO; import ParseTree; layout LAYOUT = [\t-\n\r\ ]*; start syntax Simple = A B ; syntax A = "Hello"+ ("joe" "pok")* ; syntax A= "Hi"; syntax B =…
Joe
  • 4,367
  • 7
  • 33
  • 52
2
votes
1 answer

String with null-character

Suppose we have the two lexical definitions: lexical DQChr = ![\"] | [\"][\"]; lexical String = "\"" DQChr* "\""; Then the following cases parse well: parse(#String,"\"a\""); parse(#String,"\"\u0001\""); However, the null-character gives a…
2
votes
1 answer

How do I select an the first element in a list of an optional sort while transforming using the ADT?

Is there a way to select the head of a list of an optional term while transforming such that if it exists you get the element else you get an empty string or the result of calling the function doesn't return anything? For example, if you had the…
Wayne
  • 65
  • 7
2
votes
1 answer

Writing Semantic Rules with TypePal

I am using Rascal MPL to design a DSL for data modeling here is a snippet of my grammar specification: syntax Declaration = @Foldable entity: "entity" EntityId name "{" Field+ fields “}” ; syntax Field = field: Id name ":" Type t…
2
votes
2 answers

Problem with parsing file ending on a newline

It seems a bit like a trivial question, but I am stuck on parsing the end of file EOF using my own island grammar. I am using the new VScode extension btw. I've mostly been using the examples from the basic recipes and have a simple grammar with the…
Jay05
  • 173
  • 2
  • 9
2
votes
1 answer

How can I simply extract a variable with Rascal Regex

If I process a simple string with a regex, I expect I can extract variables. The examples in the manual states that the extraction results in a stored variable. This does not work as expected. If I do the following regex: /\w*\w*/ :=…
NTwoO
  • 75
  • 6
2
votes
1 answer

Changing the working directory when using the exec function in Rascal

I am executing a command in Rascal on Windows 10 (some batch file) which in itself works fine: import util::ShellExec; exec("somecommand.bat"); This batch file does some file reads and writes in the current working directory. Through some debugging…
diggingforfire
  • 3,359
  • 1
  • 23
  • 33
2
votes
0 answers

Navigating to a source location from within code

In a Rascal terminal a source location is clickable. This will result in navigating to the location and highlighting the code encompassed by the location. I was wondering how one would achieve navigating to and highlighting from within code. So…
Y. Reijne
  • 41
  • 4
2
votes
0 answers

CodeMirror is not updated source on change

I am creating a salix webapp and I am trying to use codeMirror as per the salix examples. I am unable to execute the codeMirror example in the salix.demo.basic, even though I can easily execute all the other examples in basic, so I'm wondering if…
2
votes
1 answer

Use imported Algebraic Data Type in eval

I'm using the eval function to evaluate an abstract list pattern against a list and it keeps coming up with an Undeclared Variable error. Below is included a small reproducible example. module PuzzleScript::Test::Engine::EvalExample import…
2
votes
1 answer

How to generate arbitrary instances of a language given its concrete syntax in Rascal?

Given the concrete syntax of a language, I would like to define a function "instance" with signature str (type[&T]) that could be called with the reified type of the syntax and return a valid instance of the language. For example, with this…
Jonata Pastro
  • 23
  • 1
  • 3
2
votes
1 answer

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 boxes shown in my figure. Using only one bar, the…
Richard
  • 294
  • 1
  • 7
2
votes
1 answer

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 method fails to read a specific location…
Richard
  • 294
  • 1
  • 7
2
votes
1 answer

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/|;
str name = project.authority; Is there something similar available for classes or methods? I would like to write the contents of a class/method to disk and…
Richard
  • 294
  • 1
  • 7
2
votes
1 answer

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] = []; Also, if I would bind a complete statement,…
Richard
  • 294
  • 1
  • 7
1 2
3
30 31