Skip to content

syntax role modifiers - #1835

Open
jurgenvinju wants to merge 128 commits into
mainfrom
syntax-role-modifiers
Open

syntax role modifiers#1835
jurgenvinju wants to merge 128 commits into
mainfrom
syntax-role-modifiers

Conversation

@jurgenvinju

@jurgenvinju jurgenvinju commented Jul 7, 2023

Copy link
Copy Markdown
Member

This PR implements syntax role modifiers.

SyntaxModifiers.pdf

  • runtime types for modifiers with open and closed parameters, including subtype, lub and glb
  • subtype lub and glb for Symbol and AType
  • conversions for AST,Symbol and AType
  • JGenie code generator for open type modifiers
  • tests for using modifiers
  • Correct implementation of Explode: AST to separator syntax Tree conversion, using role modifiers
  • Tests for Explode
  • Fixes for deep match on separator syntax trees
  • Tests for deep match
  • Fixes for visit on separator syntax trees (not required since no bugs found)
  • Tests for visit
  • Fixes for match on separators syntax trees (impossible to discover see below)
  • Tests for match (impossible to write on this PR because external parsers are not called on concrete syntax yet)
  • Parameters that have a modifier as outermost type are translated properly to IConstructor or ITree

Note that syntax role modifiers do not introduce the fields of the modified type to the modifier type (yet). That is for another RAP/PR.

@codecov

codecov Bot commented Jul 7, 2023

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 34.00868% with 456 lines in your changes missing coverage. Please review.
✅ Project coverage is 45%. Comparing base (2acd8f2) to head (b678af8).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/org/rascalmpl/types/ModifySyntaxRole.java 25% 220 Missing and 34 partials ⚠️
src/org/rascalmpl/ast/SyntaxRoleModifier.java 25% 84 Missing and 1 partial ⚠️
src/org/rascalmpl/ast/Type.java 43% 17 Missing and 1 partial ⚠️
src/org/rascalmpl/library/Type.java 55% 15 Missing and 1 partial ⚠️
src/org/rascalmpl/types/RascalTypeFactory.java 43% 12 Missing and 1 partial ⚠️
...ascalmpl/semantics/dynamic/SyntaxRoleModifier.java 55% 12 Missing ⚠️
...org/rascalmpl/values/parsetrees/SymbolFactory.java 35% 10 Missing and 1 partial ⚠️
src/org/rascalmpl/types/RascalType.java 27% 7 Missing and 1 partial ⚠️
src/org/rascalmpl/ast/NullASTVisitor.java 0% 6 Missing ⚠️
...almpl/interpreter/staticErrors/UnexpectedType.java 25% 3 Missing and 3 partials ⚠️
... and 11 more
Additional details and impacted files
@@           Coverage Diff            @@
##              main   #1835    +/-   ##
========================================
- Coverage       45%     45%    -1%     
- Complexity    6786    6842    +56     
========================================
  Files          843     847     +4     
  Lines        68798   69492   +694     
  Branches     10029   10152   +123     
========================================
+ Hits         31345   31631   +286     
- Misses       35064   35423   +359     
- Partials      2389    2438    +49     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jurgenvinju

Copy link
Copy Markdown
Member Author

@rodinaarssen could you have a look at this? especially if you think we need more tests.

@jurgenvinju
jurgenvinju marked this pull request as ready for review September 8, 2026 15:30

@rodinaarssen rodinaarssen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

I have some remarks/questions, primarily for clarification

Comment thread src/org/rascalmpl/compiler/lang/rascalcore/check/AType.rsc
Comment thread src/org/rascalmpl/compiler/lang/rascalcore/check/AType.rsc Outdated
Comment thread src/org/rascalmpl/compiler/lang/rascalcore/check/AType.rsc Outdated

AType alub(\asyntaxRoleModifier(SyntaxRole a, \aparameter(x, _)),
\asyntaxRoleModifier(SyntaxRole b, \aparameter(y, _))) = aadt("Tree",[], dataSyntax())
when x != y, {a,b} < {contextFreeSyntax(), lexicalSyntax(), keywordSyntax(), layoutSyntax()};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we missing overloads for when x == y, or is that handled elsewhere?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default rule for lub(x,x) = x comes into play automatically.

  • In this case when a == b and x == y that is easy to see.
  • When a == b but x != y we get the current case
  • When a != b but x == y we should also get the current case.
  • When a != b and x != y` we should also get the current case.

So I'm dropping the x != y condition

Comment thread src/org/rascalmpl/library/lang/paths/Windows.rsc Outdated
Comment thread src/org/rascalmpl/library/Type.java Outdated
Comment thread src/org/rascalmpl/library/Type.rsc
Comment thread src/org/rascalmpl/library/Type.rsc
protected Type glbWithNonTerminal(RascalType other) {
IConstructor otherSym = ((NonTerminalType)other).symbol;

// TODO: this code does not cater for type parameters!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open TODO?

Comment thread src/org/rascalmpl/types/TypeReifier.java
@jurgenvinju

Copy link
Copy Markdown
Member Author

Interesting bootstrap issue while running CI on this PR:

10196 [INFO] --- rascal:0.31.0:compile (default-compile) @ rascal ---
10289 [INFO] Maven Rascal Mojo detected rascal project self-application. Downloading the configured bootstrap rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar
10290 [INFO] Find <rascalBootstrapVersion>0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES</rascalBootstrapVersion> in rascal/pom.xml
12446 [INFO] Resolving org.rascalmpl:rascal:jar:0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES with transitive dependencies
13945 [INFO] The Rascal runtime was resolved at /home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar
Job: loading modules
Job: loading modules
Job: Compiling Prelude
TypeUnavailable()
	at collector_getType(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/typepal/analysis/typepal/Collector.rsc|(27150,137,<667,20>,<671,9>))
	at collectSyntaxRoleModifiers(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/compiler/lang/rascalcore/check/CollectType.rsc|(36743,14,<911,10>,<911,24>))
	at collect(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/compiler/lang/rascalcore/check/CollectType.rsc|(35962,124,<894,0>,<895,63>))
	at collectSignature(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/compiler/lang/rascalcore/check/CollectDeclaration.rsc|(18287,23,<462,8>,<462,31>))
	at collect(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/compiler/lang/rascalcore/check/CollectDeclaration.rsc|(12555,36,<324,30>,<324,66>))
	at collectArgs2(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/typepal/analysis/typepal/Collector.rsc|(49372,20,<1220,8>,<1220,28>))
	at collect(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/typepal/analysis/typepal/Collector.rsc|(50885,22,<1274,29>,<1274,51>))
	at collect(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/typepal/analysis/typepal/Collector.rsc|(50466,116,<1268,36>,<1268,152>))
	at collect(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/compiler/lang/rascalcore/check/CollectDeclaration.rsc|(5496,33,<153,12>,<153,45>))
	at collect(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/typepal/analysis/typepal/Collector.rsc|(47299,15,<1128,4>,<1128,19>))
	at collect(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/compiler/lang/rascalcore/check/CollectDeclaration.rsc|(3389,25,<99,8>,<99,33>))
	at rascalTModelComponent(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc|(21812,27,<501,12>,<501,39>))
	at rascalTModelForLocs(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc|(11260,37,<301,27>,<301,64>))
	at check(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc|(24921,64,<590,9>,<590,73>))
	at main(|jar+file:///home/runner/.m2/repository/org/rascalmpl/rascal/0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES/rascal-0.43.0-RC14-BOOT-PREVIEW-SYNTAX-ROLES.jar!/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc|(27892,29,<666,19>,<666,48>))

Commented out the @bootstrapParser annotation for bootstrapping purposes.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants