Skip to content

Generate valid Java code from invalid PIE code #292

Description

@MeAmAnUsername

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions