-
Notifications
You must be signed in to change notification settings - Fork 60
[fud2] Serialize Plans into Assignment Lists #2555
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
jku20
wants to merge
26
commits into
main
Choose a base branch
from
fud2/serialize-plans
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
It might make sense to simply replace the current "show" mode with the funny new syntax, but I'm hesitant at current without writing up the syntax a bit more formally. |
jku20
commented
Oct 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some todos
4 tasks
jku20
added a commit
that referenced
this pull request
Oct 20, 2025
This serializes fud2 using JSON and a language called flang. See #2555 for more details. In short this PR adds one new planner: `json`. It reads a plan from stdin specified in the JSON form of flang. Additionally the PR adds one new mode: `json-plan`, taking the plan from the current planner and writing it to stdout in JSON syntax of flang.
KarlJoad
added a commit
to Chil-HW/chil
that referenced
this pull request
Oct 22, 2025
This TODO was prompted by Calyx's fud2 adding serialization and deserialization support in [1], with an initial implementation in [2]. [1] calyxir/calyx#2555 [2] calyxir/calyx#2564
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces functionality to export and import plans to and from a serialized data format. There are two flavors of syntax, JSON and a custom syntax I'm calling flang (fud2 lang). Currently this data format supports explicit file names with inputs and outputs from
stdioleft for the future. Path names as exported directly from the planners. This means they are generally relative to the directory thefud2command was invoked in. This is incorrect behavior, but is likely better fixed in a followup PR which changes the planner interface to include filename assignment as part of the planners.This PR adds two new planners:
jsonandflang. Both of these read a plan from stdin, one specified in JSON and the other specified in flang.Additionally the PR adds two new modes:
json-planandflang-plan, taking the plan from the current planner and writing it to stdout in JSON and flang syntax respectively.The bulk of the engineering effort here is defining the AST and parser for flang. The JSON parser is implemented decoratively in the obvious way with serde. A description of the implemented syntax follows. Defining the semantics is ongoing work.
Flang
Motivation
Plan files currently have two forms which are interchangeable: JSON and flang. Generally the
JSON notation should be preferred due to its easier interop with other tools and parsing.
The custom language is written as it is easier to read and reason about. It's nice to have the
fantasy syntax the JSON represents be real.
Syntax
Flang syntax is defined as a list of semicolon statements. Each statement is composed of the
assignment of a list of variables by a function which itself takes in a list of variables. For
example, the following is a simple flang program:
A lot about the above is similar to other imperative languages. Some particular things to note:
aand as quoted strings such as in "1 file path cool.txt (2)". This lax attitude towards variables lets things like file paths exist as variables.-as an operator, which instead can be used in identifiers.A more formal specification of the syntax follows:
TODO:
op-seqmodeadd end to end tests for new format<-- I want to wait until path stuff is finalized out before adding theseExtra notes on the implementation:
The error handling on this parser is utterly atrocious, though it is written in such a way that it should not be terribly difficult to make the error handling much better.
Notes to the Reviewer on Implementation
This is a really big PR, bigger than it should be, however, splitting it up significantly is difficult. To be a single testable unit, the parser infrastructure should likely all be implemented in a single PR. For testing and making the changes externally visiable, and making the visitor framework for traversing the ASTs into nice printable forms is quite helpful.
A decent way to group the files into three roughly independent parts is:
flangmodule represents all to do with representing and parsingflang. It includes the AST and parser.ast_converter.rsuse the visitor framework fromflangto pretty print the AST as well as convert and from current fud2 plans.fud2.For ease of reviewability, this PR will be split into a multiple other PRs. An incomplete list follows: