rascal

Is this reserve declaration hard to understand or defective?

江枫思渺然 提交于 2019-12-11 16:44:35
问题 I've got a problem with using a reserve (backslash) declaration for priority disambiguation. Below is a self-contained example. The production 'Ipv4Address' is a strict subset of 'Domain0'. In parsing URL's, though, you want dotted-quad addresses to be handled differently than domain names, so you want to split 'Domain0' into two parts; 'Domain1' is one of those two parts. The test suite included, however, is failing at 't3()', where 'Domain1' is accepting an IP address, which looks like it

Export a Rascal project to a JAR file

爷,独闯天下 提交于 2019-12-11 14:52:51
问题 I have a Rascal project I would like to export to a JAR file to be ran like a terminal application, so users can simply run the JAR from command line instead of running it from Eclipse. Is there a way to do this? I tried to export it like a regular Java project but I'm not sure how to specify things such as the JAR's entry point. 回答1: It depends a bit on the API's your using. If they are eclipse specific (the jdt submodule of m3) or if they are using the eclipse language services, you'll have

Is it possible to run rascal programs from the command line?

北城以北 提交于 2019-12-11 11:35:17
问题 I know how to run rascal code from within eclipse and how to use the REPL, but I don't know how I can run a rascal file (or group of rascal files) as a program from the command line. When I try the following, I get a parse error: $ java -Xmx1G -Xss32m -jar rascal-shell-stable.jar mymodule.rsc Version: 0.7.2.201501130937 Parse error in cwd:///mymodule.rsc from <1,11> to <1,12> The contents of mymodule.rsc : module mymodule println("hello world"); What am I doing wrong? 回答1: Well, your mymodule

Error trying to call Java method from Rascal

放肆的年华 提交于 2019-12-11 11:09:56
问题 I am trying to call a Java method from Rascal, but I'm getting this error: Cannot link method com.mypackage.Teste because: class not found Rascal code: @javaClass{com.mypackage.Teste} java void testeJava(); Java code: package com.mypackage; public class Teste { public void testeJava() { System.out.println("it worked"); } } The com.mypackage package is inside my src folder, along with all of the Rascal code. I've also tried to use src.com.mypackage.Teste as well, but had the same result. What

Looking for graph#tree transformer usage examples

你说的曾经没有我的故事 提交于 2019-12-11 07:29:16
问题 I'm writing new transpiler compiler of my programming language Ya. Since the AST Abstract Syntax Tree transformations and output language code generations is a big deal then I'm looking to use existing tree#graph transformers and output generators = pretty printers . Yet up now failed to find the tool since failed to find use examples. The list of promising tools that I've read about: Spoofax + Stratego/XT : have not found source code up now; or maybe found but it's in Java that disallows to

Does Rascal Java method AST also contain super() Expression for calls to super with arguments?

霸气de小男生 提交于 2019-12-11 06:27:43
问题 When I look at Java method AST declaration in Rascal, I see under Expression \super() node. However in Java, you can also call super() with parameters. So, I expected to see something like : \super(list[Expression] arguments) , but I do not see it. Is it traced via \methodCall() or in some other way? I could not try it myself because I get an error when I try to build an AST from a constructor with getMethodASTEclipse() method. I already opened an issue about this getMethodASTEclipse() error

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

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 21:46:33
问题 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<T> extends ArrayList<T> { public SuperTests() { super(); } public SuperTests(int capacity) { super(capacity); } @Override public void clear() { super.clear(); } public <T extends Integer> void addSupers(List<? super T> list) { } } The AST in rascal is: compilationUnit( [

Extracting class dependencies from Eclipse project using Rascal

孤街浪徒 提交于 2019-12-08 05:22:25
问题 I am using Rascal to analyze an Eclipse Java project and identify the class dependencies in this project. To be more precise: class A depends on class B if and only if class A has a method which (1) uses a parameter of type B or (2) uses a local variable of type B. Here, I am only interested in dependency relations A -> B, where A and B are both classes within my project and are both different classes. I already created an M3 model from my Eclipse project and was able to identify the required

Why are static type errors in this example code only reported at run-time by Rascal?

廉价感情. 提交于 2019-12-08 03:47:40
问题 According to the Rascal documentation, the language is statically typed. However the type errors are only reported on runtime. For example, when I create this module, I expect a type error because I am assigning a real to an int variable: module Example void example() { int x = 1.0; println(x); } When I import the module on the REPL, and finally run the function: rascal>import Example; ok rascal>example() |project://Test/src/Example.rsc|(39,7,<4,6>,<4,13>): Expected int, but got real ☞ Advice

How to cast a value type to Map in Rascal?

点点圈 提交于 2019-12-07 11:32:01
问题 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>) ☞ Advice How can I parse the value to map in order to be able to retrieve my value ? 回答1: if (map[str,str] myMap := a) { // do stuff with myMap } else { throw "<a> is not a map?"; } 来源: https://stackoverflow.com/questions/20221445/how-to-cast-a-value-type