Skip to content

Commit

Permalink
Merge branch 'main' into squeeze-charclass
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Nov 20, 2024
2 parents 67568f2 + 05e6950 commit eeaabc4
Show file tree
Hide file tree
Showing 93 changed files with 968 additions and 1,369 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
pull_request:
branches:
- main
- 'feat/*'
env:
MAVEN_OPTS: "-Xmx4G -Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"

Expand Down
39 changes: 35 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

<groupId>org.rascalmpl</groupId>
<artifactId>rascal</artifactId>
<version>0.40.7-SNAPSHOT</version>
<version>0.40.18-SNAPSHOT</version>
<packaging>jar</packaging>

<scm>
<developerConnection>scm:git:ssh://[email protected]/usethesource/rascal.git</developerConnection>
<tag>v0.40.0-BOOT1</tag>
<tag>v0.40.16</tag>
</scm>

<!-- dependency resolution configuration (usethesource) -->
Expand All @@ -32,9 +32,19 @@
<exec.mainClass>org.rascalmpl.shell.RascalShell</exec.mainClass>
<rascal.test.memory>2</rascal.test.memory>
<maven.compiler.release>11</maven.compiler.release>
<rascal-maven.version>0.28.0-RC1</rascal-maven.version>
<rascal-maven.version>0.28.9-BOOT1</rascal-maven.version>
</properties>

<licenses>
<license>
<name>BSD-2-Clause</name>
<url>https://opensource.org/license/BSD-2-Clause</url>
<distribution>repo</distribution>
<!-- we cannot define multiple licenses in this maven block, as it would mean the user can choose either of the licenses -->
<comments>Note, some older files are still licensed under Eclipse v1</comments>
</license>
</licenses>


<build>
<sourceDirectory>src</sourceDirectory>
Expand All @@ -55,6 +65,9 @@
<include>rascal-DEPENDENCIES.txt</include>
</includes>
</resource>
<resource>
<directory>${project.build.directory}/generated-resources</directory>
</resource>
</resources>
<testSourceDirectory>test</testSourceDirectory>
<testResources>
Expand Down Expand Up @@ -135,7 +148,7 @@
<ignore>${project.basedir}/src/org/rascalmpl/library/lang/rascal/syntax/tests</ignore>
</srcIgnores>
<enableStandardLibrary>false</enableStandardLibrary>
<parallel>false</parallel>
<parallel>true</parallel>
<parallelPreChecks>
<pre>${project.basedir}/src/org/rascalmpl/library/Prelude.rsc</pre>
</parallelPreChecks>
Expand Down Expand Up @@ -268,6 +281,19 @@
<arguments>-Drascal.compile.skip -Drascal.tutor.skip -DskipTests</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<id>download-licenses</id>
<goals>
<goal>download-licenses</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand All @@ -292,6 +318,11 @@
<resource>org/rascalmpl/uri/resolvers.config</resource>
<resource>io/usethesource/vallang/type/types.config </resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer">
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
<addHeader>false</addHeader>
</transformer>
</transformers>
<relocations>
<relocation>
Expand Down
7 changes: 5 additions & 2 deletions src/org/rascalmpl/interpreter/result/ConstructorFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,17 @@ public Result<IValue> computeDefaultKeywordParameter(String label, IConstructor
kwResult = def.interpret(eval);
}

// apply the static type we expect from the declaration:
kwResult = ResultFactory.makeResult(kwType, kwResult.getValue(), ctx);

if (name.equals(label)) {
// we have the one we need, bail out quickly
return kwResult;
}
else {
env.declareVariable(kwResult.getStaticType(), name);
env.declareVariable(kwType, name);
env.storeVariable(name, kwResult);
resultEnv.declareVariable(kwResult.getStaticType(), name);
resultEnv.declareVariable(kwType, name);
resultEnv.storeVariable(name, kwResult);
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/org/rascalmpl/interpreter/result/RelationResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,16 @@ public Result<IValue> fieldSelect(Field[] selectedFields) {
fieldIndices[i] = ((IInteger) f.getFieldIndex()
.interpret(this.ctx.getEvaluator()).getValue()).intValue();
} else {
String fieldName = org.rascalmpl.interpreter.utils.Names
.name(f.getFieldName());
String fieldName = org.rascalmpl.interpreter.utils.Names.name(f.getFieldName());

if (!baseType.hasFieldNames()) {
throw new UndeclaredField(fieldName, baseType,ctx.getCurrentAST());
}

try {
fieldIndices[i] = baseType.getFieldIndex(fieldName);
} catch (UndeclaredFieldException e) {
throw new UndeclaredField(fieldName, baseType,
ctx.getCurrentAST());
throw new UndeclaredField(fieldName, baseType, ctx.getCurrentAST());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

import io.usethesource.vallang.ISourceLocation;

/**
* This is a injected configuration parameter of a Rascal run-time
* environment like IRascalMonitor and IDEServices. The goal is
* to find all the file names that have the given `fileName` in
* the current run-time environment. For compiled Rascal this would
* be ClassLoader.findResources, while for the interpreter it is
* typically a search through all the roots of the source folders.
*/
public interface IResourceLocationProvider {
Set<ISourceLocation> findResources(String fileName);
}
3 changes: 2 additions & 1 deletion src/org/rascalmpl/interpreter/utils/JavaBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.rascalmpl.exceptions.JavaCompilation;
import org.rascalmpl.exceptions.JavaMethodLink;
import org.rascalmpl.exceptions.RuntimeExceptionFactory;
import org.rascalmpl.ideservices.BasicIDEServices;
import org.rascalmpl.ideservices.IDEServices;
import org.rascalmpl.interpreter.Configuration;
import org.rascalmpl.interpreter.IEvaluator;
Expand Down Expand Up @@ -445,7 +446,7 @@ else if (formals[i].isAssignableFrom(IDEServices.class)) {
args[i] = (IDEServices) monitor;
}
else {
throw new IllegalArgumentException("no IDE services are available in this environment");
args[i] = new BasicIDEServices(err, monitor);
}
}
else if (formals[i].isAssignableFrom(IResourceLocationProvider.class)) {
Expand Down
2 changes: 1 addition & 1 deletion src/org/rascalmpl/library/Content.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Content


@synopsis{Content wraps the HTTP Request/Response API to support interactive visualization types
on the terminal ((RascalShell)).}
on the terminal.}
@description{
Values wrapped in a `Content` wrapper will be displayed by interactive
Rascal applications such as the IDE, the REPL terminal and the documentation pages.
Expand Down
10 changes: 5 additions & 5 deletions src/org/rascalmpl/library/IO.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ public java str readBase64(loc file, bool includePadding=true)
throws PathNotFound, IO;
@deprecated{
Use readBase64 instead. Uuencode was a misnomer.
Use readBase64 instead.
}
public str uuencode(loc file) = readBase64(file);
Expand All @@ -583,7 +583,7 @@ public java void writeBase64(loc file, str content)
throws PathNotFound, IO;
@deprecated{
Use writeBase64 instead. Uudecode was a misnomer.
Use writeBase64 instead.
}
public void uudecode(loc file, str content) = writeBase64(file, content);
Expand Down Expand Up @@ -712,7 +712,7 @@ public java str createLink(str title, str target);
@javaClass{org.rascalmpl.library.Prelude}
@deprecated{
use `readBase64` instead.
Use `readBase64` instead.
}
public java str toBase64(loc file, bool includePadding=true)
throws PathNotFound, IO;
Expand All @@ -721,14 +721,14 @@ throws PathNotFound, IO;
java void copy(loc source, loc target, bool recursive=false, bool overwrite=true) throws IO;
@deprecated{
use the `copy` function instead
Use the `copy` function instead
}
void copyFile(loc source, loc target) {
copy(source, target, recursive=false, overwrite=true);
}
@deprecated{
use the `copy` function instead
Use the `copy` function instead
}
void copyDirectory(loc source, loc target) {
copy(source, target, recursive=true, overwrite=true);
Expand Down
30 changes: 6 additions & 24 deletions src/org/rascalmpl/library/List.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ dup([3, 1, 5, 3, 1, 7, 1, 2]);
list[&T] dup(list[&T] lst)
= ([] | (ix in it) ? it : it + [ix] | &T ix <- lst);

@deprecated{
use the indexing instead
}
@deprecated{Use a list index instead}
@javaClass{org.rascalmpl.library.Prelude}
java &T elementAt(list[&T] lst, int index);

Expand Down Expand Up @@ -420,7 +418,7 @@ list[&T] mix(list[&T] l, list[&T] r){
sizeL = size(l);
sizeR = size(r);
minSize = sizeL < sizeR ? sizeL : sizeR;
return [elementAt(l,i),elementAt(r,i)| i <- [0 .. minSize]] + drop(sizeR,l) + drop(sizeL,r);
return [l[i],r[i] | i <- [0 .. minSize]] + drop(sizeR,l) + drop(sizeL,r);
}
@synopsis{Compute all permutations of a list.}
Expand Down Expand Up @@ -481,7 +479,8 @@ push("eagle", ["zebra", "elephant", "snake", "owl"]);
list[&T] push(&T elem, list[&T] lst) = [elem] + lst;
@synopsis{Apply a function to successive elements of list and combine the results (__deprecated__).}
@synopsis{Apply a function to successive elements of list and combine the results.}
@deprecated{This function is deprecated. Use a reducer expression instead, like `(init | f(it, e) | e <- lst)`.}
@description{
Apply the function `fn` to successive elements of list `lst` starting with `unit`.
}
Expand All @@ -492,22 +491,7 @@ int add(int x, int y) { return x + y; }
reducer([10, 20, 30, 40], add, 0);
```
}
@benefits{
}
@pitfalls{
:::warning
This function is *deprecated*, use a reducer expression instead. E.g. `(init | f(it, e) | e <- lst)`.
:::
}
&T reducer(list[&T] lst, &T (&T, &T) fn, &T unit)
{
&T result = unit;
for(&T elm <- lst){
result = fn(result, elm);
}
return result;
}
&T reducer(list[&T] lst, &T (&T, &T) fn, &T unit) = (unit | fn(it, elm) | elm <- lst);
list[&T] remove(list[&T] lst, int indexToDelete) =
[ lst[i] | i <- index(lst), i != indexToDelete ];
Expand Down Expand Up @@ -845,9 +829,7 @@ l = [10,20,30,40];
s = {*l};
```
}
@deprecated{
Please use {*myList} instead.
}
@javaClass{org.rascalmpl.library.Prelude}
java set[&T] toSet(list[&T] lst);
Expand Down
6 changes: 3 additions & 3 deletions src/org/rascalmpl/library/Prelude.java
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,7 @@ public IValue head(IList lst)
}

public IValue last(IList lst)
// @doc{head -- get the last element of a list}
// @doc{last -- get the last element of a list}
{
if(lst.length() > 0){
return lst.get(lst.length() - 1);
Expand Down Expand Up @@ -4110,9 +4110,9 @@ public IBool isOverlapping(ISourceLocation first, ISourceLocation second) {
if (first.hasOffsetLength()) {
if (second.hasOffsetLength()) {
int firstStart = first.getOffset();
int firstEnd = firstStart + first.getLength();
int firstEnd = firstStart + first.getLength() - 1; // Inclusive
int secondStart = second.getOffset();
int secondEnd = secondStart + second.getLength();
int secondEnd = secondStart + second.getLength() - 1; // Inclusive

return values.bool(
(firstStart <= secondStart && secondStart <= firstEnd)
Expand Down
8 changes: 2 additions & 6 deletions src/org/rascalmpl/library/Set.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ power1({1,2,3,4});
}
public set[set[&T]] power1(set[&T] st) = power(st) - {{}};

@synopsis{Apply a function to successive elements of a set and combine the results (__deprecated__).}
@synopsis{Apply a function to successive elements of a set and combine the results.}
@description{
Apply the function `fn` to successive elements of set `s` starting with `unit`.
}
Expand All @@ -229,11 +229,7 @@ int add(int x, int y) { return x + y; }
reducer({10, 20, 30, 40}, add, 0);
```
}
@pitfalls{
:::warning
This function is *deprecated*, use a reducer expression instead, such as `(init | fn(it,e) | e <- st)`.
:::
}
@deprecated{Use a reducer expression instead, such as `(init | fn(it,e) | e <- st)`.}
public &T reducer(set[&T] st, &T (&T,&T) fn, &T unit) =
(unit | fn(it,elm) | elm <- st);

Expand Down
4 changes: 2 additions & 2 deletions src/org/rascalmpl/library/String.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ private java str format(str s, str dir, int n, str pad);
@synopsis{Determine if a string matches the given (Java-syntax) regular expression.}
@javaClass{org.rascalmpl.library.Prelude}
@deprecated{
use `/re/ := s` instead
Use `/re/ := s` instead
}
public java bool rexpMatch(str s, str re);
Expand All @@ -627,7 +627,7 @@ toLocation("http://grammarware.net");
toLocation("document.xml");
```
}
@deprecated{Use ((Location::locFromWindowsPath)) for example. The current function does not handle all the different intricasies of path notation.}
@deprecated{Use ((Location::locFromWindowsPath)) for example; toLocation does not handle all intricasies of path notation.}
public loc toLocation(str s) = (/<car:.*>\:\/\/<cdr:.*>/ := s) ? |<car>://<cdr>| : |cwd:///<s>|;


Expand Down
Loading

0 comments on commit eeaabc4

Please sign in to comment.