rascal | A simple Pascal interpreter written in rust | Interpreter library
kandi X-RAY | rascal Summary
kandi X-RAY | rascal Summary
A simple Pascal interpreter written in rust.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of rascal
rascal Key Features
rascal Examples and Code Snippets
program fibonacci;
var
input: integer;
function fib(n:integer): integer;
var
val: integer;
return: integer;
begin
if (n <= 2) then
begin
val := 1;
end
els
program exampleProcedure;
procedure printSum(a, b: integer);
var
sum: integer;
begin
sum := a + b;
writeln(IntToString(a) + ' + ' + IntToString(b) + ' = ' + IntToString(sum));
end
begin
printSum(5, 10);
end
program exampleBuiltIns;
var
my_int: integer;
my_real: real;
my_string: string;
begin
my_int := 5;
my_string := IntToString(my_int);
my_real := 5.5;
my_string := RealToString(my_real);
my_string := '5';
m
Community Discussions
Trending Discussions on rascal
QUESTION
I am trying to add instrumentation (e.g. logging some information) to methods in a Java file. I am using the following Rascal code which seems to work mostly:
...ANSWER
Answered 2021-Dec-17 at 13:13Alas, capturing whitespace with a concrete pattern is not a feature of the current version of Rascal. We used to have it, but now it's back on the TODO list. I can point you to papers about the topic if you are interested. So for now you have to deal with this "damage" later.
You could write a Tree to Tree transformation on the generic level (see ParseTree.rsc), to fix indentation issues in a parse tree after your transformation, or to re-insert the comments that you lost. This is about matching the Tree data-type and appl
constructors. The Tree format is a form of reflection on the parse trees of Rascal that allow any kind of transformation, including whitespace and comments.
The parse error you talked about is caused by not using the start
non-terminal. If you use parse(#start[CompilationUnit], ...)
then whitespace and comments before and after the CompilationUnit are accepted.
QUESTION
I am executing a command in Rascal on Windows 10 (some batch file) which in itself works fine:
...ANSWER
Answered 2021-Dec-12 at 14:36The working dir parameters is a so called "keyword parameter" which you call using this syntax:
QUESTION
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.
ANSWER
Answered 2021-Sep-01 at 11:55eval
is not an often used function in Rascal; do you really need to dynamically create patterns?- there is the node pattern:
(str name)()
which in this case would match any constructor with no arguments - the real answer is that if you do
import
the right modules in the call toeval
those modules will be cached by the interpreter which is used by theeval
function - so that would not be slow
- however, module reloading is not well-supported and you might have to restart the shell to get a fresh version into the eval evaluator.
QUESTION
I'm trying to create an outline for a syntax definition I create in rascal. I've managed to make the various object appear in the outline by simply adding label annotations like recommended in the documentation. However, I would also like to "categorise" these objects so that all the objects of the same type end up under a common collapsible category. Like the way that Rascal's outline is with all the annotations, functions, variables, tests and so on sorted into their own categories. I haven't found anything really in the documentation about it. I've tried applying @Category to the syntax and to the AST, neither really worked
...ANSWER
Answered 2021-Aug-13 at 17:24You can nest nodes like so:
QUESTION
I have this syntax definition
...ANSWER
Answered 2021-Jul-16 at 09:33Turns out I was overcomplicating the whole thing. Instead of trying to have a union of types I simply added an additional construction to RULEPART that could accommodate COMMAND. I think I might have been also initially confused about some of the issues because I had bugs in other parts of the code that I was misinterpreting as being caused by this problem.
QUESTION
I'm attempting to create a Socket library in Rascal to operate a Java TCP socket class. For this the following basic setup is used: (src)>(Network)>(Socket.java, Socket.rsc) [1]: https://i.stack.imgur.com/a66RS.png
When attempting to import the Network::Socket module into a Rascal Terminal the following error occurs: "Cannot link method Network.Socket because: class not found"
The Rascal module:
...ANSWER
Answered 2021-Jul-05 at 13:39The fault laid in some metadeta of the eclipse project being faulty.
Creating a new project with the exact same setup and files made it work.
Edit: Believed cause of error is renaming the project
QUESTION
When defining a syntax, it is possible to match 1 or more times (+) or 0 or more times (*) similarly to how it is done in regex. However, I have not found in the rascal documentation if it is possible to also match a Symbol a specific amount of times. In regex (and Rascal patterns) this is done with an integer between two curly brackets but this doesn't seem to work for syntax definition. Ideally, I'd want something like:
...ANSWER
Answered 2021-Jun-13 at 10:25No this meta syntax does not exist in Rascal. We did not add it.
You could write an over-estimation like this and have a post-parse filter reject more than 5 items:
QUESTION
I want to show the data of table in a form for updating it.
So I'm using this code :
...ANSWER
Answered 2021-May-26 at 13:56You can give classes to your p
tags inside your card
.Then , whenever user click on edit
simply use .closest
and .find()
to get values from p
tags and show them inside modal inputs .
Demo Code :
QUESTION
How can I create a set containing a loc, int and string? In the example below it seems my map is converted to the container type ' value'. I would like to use the characteristics of a set; Only one element should be contained in the set and the order does not matter . In the example below the same elements are contained in what I was hoping to be a set.
...ANSWER
Answered 2021-Jan-06 at 14:04Something weird is going on . First mySet is a map, and then you add a set to it and the variable mySet
is suddenly a set that contains the previous map and the new element you added. It looks to me that +=
has a bug.
If you want to add several elements to a set, you should start with a set and add elements to it like so:
QUESTION
In java I would use: System.getProperty("os.name") to get Java to return the operating system. Is something similar possible in Rascal? My goal is to write a method to write text files to a folder that works OS-independent. Something like;
...ANSWER
Answered 2020-Dec-23 at 17:03If you just use a home URL like home:///path/to/file
the writeFile function will take care of the rest. There is also cwd://
for the current working directory and tmp:///
for the temp folder.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install rascal
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page