Skip to content

AST for KeY Scripts #3587

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

AST for KeY Scripts #3587

wants to merge 6 commits into from

Conversation

wadoon
Copy link
Member

@wadoon wadoon commented Mar 29, 2025

Synopsis

JMLScripts and KeY scripts use the same backend, but the ProofScriptEngine is currently bound to the KeY language's parser. This PR introduces a simple AST class to abstract the source of a script, which is a simple record containing the command name, positional and keyword arguments, sub-commands, and positional information.

classDiagram
  direction TB

  class ScriptCommandAst { 
  name : String 
  positionalArgs : List<Object>
  keywordArgs    : Map<String,Object>
  loc            : Location
 }

ScriptCommandAst "*" <-- ScriptCommandAst : sub-commands
Loading

Along the road, the interface of script commands is simplified: There is no need for preparing the parameter class instance anymore. Instead, execute(..) is called directly and any command implementation can deal with the AST as they like.

Also, proof script commands can announce a list of aliases. This allows the implementation of multiple (similar) commands with one implementation. The implementation can adapt its behavior using the given AST representation.

Using List<Object> and Map<String,Object> allows the use within JML scripts, as custom objects can be provided within the AST. Later, the ValueInjector should know the conversion rules to get fromthe custom object to the required types, e.g., how to come from a JMLTerm to a JTerm.

Builds upon: #3021

Intended Change

ProofScriptEngine is free of ANTLR classes.
An AST for the execution of proof scripts exists, which is useable

Plan

  • Do it.
  • Test it.
  • Ship it.

Type of pull request

  • Refactoring (behaviour should not change or only minimally change)

    • Breaking change:
      breaks the internal API of proof script execution, and script commands.
  • There are changes to the (Java) code

Ensuring quality

  • I made sure that introduced/changed code is well documented (javadoc and inline comments).
  • I made sure that new/changed end-user features are well documented (https://github.com/KeYProject/key-docs).
  • I added new test case(s) for new functionality.
  • I have tested the feature as follows: ...
  • I have checked that runtime performance has not deteriorated.

@wadoon wadoon added this to the v2.12.4 milestone Mar 29, 2025
@wadoon wadoon self-assigned this Mar 29, 2025
@wadoon wadoon force-pushed the weigl/psg4-scriptast branch 2 times, most recently from d0aaa94 to 60e56c8 Compare April 13, 2025 16:30
@wadoon wadoon changed the base branch from main to weigl/psg4 April 14, 2025 12:50
@wadoon wadoon changed the base branch from weigl/psg4 to main April 15, 2025 10:48
@wadoon wadoon force-pushed the weigl/psg4-scriptast branch from 60e56c8 to a24ce7b Compare April 15, 2025 17:44
@wadoon wadoon force-pushed the weigl/psg4-scriptast branch 2 times, most recently from 44b2192 to 9b39f3d Compare May 10, 2025 14:02
@wadoon wadoon force-pushed the weigl/psg4-scriptast branch from a1f35a3 to 2aae43e Compare May 27, 2025 21:32
@wadoon wadoon force-pushed the weigl/psg4-scriptast branch 2 times, most recently from dd85e29 to 00a231d Compare June 8, 2025 13:59
@wadoon wadoon force-pushed the weigl/psg4-scriptast branch 2 times, most recently from c263c90 to dbe8815 Compare June 14, 2025 15:51
@wadoon wadoon force-pushed the weigl/psg4-scriptast branch from dbe8815 to 9eaa0f8 Compare June 29, 2025 22:46
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.

2 participants