Skip to content

[gen] Introduce a new relaxation/edge/atom parser in diy tool.#1685

Open
ShaleXIONG wants to merge 1 commit intoherd:masterfrom
ShaleXIONG:code-better-parser
Open

[gen] Introduce a new relaxation/edge/atom parser in diy tool.#1685
ShaleXIONG wants to merge 1 commit intoherd:masterfrom
ShaleXIONG:code-better-parser

Conversation

@ShaleXIONG
Copy link
Collaborator

@ShaleXIONG ShaleXIONG commented Jan 27, 2026

This is a first phrase to rework on the diy* lexer and parser on input relaxations or cycles. In this pull request we introduce a more conventional way, that is, (1) new lexer.mll tokenises input to an AST, specifically type t in new ast.ml and (2) new parser.mly parses the AST to internal data structure. Note that we keep the old lexutil.mll for backward compatibility, and this file will be remove for next phrase.
In the Ast.t, individual primitive relaxation is represented by One of string. The consequence of relaxation is represented by Seq of t list; this corresponds to , syntax or in some situation, white space. For example diyone7 PosWR PosRR Fri is equivalent to diyone7 PosWR,PosRR,Fri. We also introduce a Choice contractor, together with a new syntax |. For example PosWR|DpAddrdW means either PosWR or DpAddrdW. This can be used in diycross7 and diy7. In diyone7, although it will be parsed however an error occurs due to input is not a precise one cycle. The future plan is to gradually deprecates only diycross7 syntax.
for example diycross7 Po,DpAddr Rfi,Fri,Coi is in fact means diycross7 Po|DpAddr Rfi|Fri|Coi.
Last, Given all the chances above, we unify the paring process cross three diy* tools. Previously different diy* has different parsing path and the actual code are in different files. Now the main passing function unifies at parse_expand_relax and parse_expand_relaxs in relax.ml. The future plan is to remove the Ppo type as it is only used in PPCCompile_gen.ml as a special wildcard. However the current parsing is after we flatten the Ast.t to a string list list, so we can hook to the existing parsing functions. The future plan is to parametrise the type Ast.t, so we can directly parse on the Ast.t.

@ShaleXIONG ShaleXIONG requested a review from fsestini January 27, 2026 12:56
@ShaleXIONG ShaleXIONG force-pushed the code-better-parser branch 4 times, most recently from ce28381 to 15b8202 Compare January 29, 2026 09:54
@ShaleXIONG ShaleXIONG marked this pull request as ready for review January 29, 2026 10:14
- We introduce new choice syntax `|`. For example `PosWR|DpAddrdW` means
  either `PosWR` or `DpAddrdW`. This can be used in `diycross7` and
  `diy7`. In `diyone7`, although it will be parsed however an error
  occurs due to input is not a precise one cycle.
- The new `parser.mly` and `lexer.mll` combination parses the input
  cycle into `Ast.t`.
- Unify the paring process cross three `diy*` tools.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant