Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate valid Java code from invalid PIE code #292

Open
5 tasks
MeAmAnUsername opened this issue Apr 21, 2022 · 0 comments
Open
5 tasks

Generate valid Java code from invalid PIE code #292

MeAmAnUsername opened this issue Apr 21, 2022 · 0 comments
Labels
Component: code generation Something that concerns the generated code Priority: low Status: proposal Enhancement in the proposal stage Type: enhancement New feature or request

Comments

@MeAmAnUsername
Copy link
Owner

MeAmAnUsername commented Apr 21, 2022

Summary
Generate stubs with a RuntimeException from invalid PIE code

Todo

  • Figure out how to implement this
  • Figure out how to test this
  • Add e2e tests
  • Implement
  • Add to documentation

Reason
Useful while developing and you want to test some code while other, unrelated code still has errors. See this blog post for detailed reasoning.

Description
When generating Java code from PIE code with errors, generate a stub that throws a NotImplementedException. If the error is in an expression, still generate code for all expressions before it.

Implementation
Probably requires removing all with in the compiler and handling strategy failure gracefully. For example, use these strategies:

p2j-ast-exp-or-fail: java_exp -> p2j-ast-exp <+ p2j-ast-fail

p2j-ast-fail: pie_code -> ([], {| throw new InvalidPieCodeException("Could not generate Java code: PIE source code at $filename:$line has an error") |} )
  with
    <add-import> "mb.pie.dsl.compiler.InvalidPieCodeException"
  ; (filename, line) := get-source-location(pie-code)

Testing is not possible within the current test project, as that will fail the Spoofax build if the PIE code has errors. This might be configurable though.

Related issues

  • This issue changes what code to generate when the PIE code has errors. Refuse to compile if there are static errors #91 proposes to give the option to refuse compiling PIE code with errors. These changes are orthogonal: both can be implemented independently.
@MeAmAnUsername MeAmAnUsername added Status: proposal Enhancement in the proposal stage Component: code generation Something that concerns the generated code Priority: low Type: enhancement New feature or request labels Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: code generation Something that concerns the generated code Priority: low Status: proposal Enhancement in the proposal stage Type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant