-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fud2] Additional Syntax to Rhai DSL (#2203)
## Description This pull request adds new syntax for defining ops which punts most of the work of the DSL to Rhai. That is, the PR defines new syntax to define ops in Rhai by directly associating a sequence of shell commands with ops. Variables and setups can be done using Rhai's scripting instead of variables and multiple rules in ninja. This leaves only very simple, one rule for each op, ninja files. As currently written, this style of op creation may be easier to write and read, however, it may also generate less readable ninja files. ## Example of New Syntax ``` export const verilog_state = state("verilog", ["sv", "v"]); export const calyx_state = state("calyx", ["futil"]); export const verilog_noverify = state("verilog-noverify", ["sv"]); fn calyx_setup() { // Rhai syntax for object maps. #{ calyx_base: config("calyx.base"), calyx_exe: config_or("calyx.exe", "${calyx_base}/target/debug/calyx"), args: config_or("calyx.args", ""), } } defop calyx_to_verilog(c: calyx_state) >> v: verilog_state { let s = calyx_setup(); shell("${s.calyx_exe} -l ${s.calyx_base} -b verilog ${s.args} ${c} > ${v}"); } defop calyx_noverify(c: calyx_state) >> v: verilog_noverify { let s = calyx_setup(); shell("${s.calyx_exe} -l ${s.calyx_base} -b verilog ${s.args} --disable-verify ${c} > ${v}"); } ``` The strings passed to `shell` can be constructed with a function to remove some repetition if desired. While this style of creating ops does clash with the current style, they should still be able to coexist. ## TODO - [x] Implement `defop` syntax. - [x] Implement `shell` function. - [x] Implement `config` and `config_or` function. - [x] Make the two types of substitution more distinct.
- Loading branch information
Showing
32 changed files
with
1,596 additions
and
59 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.