From b1a56fb777aa0751f9018392427f2991dfc3729e Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 20 Oct 2026 12:17:14 +0200 Subject: [PATCH 01/41] Added rascal-generated-java as submodule. This repository currently contains the compiled parser generator --- .gitmodules | 3 +++ generated | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 generated diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000000..5dddf201017 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "generated"] + path = generated + url = git@github.com:usethesource/rascal-generated-java.git diff --git a/generated b/generated new file mode 160000 index 00000000000..504e642e5e4 --- /dev/null +++ b/generated @@ -0,0 +1 @@ +Subproject commit 504e642e5e4c4669b23d84e172053c9e9a9393e1 From 9b72a112f6d83df7392b320df91201459b48a4b4 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Mon, 26 Oct 2026 09:32:09 +0100 Subject: [PATCH 02/41] Wired up the compiled parser generator --- .settings/org.eclipse.core.resources.prefs | 2 +- pom.xml | 21 ++- src/org/rascalmpl/interpreter/Evaluator.java | 11 -- src/org/rascalmpl/parser/ParserGenerator.java | 151 ++++++------------ .../semantics/dynamic/ShellCommand.java | 1 - 5 files changed, 72 insertions(+), 114 deletions(-) diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index e16014115e1..3063ac4334d 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,11 +1,11 @@ eclipse.preferences.version=1 +encoding//generated/src/main/java=UTF-8 encoding//src/org/rascalmpl/library=UTF-8 encoding//src/org/rascalmpl/library/experiments/vis2/lib/MarkdownConverter.js=UTF-8 encoding//src/org/rascalmpl/library/experiments/vis2/lib/nv.d3.css=UTF-8 encoding//src/org/rascalmpl/library/experiments/vis2/lib/nv.d3.js=UTF-8 encoding//src/org/rascalmpl/library/experiments/vis2/lib/reset.css=UTF-8 encoding//src/org/rascalmpl/library/lang/rascal/tests/functionality/DataType.rsc=UTF-8 -encoding//target/generated-resources=UTF-8 encoding//test/org/rascalmpl/test/data=UTF-8 encoding/=UTF-8 encoding/META-INF=UTF-8 diff --git a/pom.xml b/pom.xml index f40d864f98f..dba7934562a 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ false - ${project.build.directory}/generated-resources + generated/src/main/java test @@ -410,6 +410,25 @@ + + org.codehaus.mojo + build-helper-maven-plugin + 3.6.2 + + + add-source + generate-sources + + add-source + + + + generated/src/main/java + + + + + diff --git a/src/org/rascalmpl/interpreter/Evaluator.java b/src/org/rascalmpl/interpreter/Evaluator.java index abd9989d327..90dd47d258e 100755 --- a/src/org/rascalmpl/interpreter/Evaluator.java +++ b/src/org/rascalmpl/interpreter/Evaluator.java @@ -719,17 +719,6 @@ public IConstructor getGrammar(Environment env) { return getParserGenerator().getGrammarFromModules(monitor, root.getName(), root.getSyntaxDefinition()); } - public IValue diagnoseAmbiguity(IRascalMonitor monitor, IConstructor parseTree) { - IRascalMonitor old = setMonitor(monitor); - try { - ParserGenerator pgen = getParserGenerator(); - return pgen.diagnoseAmbiguity(parseTree); - } - finally { - setMonitor(old); - } - } - public IConstructor getExpandedGrammar(IRascalMonitor monitor, ISourceLocation uri) { IRascalMonitor old = setMonitor(monitor); try { diff --git a/src/org/rascalmpl/parser/ParserGenerator.java b/src/org/rascalmpl/parser/ParserGenerator.java index dd56d4abfdf..3142dbbbb8c 100644 --- a/src/org/rascalmpl/parser/ParserGenerator.java +++ b/src/org/rascalmpl/parser/ParserGenerator.java @@ -30,6 +30,7 @@ import org.rascalmpl.interpreter.utils.JavaBridge; import org.rascalmpl.interpreter.utils.Profiler; import org.rascalmpl.parser.gtd.IGTD; +import org.rascalmpl.runtime.RascalExecutionContext; import org.rascalmpl.shell.ShellEvaluatorFactory; import org.rascalmpl.uri.URIResolverRegistry; import org.rascalmpl.values.IRascalValueFactory; @@ -44,43 +45,46 @@ import io.usethesource.vallang.IString; import io.usethesource.vallang.IValue; import io.usethesource.vallang.IValueFactory; +import rascal.lang.rascal.grammar.$ConcreteSyntax; +import rascal.lang.rascal.grammar.$ParserGenerator; +import rascal.lang.rascal.grammar.definition.$Keywords; +import rascal.lang.rascal.grammar.definition.$Literals; +import rascal.lang.rascal.grammar.definition.$Modules; +import rascal.lang.rascal.grammar.definition.$Parameters; +import rascal.lang.rascal.grammar.definition.$Priorities; +import rascal.lang.rascal.grammar.definition.$Regular; +import rascal.lang.rascal.grammar.definition.$Symbols; public class ParserGenerator { - private final Evaluator evaluator; private final JavaBridge bridge; private final IValueFactory vf; private static final String packageName = "org.rascalmpl.test.parser"; private static final boolean debug = false; + private final $ParserGenerator parserGenerator; + private final $ConcreteSyntax concreteSyntax; + private final $Modules modules; + private final $Priorities priorities; + private final $Regular regular; + private final $Keywords keywords; + private final $Literals literals; + private final $Parameters parameters; + private final $Symbols symbols; + public ParserGenerator(IRascalMonitor monitor, PrintWriter out, IValueFactory factory, Configuration config) { - this.evaluator = ShellEvaluatorFactory.getBasicEvaluator(Reader.nullReader(), out, out, monitor, "$parsergenerator$"); - this.evaluator.getConfiguration().setGeneratorProfiling(config.getGeneratorProfilingProperty()); - this.evaluator.setBootstrapperProperty(true); + var rex = new RascalExecutionContext(null, out, out, null, null, $ParserGenerator.class); + var ms = rex.getModuleStore(); + parserGenerator = new $ParserGenerator(rex); + concreteSyntax = ms.getModule($ConcreteSyntax.class); + modules = ms.getModule($Modules.class); + priorities = ms.getModule($Priorities.class); + regular = ms.getModule($Regular.class); + keywords = ms.getModule($Keywords.class); + literals = ms.getModule($Literals.class); + parameters = ms.getModule($Parameters.class); + symbols = ms.getModule($Symbols.class); this.bridge = new JavaBridge(Collections.singletonList(Evaluator.class.getClassLoader()), factory, config); this.vf = factory; - - evaluator.doImport(monitor, - "lang::rascal::grammar::ParserGenerator", - "lang::rascal::grammar::ConcreteSyntax", - "lang::rascal::grammar::definition::Modules", - "lang::rascal::grammar::definition::Priorities", - "lang::rascal::grammar::definition::Regular", - "lang::rascal::grammar::definition::Keywords", - "lang::rascal::grammar::definition::Literals", - "lang::rascal::grammar::definition::Parameters", - "lang::rascal::grammar::definition::Symbols", - "analysis::grammars::Ambiguity" - ); - } - - public void setGeneratorProfiling(boolean f) { - evaluator.getConfiguration().setGeneratorProfiling(f); - } - - public IValue diagnoseAmbiguity(IConstructor parseForest) { - synchronized(evaluator) { - return evaluator.call("diagnose", parseForest); - } } private void debugOutput(String kind, Object thing, String file) { @@ -88,7 +92,7 @@ private void debugOutput(String kind, Object thing, String file) { String classString = thing.toString(); FileOutputStream s = null; try { - evaluator.getErrorPrinter().println("\nWriting " + kind + " to " + file); + System.err.println("\nWriting " + kind + " to " + file); s = new FileOutputStream(file); s.write(classString.getBytes()); @@ -109,69 +113,37 @@ private void debugOutput(String kind, Object thing, String file) { } } - public IConstructor getGrammarFromModules(IRascalMonitor monitor, String main, IMap modules) { - synchronized(evaluator) { - return (IConstructor) evaluator.call(monitor, "modules2grammar", vf.string(main), modules); - } + public IConstructor getGrammarFromModules(IRascalMonitor monitor, String main, IMap mods) { + return modules.modules2grammar(vf.string(main), mods); } public IConstructor getExpandedGrammar(IRascalMonitor monitor, String main, IMap definition) { - synchronized(evaluator) { - IConstructor g = getGrammarFromModules(monitor, main, definition); - g = (IConstructor) evaluator.call(monitor, "expandKeywords", g); - g = (IConstructor) evaluator.call(monitor, "makeRegularStubs", g); - g = (IConstructor) evaluator.call(monitor, "expandRegularSymbols", g); - g = (IConstructor) evaluator.call(monitor, "expandParameterizedSymbols", g); - g = (IConstructor) evaluator.call(monitor, "literals", g); - return g; - } + var g = getGrammarFromModules(monitor, main, definition); + g = keywords.expandKeywords(g); + g = (IConstructor) regular.makeRegularStubs(g); + g = regular.expandRegularSymbols(g); + g = parameters.expandParameterizedSymbols(g); + g = literals.literals(g); + + return g; } - public ISet getNestingRestrictions(IRascalMonitor monitor, - IConstructor g) { - synchronized (evaluator) { - return (ISet) evaluator.call(monitor, "doNotNest", g); - } + public ISet getNestingRestrictions(IRascalMonitor monitor, IConstructor g) { + return priorities.doNotNest(g); } /** * Produces the name generated by the parser generator for a parse method for the given symbol */ public String getParserMethodName(IConstructor symbol) { - // we use a fast non-synchronized path for simple cases; - // this is to prevent locking the evaluator in IDE contexts - // where many calls into the evaluator/parser are fired in rapid - // succession. - - switch (symbol.getName()) { - case "start": - return "$start_" + getParserMethodName(SymbolAdapter.getStart(symbol)); - case "layouts": - return "$l_" + SymbolAdapter.getName(symbol); - case "sort": - return SymbolAdapter.getName(symbol); - case "lex": - return SymbolAdapter.getName(symbol); - case "keywords": - return "$k_" + SymbolAdapter.getName(symbol); - } - - synchronized (evaluator) { - // TODO we assume here this is a context-free non-terminal for now. - // Later with the syntax role modifiers we can implement parsing for lexical regulars too - Map kwArgs = Map.of("withLayout", vf.bool(true)); - return ((IString) evaluator.call("getParserMethodName", "lang::rascal::grammar::ParserGenerator", kwArgs, symbol)).getValue(); - } + return parserGenerator.getParserMethodName(symbol, symbol.asWithKeywordParameters().getParameters()).getValue(); // TODO (RA): check, different than JV's implementation } /** * Converts the parse tree of a symbol to a UPTR symbol */ public IConstructor symbolTreeToSymbol(IConstructor symbol, boolean withLayout) { - synchronized (evaluator) { - Map kws = Map.of("withLayout", vf.bool(withLayout)); - return (IConstructor) evaluator.call("sym2symbol", "lang::rascal::grammar::definition::Symbols", kws, symbol); - } + return symbols.sym2symbol(symbol, symbol.asWithKeywordParameters().getParameters()); // TODO (RA): check, different than JV's implementation } /** @@ -184,12 +156,7 @@ public IConstructor symbolTreeToSymbol(IConstructor symbol, boolean withLayout) * @return A parser class, ready for instantiation */ public Class> getNewParser(IRascalMonitor monitor, ISourceLocation loc, String name, IMap definition) { - Profiler profiler = evaluator.getConfiguration().getGeneratorProfilingProperty() ? new Profiler(evaluator) : null; - try { - if (profiler != null) { - profiler.start(); - } IConstructor grammar = IRascalValueFactory.getInstance().grammar(definition); debugOutput("grammar", grammar, System.getProperty("java.io.tmpdir") + "/grammar.trm"); return getNewParser(monitor, loc, name, grammar); @@ -200,14 +167,6 @@ public Class> getNewParser(IRascalMon catch (Throw e) { throw new ImplementationError("parser generator: " + e.getMessage() + e.getTrace()); } - finally { - if (profiler != null) { - profiler.pleaseStop(); - evaluator.getOutPrinter().println("PROFILE:"); - profiler.report(); - profiler = null; - } - } } /** @@ -223,11 +182,8 @@ public Class> getNewParser(IRascalMon try { String normName = name.replaceAll("::", "_").replaceAll("\\\\", "_"); - IString classString; - synchronized (evaluator) { - classString = (IString) evaluator.call(monitor, "newGenerate", vf.string(packageName), vf.string(normName), grammar); - } - debugOutput("java code", classString.getValue(), "./test/org/rascalmpl/test/parser/" + normName + ".java"); + IString classString = parserGenerator.newGenerate(vf.string(packageName), vf.string(normName), grammar); + debugOutput("java code", classString.getValue(), System.getProperty("java.io.tmpdir") + "/parser.java"); return bridge.compileJava(loc, packageName + "." + normName, classString.getValue()); } catch (ClassCastException e) { @@ -250,12 +206,9 @@ public Class> getNewParser(IRascalMon public void writeNewParser(IRascalMonitor monitor, ISourceLocation loc, String name, IMap definition, ISourceLocation target) throws IOException { try (OutputStream out = URIResolverRegistry.getInstance().getOutputStream(target, false)) { String normName = name.replaceAll("::", "_").replaceAll("\\\\", "_"); - IString classString; IConstructor grammar = IRascalValueFactory.getInstance().grammar(definition); - - synchronized (evaluator) { - classString = (IString) evaluator.call(monitor, "newGenerate", vf.string(packageName), vf.string(normName), grammar); - } + + IString classString = parserGenerator.newGenerate(vf.string(packageName), vf.string(normName), grammar); debugOutput("java code", classString.getValue(), System.getProperty("java.io.tmpdir") + "/parser.java"); bridge.compileJava(loc, packageName + "." + normName, classString.getValue(), out); @@ -267,8 +220,6 @@ public void writeNewParser(IRascalMonitor monitor, ISourceLocation loc, String n } public IString createHole(IConstructor part, IInteger size) { - synchronized (evaluator) { - return (IString) evaluator.call("createHole", part, size); - } + return concreteSyntax.createHole(part, size); } } diff --git a/src/org/rascalmpl/semantics/dynamic/ShellCommand.java b/src/org/rascalmpl/semantics/dynamic/ShellCommand.java index 46744163ec4..48813b79cbd 100644 --- a/src/org/rascalmpl/semantics/dynamic/ShellCommand.java +++ b/src/org/rascalmpl/semantics/dynamic/ShellCommand.java @@ -227,7 +227,6 @@ private static void setOption(IEvaluator> __eval, String name, St switch (name) { case Configuration.GENERATOR_PROFILING_PROPERTY: __eval.getConfiguration().setGeneratorProfiling(Boolean.parseBoolean(value)); - __eval.getParserGenerator().setGeneratorProfiling(Boolean.parseBoolean(value)); break; case Configuration.PROFILING_PROPERTY: __eval.getConfiguration().setProfiling(Boolean.parseBoolean(value)); From c53980892b4c39b05cafc3d455900595e296a1cc Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 10 Nov 2026 13:56:24 +0100 Subject: [PATCH 03/41] Correctly adding layout before looking for parse functions --- src/org/rascalmpl/parser/ParserGenerator.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/parser/ParserGenerator.java b/src/org/rascalmpl/parser/ParserGenerator.java index 3142dbbbb8c..9ba5c18ae94 100644 --- a/src/org/rascalmpl/parser/ParserGenerator.java +++ b/src/org/rascalmpl/parser/ParserGenerator.java @@ -136,14 +136,18 @@ public ISet getNestingRestrictions(IRascalMonitor monitor, IConstructor g) { * Produces the name generated by the parser generator for a parse method for the given symbol */ public String getParserMethodName(IConstructor symbol) { - return parserGenerator.getParserMethodName(symbol, symbol.asWithKeywordParameters().getParameters()).getValue(); // TODO (RA): check, different than JV's implementation + // TODO we assume here this is a context-free non-terminal for now. + // Later with the syntax role modifiers we can implement parsing for lexical regulars too + Map kwArgs = Map.of("withLayout", vf.bool(true)); + return parserGenerator.getParserMethodName(symbol, kwArgs).getValue(); } /** * Converts the parse tree of a symbol to a UPTR symbol */ public IConstructor symbolTreeToSymbol(IConstructor symbol, boolean withLayout) { - return symbols.sym2symbol(symbol, symbol.asWithKeywordParameters().getParameters()); // TODO (RA): check, different than JV's implementation + Map kwArgs = Map.of("withLayout", vf.bool(withLayout)); + return symbols.sym2symbol(symbol, kwArgs); } /** From ffbb276e71dfc497fe528ecf9a312cb4b902c44e Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 11 Nov 2026 08:54:41 +0100 Subject: [PATCH 04/41] Using URIUtil function to convert from URL to loc --- src/org/rascalmpl/library/lang/java/JavaRunner.java | 2 +- src/org/rascalmpl/runtime/$RascalModule.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/org/rascalmpl/library/lang/java/JavaRunner.java b/src/org/rascalmpl/library/lang/java/JavaRunner.java index c0826068314..01560eefe79 100644 --- a/src/org/rascalmpl/library/lang/java/JavaRunner.java +++ b/src/org/rascalmpl/library/lang/java/JavaRunner.java @@ -72,7 +72,7 @@ public void testIgnored(Description description) throws Exception { public ISourceLocation getJUnitClassPath(IConstructor version) { try { assert version.getName().equals("junit4"); - return vf.sourceLocation(JUnit4.class.getProtectionDomain().getCodeSource().getLocation().toURI()); + return vf.sourceLocation(URIUtil.fromURL(JUnit4.class.getProtectionDomain().getCodeSource().getLocation())); } catch (URISyntaxException e) { throw RuntimeExceptionFactory.illegalArgument(vf.string(e.getMessage())); diff --git a/src/org/rascalmpl/runtime/$RascalModule.java b/src/org/rascalmpl/runtime/$RascalModule.java index 12cfc6d4579..1a01d420d79 100644 --- a/src/org/rascalmpl/runtime/$RascalModule.java +++ b/src/org/rascalmpl/runtime/$RascalModule.java @@ -275,7 +275,7 @@ public Set findResources(String fileName) { try { for (URL found : Collections.list(getClass().getClassLoader().getResources(fileName))) { try { - result.add($RVF.sourceLocation(found.toURI())); + result.add($RVF.sourceLocation(URIUtil.fromURL(found))); } catch (URISyntaxException e) { $MONITOR.warning("WARNING: skipping " + found + " due to URI syntax exception", URIUtil.rootLocation("module-init")); } @@ -467,7 +467,7 @@ public IList readBinaryConstantsFile(Class c, String path, int expected_lengt if(url == null) { throw RuntimeExceptionFactory.io($RVF.string("Cannot find resource " + path)); } - loc = $RVF.sourceLocation(url.toURI()); + loc = $RVF.sourceLocation(URIUtil.fromURL(url)); } catch (URISyntaxException e) { System.err.println("readBinaryConstantsFile: " + path + " throws " + e.getMessage()); } From 7173397ea21e98abb53bcda2e1ada54e880c347f Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 11 Nov 2026 09:42:54 +0100 Subject: [PATCH 05/41] Using cwd as project root for RascalExecutionContex (cf. ShellEvaluatorFactory) --- src/org/rascalmpl/runtime/RascalExecutionContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/rascalmpl/runtime/RascalExecutionContext.java b/src/org/rascalmpl/runtime/RascalExecutionContext.java index f0d24603a15..d2c22fa66f7 100644 --- a/src/org/rascalmpl/runtime/RascalExecutionContext.java +++ b/src/org/rascalmpl/runtime/RascalExecutionContext.java @@ -82,7 +82,7 @@ public RascalExecutionContext( this.errwriter = errwriter; this.pcfg = pcfg == null ? new PathConfig() : pcfg; - ISourceLocation projectRoot = inferProjectRoot(clazz); + ISourceLocation projectRoot = URIUtil.rootLocation("cwd"); this.ideServices = ideServices == null ? new BasicIDEServices(errwriter, this, null, projectRoot) : ideServices; $RVF = new RascalRuntimeValueFactory(this); $TF = TypeFactory.getInstance(); From a7a3ae5ca55638968bc878f86c7f5a09f484ff54 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 11 Nov 2026 09:43:33 +0100 Subject: [PATCH 06/41] Disabled registration of project locations based on all project living in the parent of the current project --- .../runtime/RascalExecutionContext.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/org/rascalmpl/runtime/RascalExecutionContext.java b/src/org/rascalmpl/runtime/RascalExecutionContext.java index d2c22fa66f7..a722acaf072 100644 --- a/src/org/rascalmpl/runtime/RascalExecutionContext.java +++ b/src/org/rascalmpl/runtime/RascalExecutionContext.java @@ -99,32 +99,32 @@ public RascalExecutionContext( reg.registerLogical(new TargetURIResolver(projectRoot, projectName)); } - String projectPath = projectRoot.getPath(); - String projectsDirPath = projectPath.substring(0, projectPath.length() - projectName.length()-1); + // String projectPath = projectRoot.getPath(); + // String projectsDirPath = projectPath.substring(0, projectPath.length() - projectName.length()-1); - try { - ISourceLocation projectsDir = $RVF.sourceLocation(projectRoot.getScheme(), projectRoot.getAuthority(),projectsDirPath); - String[]entries = URIResolverRegistry.getInstance().listEntries(projectsDir); - if (entries != null) { - //System.err.print("INFO adding projects: "); - for(String entryName : entries) { - if(entryName.charAt(0) != '.' && !(entryName.equals("pom-parent") || entryName.equals("bin") || entryName.equals("src") || entryName.equals("META-INF"))) { - ISourceLocation entryRoot = $RVF.sourceLocation(projectsDir.getScheme(), projectsDir.getAuthority(), projectsDir.getPath() + "/" + entryName); - if(URIResolverRegistry.getInstance().isDirectory(entryRoot)) { - reg.registerLogical(new ProjectURIResolver(entryRoot, entryName)); - reg.registerLogical(new TargetURIResolver(entryRoot, entryName)); - rascalSearchPath.addPathContributor(new SourceLocationListContributor(entryName, $RVF.list(entryRoot))); - //System.err.print(entryName + " "); - } - } - } - //System.err.println(""); - } - } catch (IOException e) { - return; - } catch (URISyntaxException e) { - return; - } + // try { + // ISourceLocation projectsDir = $RVF.sourceLocation(projectRoot.getScheme(), projectRoot.getAuthority(),projectsDirPath); + // String[]entries = URIResolverRegistry.getInstance().listEntries(projectsDir); + // if (entries != null) { + // //System.err.print("INFO adding projects: "); + // for(String entryName : entries) { + // if(entryName.charAt(0) != '.' && !(entryName.equals("pom-parent") || entryName.equals("bin") || entryName.equals("src") || entryName.equals("META-INF"))) { + // ISourceLocation entryRoot = $RVF.sourceLocation(projectsDir.getScheme(), projectsDir.getAuthority(), projectsDir.getPath() + "/" + entryName); + // if(URIResolverRegistry.getInstance().isDirectory(entryRoot)) { + // reg.registerLogical(new ProjectURIResolver(entryRoot, entryName)); + // reg.registerLogical(new TargetURIResolver(entryRoot, entryName)); + // rascalSearchPath.addPathContributor(new SourceLocationListContributor(entryName, $RVF.list(entryRoot))); + // //System.err.print(entryName + " "); + // } + // } + // } + // //System.err.println(""); + // } + // } catch (IOException e) { + // return; + // } catch (URISyntaxException e) { + // return; + // } } IRascalValueFactory getRascalRuntimeValueFactory() { return $RVF; } From 599b45fce2268c7045ad1f999eeef8b74840dd02 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 11 Nov 2026 09:44:05 +0100 Subject: [PATCH 07/41] Unstubbed monitor-related methods in RascalExecutionContext --- src/org/rascalmpl/parser/ParserGenerator.java | 6 ++--- .../runtime/RascalExecutionContext.java | 22 ++++++------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/org/rascalmpl/parser/ParserGenerator.java b/src/org/rascalmpl/parser/ParserGenerator.java index 9ba5c18ae94..9d39075f27c 100644 --- a/src/org/rascalmpl/parser/ParserGenerator.java +++ b/src/org/rascalmpl/parser/ParserGenerator.java @@ -25,17 +25,15 @@ import org.rascalmpl.debug.IRascalMonitor; import org.rascalmpl.exceptions.ImplementationError; import org.rascalmpl.exceptions.Throw; +import org.rascalmpl.ideservices.IDEServices; import org.rascalmpl.interpreter.Configuration; import org.rascalmpl.interpreter.Evaluator; import org.rascalmpl.interpreter.utils.JavaBridge; -import org.rascalmpl.interpreter.utils.Profiler; import org.rascalmpl.parser.gtd.IGTD; import org.rascalmpl.runtime.RascalExecutionContext; -import org.rascalmpl.shell.ShellEvaluatorFactory; import org.rascalmpl.uri.URIResolverRegistry; import org.rascalmpl.values.IRascalValueFactory; import org.rascalmpl.values.parsetrees.ITree; -import org.rascalmpl.values.parsetrees.SymbolAdapter; import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.IInteger; @@ -72,7 +70,7 @@ public class ParserGenerator { private final $Symbols symbols; public ParserGenerator(IRascalMonitor monitor, PrintWriter out, IValueFactory factory, Configuration config) { - var rex = new RascalExecutionContext(null, out, out, null, null, $ParserGenerator.class); + var rex = new RascalExecutionContext(Reader.nullReader(), out, out, null, monitor instanceof IDEServices ? (IDEServices) monitor : null, $ParserGenerator.class); var ms = rex.getModuleStore(); parserGenerator = new $ParserGenerator(rex); concreteSyntax = ms.getModule($ConcreteSyntax.class); diff --git a/src/org/rascalmpl/runtime/RascalExecutionContext.java b/src/org/rascalmpl/runtime/RascalExecutionContext.java index a722acaf072..5f9a8f47055 100644 --- a/src/org/rascalmpl/runtime/RascalExecutionContext.java +++ b/src/org/rascalmpl/runtime/RascalExecutionContext.java @@ -31,12 +31,10 @@ import java.io.Reader; import java.net.URISyntaxException; -import java.io.IOException; import org.rascalmpl.debug.IRascalMonitor; import org.rascalmpl.ideservices.BasicIDEServices; import org.rascalmpl.ideservices.IDEServices; import org.rascalmpl.interpreter.load.RascalSearchPath; -import org.rascalmpl.interpreter.load.SourceLocationListContributor; import org.rascalmpl.interpreter.utils.RascalManifest; import org.rascalmpl.library.util.PathConfig; import org.rascalmpl.runtime.traverse.Traverse; @@ -46,6 +44,7 @@ import org.rascalmpl.uri.project.ProjectURIResolver; import org.rascalmpl.uri.project.TargetURIResolver; import org.rascalmpl.values.IRascalValueFactory; + import io.usethesource.vallang.ISourceLocation; import io.usethesource.vallang.type.TypeFactory; import io.usethesource.vallang.type.TypeStore; @@ -165,40 +164,33 @@ public RascalExecutionContext( @Override public int jobEnd(String name, boolean succeeded) { - errwriter.println(name + " ends"); - return 0; - //return ideServices.jobEnd(name, succeeded); + return ideServices.jobEnd(name, succeeded); } @Override public void jobStep(String name, String message, int worked) { - //errstream.println(name + ": " + message); - //ideServices.jobStep(name, message, worked); + ideServices.jobStep(name, message, worked); } @Override public void jobStart(String name, int workShare, int totalWork) { - errwriter.println(name + " starts"); - //ideServices.jobStart(name, workShare, totalWork); + ideServices.jobStart(name, workShare, totalWork); } @Override public void jobTodo(String name, int work) { - //ideServices.jobTodo(name, work); + ideServices.jobTodo(name, work); } @Override public boolean jobIsCanceled(String name) { - errwriter.println(name + " canceled"); - return true; - //return ideServices.jobIsCanceled(name); + return ideServices.jobIsCanceled(name); } @Override public void warning(String message, ISourceLocation src) { - errwriter.println(message); - //ideServices.warning(message, src);; + ideServices.warning(message, src);; } public static ISourceLocation inferProjectRoot(Class clazz) { From 9245d3fb2287ed364db78ebe767063bd71737711 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 11 Nov 2026 09:59:51 +0100 Subject: [PATCH 08/41] Enabled registration of the project/target resolvers for the current project --- .../runtime/RascalExecutionContext.java | 36 +++---------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/src/org/rascalmpl/runtime/RascalExecutionContext.java b/src/org/rascalmpl/runtime/RascalExecutionContext.java index 5f9a8f47055..f48ab79e950 100644 --- a/src/org/rascalmpl/runtime/RascalExecutionContext.java +++ b/src/org/rascalmpl/runtime/RascalExecutionContext.java @@ -41,6 +41,8 @@ import org.rascalmpl.types.RascalTypeFactory; import org.rascalmpl.uri.URIResolverRegistry; import org.rascalmpl.uri.URIUtil; +import org.rascalmpl.uri.project.IDEProjectURIResolver; +import org.rascalmpl.uri.project.IDETargetURIResolver; import org.rascalmpl.uri.project.ProjectURIResolver; import org.rascalmpl.uri.project.TargetURIResolver; import org.rascalmpl.values.IRascalValueFactory; @@ -92,38 +94,8 @@ public RascalExecutionContext( rascalSearchPath = new RascalSearchPath(); URIResolverRegistry reg = URIResolverRegistry.getInstance(); - String projectName = new RascalManifest().getProjectName(projectRoot); - if(!projectName.isEmpty()) { - reg.registerLogical(new ProjectURIResolver(projectRoot, projectName)); - reg.registerLogical(new TargetURIResolver(projectRoot, projectName)); - } - - // String projectPath = projectRoot.getPath(); - // String projectsDirPath = projectPath.substring(0, projectPath.length() - projectName.length()-1); - - // try { - // ISourceLocation projectsDir = $RVF.sourceLocation(projectRoot.getScheme(), projectRoot.getAuthority(),projectsDirPath); - // String[]entries = URIResolverRegistry.getInstance().listEntries(projectsDir); - // if (entries != null) { - // //System.err.print("INFO adding projects: "); - // for(String entryName : entries) { - // if(entryName.charAt(0) != '.' && !(entryName.equals("pom-parent") || entryName.equals("bin") || entryName.equals("src") || entryName.equals("META-INF"))) { - // ISourceLocation entryRoot = $RVF.sourceLocation(projectsDir.getScheme(), projectsDir.getAuthority(), projectsDir.getPath() + "/" + entryName); - // if(URIResolverRegistry.getInstance().isDirectory(entryRoot)) { - // reg.registerLogical(new ProjectURIResolver(entryRoot, entryName)); - // reg.registerLogical(new TargetURIResolver(entryRoot, entryName)); - // rascalSearchPath.addPathContributor(new SourceLocationListContributor(entryName, $RVF.list(entryRoot))); - // //System.err.print(entryName + " "); - // } - // } - // } - // //System.err.println(""); - // } - // } catch (IOException e) { - // return; - // } catch (URISyntaxException e) { - // return; - // } + reg.registerLogical(new IDEProjectURIResolver(ideServices::resolveProjectLocation)); + reg.registerLogical(new IDETargetURIResolver(ideServices::resolveProjectLocation)); } IRascalValueFactory getRascalRuntimeValueFactory() { return $RVF; } From e209d73765f4413457c4e82be6d7b9bcd1b85181 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 11 Nov 2026 10:01:20 +0100 Subject: [PATCH 09/41] Using new generated parser generator --- generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated b/generated index 504e642e5e4..76fdea6e206 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit 504e642e5e4c4669b23d84e172053c9e9a9393e1 +Subproject commit 76fdea6e2067f5213b6b1571eb99a9d73bc82691 From a4a1f4b491aa84a2088ff2785a886e8503163162 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 11 Nov 2026 10:26:46 +0100 Subject: [PATCH 10/41] Removed unused constructor argument --- src/org/rascalmpl/parser/ParserGenerator.java | 2 +- src/org/rascalmpl/runtime/RascalExecutionContext.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/org/rascalmpl/parser/ParserGenerator.java b/src/org/rascalmpl/parser/ParserGenerator.java index 9d39075f27c..f4940c469fb 100644 --- a/src/org/rascalmpl/parser/ParserGenerator.java +++ b/src/org/rascalmpl/parser/ParserGenerator.java @@ -70,7 +70,7 @@ public class ParserGenerator { private final $Symbols symbols; public ParserGenerator(IRascalMonitor monitor, PrintWriter out, IValueFactory factory, Configuration config) { - var rex = new RascalExecutionContext(Reader.nullReader(), out, out, null, monitor instanceof IDEServices ? (IDEServices) monitor : null, $ParserGenerator.class); + var rex = new RascalExecutionContext(Reader.nullReader(), out, out, null, monitor instanceof IDEServices ? (IDEServices) monitor : null); var ms = rex.getModuleStore(); parserGenerator = new $ParserGenerator(rex); concreteSyntax = ms.getModule($ConcreteSyntax.class); diff --git a/src/org/rascalmpl/runtime/RascalExecutionContext.java b/src/org/rascalmpl/runtime/RascalExecutionContext.java index f48ab79e950..506ac094460 100644 --- a/src/org/rascalmpl/runtime/RascalExecutionContext.java +++ b/src/org/rascalmpl/runtime/RascalExecutionContext.java @@ -72,8 +72,7 @@ public RascalExecutionContext( PrintWriter outwriter, PrintWriter errwriter, PathConfig pcfg, - IDEServices ideServices, - Class clazz + IDEServices ideServices ){ currentModuleName = "UNDEFINED"; From 9fcca3abd36e3460933226819ecca3a77a73a8f9 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 11 Nov 2026 10:51:46 +0100 Subject: [PATCH 11/41] Updated workflow to check out submodules --- .github/workflows/build.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ec8897de12d..2c3f3f80576 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,6 +20,8 @@ jobs: runs-on: ubicloud-standard-4 steps: - uses: actions/checkout@v5 + with: + submodules: true - uses: actions/setup-java@v5 id: java @@ -155,6 +157,8 @@ jobs: MAVEN_OPTS: "-Xmx512M -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" steps: - uses: actions/checkout@v5 + with: + submodules: true - uses: actions/setup-java@v5 with: From d4e73984873de9be20ca9b93c667256f51c9d27c Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 11 Nov 2026 11:09:35 +0100 Subject: [PATCH 12/41] Using fully qualified name --- src/org/rascalmpl/runtime/RascalExecutionContext.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/runtime/RascalExecutionContext.java b/src/org/rascalmpl/runtime/RascalExecutionContext.java index 506ac094460..c4b3c0d9dcf 100644 --- a/src/org/rascalmpl/runtime/RascalExecutionContext.java +++ b/src/org/rascalmpl/runtime/RascalExecutionContext.java @@ -93,8 +93,8 @@ public RascalExecutionContext( rascalSearchPath = new RascalSearchPath(); URIResolverRegistry reg = URIResolverRegistry.getInstance(); - reg.registerLogical(new IDEProjectURIResolver(ideServices::resolveProjectLocation)); - reg.registerLogical(new IDETargetURIResolver(ideServices::resolveProjectLocation)); + reg.registerLogical(new IDEProjectURIResolver(this.ideServices::resolveProjectLocation)); + reg.registerLogical(new IDETargetURIResolver(this.ideServices::resolveProjectLocation)); } IRascalValueFactory getRascalRuntimeValueFactory() { return $RVF; } From 642f62138108d6e2a0aa6917c743e4cf0b6f44b6 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 11 Nov 2026 11:33:17 +0100 Subject: [PATCH 13/41] Fixed stack overflow during tests --- src/org/rascalmpl/runtime/RascalExecutionContext.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/org/rascalmpl/runtime/RascalExecutionContext.java b/src/org/rascalmpl/runtime/RascalExecutionContext.java index c4b3c0d9dcf..5c3ec36e65b 100644 --- a/src/org/rascalmpl/runtime/RascalExecutionContext.java +++ b/src/org/rascalmpl/runtime/RascalExecutionContext.java @@ -32,6 +32,7 @@ import java.net.URISyntaxException; import org.rascalmpl.debug.IRascalMonitor; +import org.rascalmpl.debug.NullRascalMonitor; import org.rascalmpl.ideservices.BasicIDEServices; import org.rascalmpl.ideservices.IDEServices; import org.rascalmpl.interpreter.load.RascalSearchPath; @@ -83,7 +84,7 @@ public RascalExecutionContext( this.pcfg = pcfg == null ? new PathConfig() : pcfg; ISourceLocation projectRoot = URIUtil.rootLocation("cwd"); - this.ideServices = ideServices == null ? new BasicIDEServices(errwriter, this, null, projectRoot) : ideServices; + this.ideServices = ideServices == null ? new BasicIDEServices(errwriter, new NullRascalMonitor(), null, projectRoot) : ideServices; $RVF = new RascalRuntimeValueFactory(this); $TF = TypeFactory.getInstance(); $RTF = RascalTypeFactory.getInstance(); From fc082531c56986f8d769278e7ab221f9687292a5 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 11 Nov 2026 11:53:44 +0100 Subject: [PATCH 14/41] Updated workflow to check out submodules once more --- .github/workflows/build.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2c3f3f80576..4ae9ae9b6b3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -191,6 +191,8 @@ jobs: MAVEN_OPTS: "-Xmx512M -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" steps: - uses: actions/checkout@v5 + with: + submodules: true - uses: actions/setup-java@v5 with: From d6454074fa2a040fea220dd084c18404d01e4e03 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 11 Nov 2026 11:54:54 +0100 Subject: [PATCH 15/41] Updated workflow to check out submodules once more --- .github/workflows/build.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4ae9ae9b6b3..bd96fe9c579 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -70,6 +70,8 @@ jobs: - run: which chromedriver - uses: actions/checkout@v5 + with: + submodules: true - uses: actions/setup-java@v5 with: From aedf7a325acf1d2d8b989a1ac1d0b8606316a087 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Mon, 16 Nov 2026 16:44:09 +0100 Subject: [PATCH 16/41] Removed local path from the parser generator compilation module and added a Java wrapper --- .../compiler/CompileParserGenerator.rsc | 24 +++++++++---------- src/org/rascalmpl/shell/RascalCompile.java | 1 - .../shell/RascalGenerateSources.java | 19 +++++++++++++++ 3 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 src/org/rascalmpl/shell/RascalGenerateSources.java diff --git a/src/org/rascalmpl/compiler/CompileParserGenerator.rsc b/src/org/rascalmpl/compiler/CompileParserGenerator.rsc index d653f40af78..adbda11b347 100644 --- a/src/org/rascalmpl/compiler/CompileParserGenerator.rsc +++ b/src/org/rascalmpl/compiler/CompileParserGenerator.rsc @@ -30,21 +30,21 @@ import IO; import lang::rascalcore::compile::Compile; @synopsis{Compile the parser generator including all needed library modules} -void main(loc REPO = |file:///Users/paulklint/git/|, - loc COMPILED = REPO + "compiled-rascal"){ +void main(loc rascalRepo = |project://rascal|, + loc generatedDir = rascalRepo + "generated"){ pcfg = pathConfig( - srcs = [ REPO + "rascal/src/org/rascalmpl/library", - REPO + "rascal/test/org/rascalmpl/benchmark/", - REPO + "rascal/src/org/rascalmpl/compiler", - REPO + "rascal/src/org/rascalmpl/tutor"], - bin = COMPILED + "/target/classes", - generatedSources = COMPILED + "/src/main/java", - generatedTestSources = COMPILED + "/src/test/java/", - generatedResources = COMPILED + "/src/main/java", - generatedTestResources = COMPILED + "/src/test/java/", + srcs = [ rascalRepo + "src/org/rascalmpl/library", + rascalRepo + "test/org/rascalmpl/benchmark/", + rascalRepo + "src/org/rascalmpl/compiler", + rascalRepo + "src/org/rascalmpl/tutor"], + bin = generatedDir + "/target/classes", + generatedSources = generatedDir + "/src/main/java", + generatedTestSources = generatedDir + "/src/test/java/", + generatedResources = generatedDir + "/src/main/java", + generatedTestResources = generatedDir + "/src/test/java/", libs = [ ] - ); + ); ccfg = rascalCompilerConfig(pcfg)[verbose = true][logWrittenFiles=true]; msgs = compile(["lang::rascal::grammar::ParserGenerator"], ccfg); diff --git a/src/org/rascalmpl/shell/RascalCompile.java b/src/org/rascalmpl/shell/RascalCompile.java index e99b42cab2e..45a45259468 100644 --- a/src/org/rascalmpl/shell/RascalCompile.java +++ b/src/org/rascalmpl/shell/RascalCompile.java @@ -20,7 +20,6 @@ import org.rascalmpl.uri.URIUtil; import org.rascalmpl.values.IRascalValueFactory; -import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.IList; import io.usethesource.vallang.ISourceLocation; import io.usethesource.vallang.IValue; diff --git a/src/org/rascalmpl/shell/RascalGenerateSources.java b/src/org/rascalmpl/shell/RascalGenerateSources.java new file mode 100644 index 00000000000..3a9283f346f --- /dev/null +++ b/src/org/rascalmpl/shell/RascalGenerateSources.java @@ -0,0 +1,19 @@ +package org.rascalmpl.shell; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.Writer; + +import org.rascalmpl.debug.IRascalMonitor; +import org.rascalmpl.repl.streams.StreamUtil; + +public class RascalGenerateSources extends AbstractCommandlineTool { + public static void main(String[] args) throws IOException { + var term = RascalShell.connectToTerminal(); + var monitor = IRascalMonitor.buildConsoleMonitor(term); + var err = (monitor instanceof Writer) ? StreamUtil.generateErrorStream(term, (Writer)monitor) : new PrintWriter(System.err, true); + var out = (monitor instanceof PrintWriter) ? (PrintWriter) monitor : new PrintWriter(System.out, false); + + System.exit(main("CompileParserGenerator", new String[] { "org/rascalmpl/compiler", "org/rascalmpl/typepal" }, args, term, monitor, err, out)); + } +} From dbd2c8b18afa12a8f749614d0a53b6bb5214baf9 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Mon, 16 Nov 2026 16:44:54 +0100 Subject: [PATCH 17/41] Added license to code generation --- .../compiler/CompileParserGenerator.rsc | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/org/rascalmpl/compiler/CompileParserGenerator.rsc b/src/org/rascalmpl/compiler/CompileParserGenerator.rsc index adbda11b347..9cd59f9a50c 100644 --- a/src/org/rascalmpl/compiler/CompileParserGenerator.rsc +++ b/src/org/rascalmpl/compiler/CompileParserGenerator.rsc @@ -31,7 +31,8 @@ import lang::rascalcore::compile::Compile; @synopsis{Compile the parser generator including all needed library modules} void main(loc rascalRepo = |project://rascal|, - loc generatedDir = rascalRepo + "generated"){ + loc generatedDir = rascalRepo + "generated", + loc license = |memory:///LICENSE|){ pcfg = pathConfig( srcs = [ rascalRepo + "src/org/rascalmpl/library", @@ -46,11 +47,45 @@ void main(loc rascalRepo = |project://rascal|, libs = [ ] ); - ccfg = rascalCompilerConfig(pcfg)[verbose = true][logWrittenFiles=true]; + if (!license?) { + saveDefaultLicense(); + } + + ccfg = rascalCompilerConfig(pcfg)[verbose = true][logWrittenFiles=true][license=license]; msgs = compile(["lang::rascal::grammar::ParserGenerator"], ccfg); if(isEmpty(msgs)){ println("ok"); } else { iprintln(msgs); } -} \ No newline at end of file +} + +private void saveDefaultLicense() { + writeFile(|memory:///LICENSE|, + "Copyright (c) 2018-2025, NWO-I CWI and Swat.engineering + 'All rights reserved. + ' + 'Redistribution and use in source and binary forms, with or without + 'modification, are permitted provided that the following conditions are met: + ' + '1. Redistributions of source code must retain the above copyright notice, + 'this list of conditions and the following disclaimer. + ' + '2. Redistributions in binary form must reproduce the above copyright notice, + 'this list of conditions and the following disclaimer in the documentation + 'and/or other materials provided with the distribution. + ' + 'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" + 'AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + 'IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + 'ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + 'LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + 'CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + 'SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + 'INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + 'CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + 'ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + 'POSSIBILITY OF SUCH DAMAGE. + '" + ); +} From 1056f3af57defce1329db479ab3e0a0c8ab3f653 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Mon, 16 Nov 2026 16:45:21 +0100 Subject: [PATCH 18/41] Updated lib:// location to project:// --- src/org/rascalmpl/compiler/CompileTestSources.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/rascalmpl/compiler/CompileTestSources.rsc b/src/org/rascalmpl/compiler/CompileTestSources.rsc index f9ce0e4b87a..5bd92aef95f 100644 --- a/src/org/rascalmpl/compiler/CompileTestSources.rsc +++ b/src/org/rascalmpl/compiler/CompileTestSources.rsc @@ -54,7 +54,7 @@ void compileTestSources(PathConfig pcfg) { testCompilerConfig = getAllSrcCompilerConfig()[logPathConfig=false]; total = 0; - println(readFile(|lib://rascal/META-INF/MANIFEST.MF|)); + println(readFile(|project://rascal/META-INF/MANIFEST.MF|)); libraryModules = ["Boolean", "DateTime", From bf51142b858d92eaf56f7e63c6e050a3e423c58b Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Mon, 16 Nov 2026 16:45:40 +0100 Subject: [PATCH 19/41] Updated submodule --- generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated b/generated index 76fdea6e206..699da5a7877 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit 76fdea6e2067f5213b6b1571eb99a9d73bc82691 +Subproject commit 699da5a78775feb503febf6ff561eac9c37de336 From 5d92fccb6a21d0c65e97973155a61feace71602c Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Mon, 16 Nov 2026 16:50:15 +0100 Subject: [PATCH 20/41] No longer calling getValue() on the same IStrings twice in succession --- src/org/rascalmpl/parser/ParserGenerator.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/org/rascalmpl/parser/ParserGenerator.java b/src/org/rascalmpl/parser/ParserGenerator.java index f4940c469fb..e9c631c5544 100644 --- a/src/org/rascalmpl/parser/ParserGenerator.java +++ b/src/org/rascalmpl/parser/ParserGenerator.java @@ -184,10 +184,10 @@ public Class> getNewParser(IRascalMon try { String normName = name.replaceAll("::", "_").replaceAll("\\\\", "_"); - IString classString = parserGenerator.newGenerate(vf.string(packageName), vf.string(normName), grammar); - debugOutput("java code", classString.getValue(), System.getProperty("java.io.tmpdir") + "/parser.java"); + var classString = parserGenerator.newGenerate(vf.string(packageName), vf.string(normName), grammar).getValue(); + debugOutput("java code", classString, System.getProperty("java.io.tmpdir") + "/parser.java"); - return bridge.compileJava(loc, packageName + "." + normName, classString.getValue()); + return bridge.compileJava(loc, packageName + "." + normName, classString); } catch (ClassCastException e) { throw new ImplementationError("parser generator:" + e.getMessage(), e); } catch (Throw e) { @@ -210,10 +210,10 @@ public void writeNewParser(IRascalMonitor monitor, ISourceLocation loc, String n String normName = name.replaceAll("::", "_").replaceAll("\\\\", "_"); IConstructor grammar = IRascalValueFactory.getInstance().grammar(definition); - IString classString = parserGenerator.newGenerate(vf.string(packageName), vf.string(normName), grammar); - debugOutput("java code", classString.getValue(), System.getProperty("java.io.tmpdir") + "/parser.java"); + var classString = parserGenerator.newGenerate(vf.string(packageName), vf.string(normName), grammar).getValue(); + debugOutput("java code", classString, System.getProperty("java.io.tmpdir") + "/parser.java"); - bridge.compileJava(loc, packageName + "." + normName, classString.getValue(), out); + bridge.compileJava(loc, packageName + "." + normName, classString, out); } catch (ClassCastException e) { throw new ImplementationError("parser generator:" + e.getMessage(), e); } catch (Throw e) { From ecfde2a7eb0394fa176ab2cee936c67c7664448a Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Mon, 16 Nov 2026 16:53:08 +0100 Subject: [PATCH 21/41] Added comment to newly added maven plugin --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 15d1775fc25..74514aa4095 100644 --- a/pom.xml +++ b/pom.xml @@ -410,7 +410,7 @@ - + org.codehaus.mojo build-helper-maven-plugin 3.6.2 From 2518d64cc6070f6d5323cc834dd7665134364a7e Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 17 Nov 2026 10:38:41 +0100 Subject: [PATCH 22/41] Avoiding exceptions during code generation --- .../compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc index a8f6f6918e4..aa8893423e4 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc @@ -64,6 +64,7 @@ rel[Name_Arity, Define] getFunctionsAndConstructors(TModel tmodel, set[MODID] mo (ov.idRole == functionId() || ov.idRole == constructorId()) } | loc u <- tmodel.facts, + isModuleId(u), moduleId2moduleName(u) == mname/*jg.isContainedIn(u, mscope)*/, /ovl:overloadedAType(rel[loc def, IdRole idRole, AType atype] overloads) := tmodel.facts[u] }; From c71eef169f95da722fd5550bd398245bf8500c51 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 17 Nov 2026 10:39:55 +0100 Subject: [PATCH 23/41] Bumped compiled parser generator --- generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated b/generated index 699da5a7877..669f99f169d 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit 699da5a78775feb503febf6ff561eac9c37de336 +Subproject commit 669f99f169d61b5ca10fda7dc7f0bb51fb3f5ebe From ea53f61ed3262cc352e8dcb92b2cf9fd30f4e000 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 17 Nov 2026 11:13:47 +0100 Subject: [PATCH 24/41] Revert "Avoiding exceptions during code generation" This reverts commit 2518d64cc6070f6d5323cc834dd7665134364a7e. --- .../compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc index aa8893423e4..a8f6f6918e4 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc @@ -64,7 +64,6 @@ rel[Name_Arity, Define] getFunctionsAndConstructors(TModel tmodel, set[MODID] mo (ov.idRole == functionId() || ov.idRole == constructorId()) } | loc u <- tmodel.facts, - isModuleId(u), moduleId2moduleName(u) == mname/*jg.isContainedIn(u, mscope)*/, /ovl:overloadedAType(rel[loc def, IdRole idRole, AType atype] overloads) := tmodel.facts[u] }; From 5ca1a702e39d0cffb3935304aaa1c00948867164 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 17 Nov 2026 11:23:17 +0100 Subject: [PATCH 25/41] Reverted to previous version of generated parser generator --- generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated b/generated index 669f99f169d..699da5a7877 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit 669f99f169d61b5ca10fda7dc7f0bb51fb3f5ebe +Subproject commit 699da5a78775feb503febf6ff561eac9c37de336 From d7b89de2b58877d6562f908a4870e59a25313d33 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 17 Nov 2026 12:47:51 +0100 Subject: [PATCH 26/41] Bumped submodule pointer. Submodule now has a DEVELOPERS.md --- generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated b/generated index 699da5a7877..9bedb90bcbd 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit 699da5a78775feb503febf6ff561eac9c37de336 +Subproject commit 9bedb90bcbd01e81caf33c8f32bff686d02fa9dc From f85b4fc1df791b02047a7d760f33b2d8b796a4c1 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 17 Nov 2026 12:48:03 +0100 Subject: [PATCH 27/41] Added DEVELOPERS.md --- DEVELOPERS.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 DEVELOPERS.md diff --git a/DEVELOPERS.md b/DEVELOPERS.md new file mode 100644 index 00000000000..8b13c2459d5 --- /dev/null +++ b/DEVELOPERS.md @@ -0,0 +1,15 @@ +# Rascal Developer Manual + +## Checking out the repository + +The Rascal project makes use of Java code that is generated from Rascal modules. +To avoid pollution of the Rascal repository itself, the generated code is not committed to this repository, but to a [separate repository](https://github.com/usethesource/rascal-generated-java). +This secondary repository is "linked in" using Git's submodule system, in the `generated` directory in the root of the repository. + +To start working on Rascal, execute the following steps. +1. Check out the Rascal repository (e.g., `git clone git@github.com:usethesource/rascal.git`). +2. Initialize the submodule (`git submodule update --init`). The `generated` directory should now be filled. + +## Updating the submodule + +After an update of the submodule's commit pointer, `git pull` will (by default) not update the submodule directory. To update the submodule, run `git submodule update`. From 4165ee834cf7182eca7fd6b04d294b0b913d8cdf Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 17 Nov 2026 13:16:28 +0100 Subject: [PATCH 28/41] Bumped submodule after a typo fix --- generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated b/generated index 9bedb90bcbd..f803d046c55 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit 9bedb90bcbd01e81caf33c8f32bff686d02fa9dc +Subproject commit f803d046c5500cab4348ee53891468610cb56b24 From ee9bbc91dc91aa17d912884cfcfd8d6499b38ee3 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 17 Nov 2026 13:19:12 +0100 Subject: [PATCH 29/41] Small tweaks to DEVELOPERS.md --- DEVELOPERS.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DEVELOPERS.md b/DEVELOPERS.md index 8b13c2459d5..0de0d677f2e 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -12,4 +12,6 @@ To start working on Rascal, execute the following steps. ## Updating the submodule -After an update of the submodule's commit pointer, `git pull` will (by default) not update the submodule directory. To update the submodule, run `git submodule update`. +After an update of the submodule's commit pointer, `git pull` will (by default) not update the submodule directory. +The output of `git diff` will contain an entry indicating `"new commits"` in `generated`. +To update the directory, navigate to `generated` and run `git pull` from there. From 409c733acd5d2011129bb95b59d9a13b00af3d52 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Wed, 18 Nov 2026 11:29:02 +0100 Subject: [PATCH 30/41] Bumped compiled parser generator --- generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated b/generated index f803d046c55..cc685e3cae0 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit f803d046c5500cab4348ee53891468610cb56b24 +Subproject commit cc685e3cae0cb9074d40bd7951265bd4db4b7e35 From c09fa9421b41913af1545b1f0a3a252c02d26376 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 24 Nov 2026 11:13:05 +0100 Subject: [PATCH 31/41] Bumped compiled parser generator --- generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated b/generated index cc685e3cae0..b03d354c635 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit cc685e3cae0cb9074d40bd7951265bd4db4b7e35 +Subproject commit b03d354c635c23db78655201d76333ebbb7b0979 From 3c707ba4825e70d7c9ca948049f9d6c549cb4a17 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 24 Nov 2026 11:14:26 +0100 Subject: [PATCH 32/41] Added explicit type to local variable --- .../library/lang/rascal/grammar/definition/Parameters.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/rascalmpl/library/lang/rascal/grammar/definition/Parameters.rsc b/src/org/rascalmpl/library/lang/rascal/grammar/definition/Parameters.rsc index 2caf299c18f..5db891c02d9 100644 --- a/src/org/rascalmpl/library/lang/rascal/grammar/definition/Parameters.rsc +++ b/src/org/rascalmpl/library/lang/rascal/grammar/definition/Parameters.rsc @@ -37,7 +37,7 @@ set[Production] expand(set[Production] prods) { instantiated = {}; while (uses != {}) { - instances = {}; + set[Production] instances = {}; for (u <- uses, def <- defs, def.def.name == u.name) { name = u.name; actuals = u.parameters; From b7d8ba0bbc694c17cb03da19e821bd4ab2203e6d Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 24 Nov 2026 11:17:16 +0100 Subject: [PATCH 33/41] Reusing stream from RascalExecutionContext --- src/org/rascalmpl/parser/ParserGenerator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/parser/ParserGenerator.java b/src/org/rascalmpl/parser/ParserGenerator.java index e9c631c5544..42aad2b8170 100644 --- a/src/org/rascalmpl/parser/ParserGenerator.java +++ b/src/org/rascalmpl/parser/ParserGenerator.java @@ -69,8 +69,10 @@ public class ParserGenerator { private final $Parameters parameters; private final $Symbols symbols; + private final RascalExecutionContext rex; + public ParserGenerator(IRascalMonitor monitor, PrintWriter out, IValueFactory factory, Configuration config) { - var rex = new RascalExecutionContext(Reader.nullReader(), out, out, null, monitor instanceof IDEServices ? (IDEServices) monitor : null); + rex = new RascalExecutionContext(Reader.nullReader(), out, out, null, monitor instanceof IDEServices ? (IDEServices) monitor : null); var ms = rex.getModuleStore(); parserGenerator = new $ParserGenerator(rex); concreteSyntax = ms.getModule($ConcreteSyntax.class); @@ -90,7 +92,7 @@ private void debugOutput(String kind, Object thing, String file) { String classString = thing.toString(); FileOutputStream s = null; try { - System.err.println("\nWriting " + kind + " to " + file); + rex.getErrWriter().println("\nWriting " + kind + " to " + file); s = new FileOutputStream(file); s.write(classString.getBytes()); From b28eb83ac29a876d24f72e28e24eb505c202a98b Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 24 Nov 2026 11:26:35 +0100 Subject: [PATCH 34/41] Updated DEVELOPERS.md after @DavyLandman feedback --- DEVELOPERS.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/DEVELOPERS.md b/DEVELOPERS.md index 0de0d677f2e..bfdb409d374 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -1,17 +1,14 @@ # Rascal Developer Manual -## Checking out the repository +## Working with the repository The Rascal project makes use of Java code that is generated from Rascal modules. To avoid pollution of the Rascal repository itself, the generated code is not committed to this repository, but to a [separate repository](https://github.com/usethesource/rascal-generated-java). This secondary repository is "linked in" using Git's submodule system, in the `generated` directory in the root of the repository. -To start working on Rascal, execute the following steps. -1. Check out the Rascal repository (e.g., `git clone git@github.com:usethesource/rascal.git`). -2. Initialize the submodule (`git submodule update --init`). The `generated` directory should now be filled. +To start working on Rascal, check out the Rascal repository (`git clone --recurse-submodules git@github.com:usethesource/rascal.git`). +Note: for existing (local) repositories, initialize the submodule through `git submodule update --init`. -## Updating the submodule - -After an update of the submodule's commit pointer, `git pull` will (by default) not update the submodule directory. -The output of `git diff` will contain an entry indicating `"new commits"` in `generated`. -To update the directory, navigate to `generated` and run `git pull` from there. +By default, `git` operations (such as `git pull`) will reel in changes to submodules, but will not actually alter the content of submodule directories. +To bring the contents up to date, run `git submodule update` after a pull, or add the `--recurse-submodules` to `git pull`. +To automate this, set the configuration option `submodule.recurse` to `true` for the Rascal project. From 1f7894801a10e065e369ea69ad023a0dc8ee93bb Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 24 Nov 2026 11:33:05 +0100 Subject: [PATCH 35/41] Added pointer to other repository in DEVELOPERS.md --- DEVELOPERS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DEVELOPERS.md b/DEVELOPERS.md index bfdb409d374..1e5cb7ff7e1 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -12,3 +12,7 @@ Note: for existing (local) repositories, initialize the submodule through `git s By default, `git` operations (such as `git pull`) will reel in changes to submodules, but will not actually alter the content of submodule directories. To bring the contents up to date, run `git submodule update` after a pull, or add the `--recurse-submodules` to `git pull`. To automate this, set the configuration option `submodule.recurse` to `true` for the Rascal project. + +## Updating the submodule + +Instructions for updating the submodule contents can be found in the `DEVELOPERS.md` in the `rascal-generated-java` project. From 14e02f27ed57905915c1bc227bfe2db527bd6f94 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 24 Nov 2026 11:37:00 +0100 Subject: [PATCH 36/41] Made generate sources entry module more generic --- .../compiler/RascalGenerateSources.rsc | 34 +++++++++++++++++++ .../shell/RascalGenerateSources.java | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/org/rascalmpl/compiler/RascalGenerateSources.rsc diff --git a/src/org/rascalmpl/compiler/RascalGenerateSources.rsc b/src/org/rascalmpl/compiler/RascalGenerateSources.rsc new file mode 100644 index 00000000000..8c095959a15 --- /dev/null +++ b/src/org/rascalmpl/compiler/RascalGenerateSources.rsc @@ -0,0 +1,34 @@ +@license{ +Copyright (c) 2018-2025, NWO-I CWI, Swat.engineering and Paul Klint +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +} +module RascalGenerateSources + +import CompileParserGenerator; + +@synopsis{Entry point for code generation} +void main() { + CompileParserGenerator::main(); +} \ No newline at end of file diff --git a/src/org/rascalmpl/shell/RascalGenerateSources.java b/src/org/rascalmpl/shell/RascalGenerateSources.java index 3a9283f346f..cab4025a886 100644 --- a/src/org/rascalmpl/shell/RascalGenerateSources.java +++ b/src/org/rascalmpl/shell/RascalGenerateSources.java @@ -14,6 +14,6 @@ public static void main(String[] args) throws IOException { var err = (monitor instanceof Writer) ? StreamUtil.generateErrorStream(term, (Writer)monitor) : new PrintWriter(System.err, true); var out = (monitor instanceof PrintWriter) ? (PrintWriter) monitor : new PrintWriter(System.out, false); - System.exit(main("CompileParserGenerator", new String[] { "org/rascalmpl/compiler", "org/rascalmpl/typepal" }, args, term, monitor, err, out)); + System.exit(main("RascalGenerateSources", new String[] { "org/rascalmpl/compiler", "org/rascalmpl/typepal" }, args, term, monitor, err, out)); } } From 4c6930e50af9ef7bc0fe6978a7f79b5ba244c444 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 24 Nov 2026 11:57:53 +0100 Subject: [PATCH 37/41] Bumped compiled submodule. tpls have been removed from there --- generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated b/generated index b03d354c635..842cb8c4fb0 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit b03d354c635c23db78655201d76333ebbb7b0979 +Subproject commit 842cb8c4fb0db8d2f0f6a0bbd41040a5c0a4aa16 From 149e79a8965c6af88e110b63e549a857c944cc10 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 24 Nov 2026 12:12:38 +0100 Subject: [PATCH 38/41] Fixed the main function for code generation --- .../compiler/CompileParserGenerator.rsc | 34 --------------- .../compiler/RascalGenerateSources.rsc | 42 +++++++++++++++++-- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/org/rascalmpl/compiler/CompileParserGenerator.rsc b/src/org/rascalmpl/compiler/CompileParserGenerator.rsc index 9cd59f9a50c..f424fd2db02 100644 --- a/src/org/rascalmpl/compiler/CompileParserGenerator.rsc +++ b/src/org/rascalmpl/compiler/CompileParserGenerator.rsc @@ -47,10 +47,6 @@ void main(loc rascalRepo = |project://rascal|, libs = [ ] ); - if (!license?) { - saveDefaultLicense(); - } - ccfg = rascalCompilerConfig(pcfg)[verbose = true][logWrittenFiles=true][license=license]; msgs = compile(["lang::rascal::grammar::ParserGenerator"], ccfg); if(isEmpty(msgs)){ @@ -59,33 +55,3 @@ void main(loc rascalRepo = |project://rascal|, iprintln(msgs); } } - -private void saveDefaultLicense() { - writeFile(|memory:///LICENSE|, - "Copyright (c) 2018-2025, NWO-I CWI and Swat.engineering - 'All rights reserved. - ' - 'Redistribution and use in source and binary forms, with or without - 'modification, are permitted provided that the following conditions are met: - ' - '1. Redistributions of source code must retain the above copyright notice, - 'this list of conditions and the following disclaimer. - ' - '2. Redistributions in binary form must reproduce the above copyright notice, - 'this list of conditions and the following disclaimer in the documentation - 'and/or other materials provided with the distribution. - ' - 'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" - 'AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - 'IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - 'ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - 'LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - 'CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - 'SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - 'INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - 'CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - 'ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - 'POSSIBILITY OF SUCH DAMAGE. - '" - ); -} diff --git a/src/org/rascalmpl/compiler/RascalGenerateSources.rsc b/src/org/rascalmpl/compiler/RascalGenerateSources.rsc index 8c095959a15..0ff982cadd0 100644 --- a/src/org/rascalmpl/compiler/RascalGenerateSources.rsc +++ b/src/org/rascalmpl/compiler/RascalGenerateSources.rsc @@ -26,9 +26,45 @@ POSSIBILITY OF SUCH DAMAGE. } module RascalGenerateSources +import IO; + import CompileParserGenerator; @synopsis{Entry point for code generation} -void main() { - CompileParserGenerator::main(); -} \ No newline at end of file +void main(loc rascalRepo = |project://rascal|, loc generatedDir = rascalRepo + "generated", loc license = |memory:///LICENSE|) { + if (!license?) { + saveDefaultLicense(); + } + + CompileParserGenerator::main(rascalRepo=rascalRepo, generatedDir=generatedDir, license=license); +} + +private void saveDefaultLicense() { + writeFile(|memory:///LICENSE|, + "Copyright (c) 2018-2025, NWO-I CWI and Swat.engineering + 'All rights reserved. + ' + 'Redistribution and use in source and binary forms, with or without + 'modification, are permitted provided that the following conditions are met: + ' + '1. Redistributions of source code must retain the above copyright notice, + 'this list of conditions and the following disclaimer. + ' + '2. Redistributions in binary form must reproduce the above copyright notice, + 'this list of conditions and the following disclaimer in the documentation + 'and/or other materials provided with the distribution. + ' + 'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" + 'AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + 'IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + 'ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + 'LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + 'CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + 'SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + 'INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + 'CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + 'ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + 'POSSIBILITY OF SUCH DAMAGE. + '" + ); +} From 4240e2f5719e7f4e86755970c480b1084b0c4583 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 24 Nov 2026 12:43:57 +0100 Subject: [PATCH 39/41] Bumped compiled parser generator --- generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated b/generated index 842cb8c4fb0..6a3831a1188 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit 842cb8c4fb0db8d2f0f6a0bbd41040a5c0a4aa16 +Subproject commit 6a3831a1188bd173d64739d6fa9201920c1b4c79 From 4c3dd7b7de1890f20fc04cad23d5eb13cd686e23 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Tue, 1 Dec 2026 09:36:38 +0100 Subject: [PATCH 40/41] Implemented ambiguous tree support similar to error tree support (cf. #2987) --- src/org/rascalmpl/runtime/$RascalModule.java | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/org/rascalmpl/runtime/$RascalModule.java b/src/org/rascalmpl/runtime/$RascalModule.java index 1a01d420d79..3eb3c0e1c48 100644 --- a/src/org/rascalmpl/runtime/$RascalModule.java +++ b/src/org/rascalmpl/runtime/$RascalModule.java @@ -55,6 +55,7 @@ import org.rascalmpl.interpreter.utils.IResourceLocationProvider; import org.rascalmpl.interpreter.utils.RascalManifest; import org.rascalmpl.library.util.PathConfig; +import org.rascalmpl.library.util.ParseErrorRecovery; import org.rascalmpl.library.util.ToplevelType; import org.rascalmpl.parser.gtd.result.out.INodeFlattener; import org.rascalmpl.runtime.traverse.Traverse; @@ -907,6 +908,10 @@ private IValueInputStream constructValueReader(ISourceLocation loc) throws IOExc protected final IValue $aadt_get_field(final IConstructor cons, final String fieldName) { Type consType = cons.getConstructorType(); + + if (consType == RascalValueFactory.Tree_Amb) { + throwOnAmbFieldAccess(cons, fieldName); + } if(TreeAdapter.isTree(cons) && TreeAdapter.isAppl((ITree) cons)) { FieldResult fldres = TreeAdapter.getLabeledField((ITree) cons, fieldName); @@ -941,6 +946,28 @@ private IValueInputStream constructValueReader(ISourceLocation loc) throws IOExc } } + private void throwOnAmbFieldAccess(final IConstructor cons, final String fieldName) { + ITree tree = (ITree) cons; + ISet alts = (ISet) tree.get(0); + for (IValue alt : alts) { + if (TreeAdapter.getLabeledField((ITree) alt, fieldName) != null) { + // If the ambiguity is generated by error recovery we throw an ParseErrorRecovery exception, + // otherwise we throw an Ambiguity exception + if ((new ParseErrorRecovery($RVF)).hasParseErrors(tree).getValue()) { + throw RuntimeExceptionFactory.parseErrorRecoveryNoSuchField(fieldName, TreeAdapter.getLocation(tree)); + } + else { + IString typeString = $RVF.string(SymbolAdapter.toString(tree, false)); + IString treeString = $RVF.string(TreeAdapter.yield(tree)); + ISourceLocation loc = TreeAdapter.getLocation(tree); + throw RuntimeExceptionFactory.ambiguity(loc, typeString, treeString); + } + } + } + + throw RuntimeExceptionFactory.noSuchField(fieldName); + } + protected final IValue $aloc_get_field(final ISourceLocation sloc, final String field) { IValue v; switch (field) { @@ -1776,6 +1803,10 @@ else if (iEndLine != -1 || iEndColumn != -1) { Type consType = cons.getConstructorType(); + if (consType == RascalValueFactory.Tree_Amb) { + throwOnAmbFieldAccess(cons, fieldName); + } + // Does fieldName exist as field in a parse tree? if(TreeAdapter.isTree(cons)) { if(TreeAdapter.isAppl((ITree) cons) && TreeAdapter.getLabeledField((ITree)cons, fieldName) != null) { From 6eae2d3446b9a2bf74e9bea936ec91e4479a0446 Mon Sep 17 00:00:00 2001 From: Rodin Aarssen Date: Fri, 4 Dec 2026 09:05:47 +0100 Subject: [PATCH 41/41] Removed function argument during generation --- .../compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc | 2 +- .../compiler/lang/rascalcore/compile/muRascal2Java/Tests.rsc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc index 7c0cbdbd024..9333dbd9b2e 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc @@ -214,7 +214,7 @@ tuple[JCode, JCode, JCode, list[value]] muRascal2Java(MuModule m, ModuleStatus m main_method = "public static void main(String[] args) { ' long start_time = System.currentTimeMillis(); - ' RascalExecutionContext rex = new RascalExecutionContext(new InputStreamReader(System.in), new PrintWriter(System.out), new PrintWriter(System.err), null, null, ..class); + ' RascalExecutionContext rex = new RascalExecutionContext(new InputStreamReader(System.in), new PrintWriter(System.out), new PrintWriter(System.err), null, null); ' instance = new (rex); ' long init_time = System.currentTimeMillis(); ' diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Tests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Tests.rsc index 93a6e7e6784..6e8b91d7e42 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Tests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Tests.rsc @@ -82,7 +82,7 @@ str generateTestClass(str preamble, str packageName, str className, list[MuFunct ' final GenerateActuals generator = new GenerateActuals(5, 5, 10); ' ' public Tests(){ - ' super(new RascalExecutionContext(new InputStreamReader(System.in), new PrintWriter(System.out), new PrintWriter(System.err), null, null, ..class)); + ' super(new RascalExecutionContext(new InputStreamReader(System.in), new PrintWriter(System.out), new PrintWriter(System.err), null, null)); ' ModuleStore store = $rex.getModuleStore(); ' store.importModule(.class, this.$rex, ::new); ' $me = store.getModule(.class);