Created
April 10, 2024 09:41
-
-
Save sogaiu/358f506ffc6197ab9e637e141c832779 to your computer and use it in GitHub Desktop.
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
diff --git a/cli/src/main.rs b/cli/src/main.rs | |
index 0337ead0..f38c8543 100644 | |
--- a/cli/src/main.rs | |
+++ b/cli/src/main.rs | |
@@ -33,6 +33,7 @@ enum Commands { | |
Query(Query), | |
Highlight(Highlight), | |
Tags(Tags), | |
+ BuildWasm(BuildWasm), | |
Playground(Playground), | |
DumpLanguages(DumpLanguages), | |
} | |
@@ -322,6 +323,18 @@ struct Tags { | |
pub config_path: Option<PathBuf>, | |
} | |
+#[derive(Args)] | |
+#[command(about = "Compile a parser to WASM", alias = "bw")] | |
+struct BuildWasm { | |
+ #[arg( | |
+ long, | |
+ help = "Run emscripten via docker even if it is installed locally" | |
+ )] | |
+ pub docker: bool, | |
+ #[arg(index = 1, num_args = 1.., help = "The path to output the wasm file")] | |
+ pub path: Option<String>, | |
+} | |
+ | |
#[derive(Args)] | |
#[command( | |
about = "Start local playground for a parser in the browser", | |
@@ -840,6 +853,17 @@ fn run() -> Result<()> { | |
)?; | |
} | |
+ Commands::BuildWasm(wasm_options) => { | |
+ let grammar_path = current_dir.join(wasm_options.path.unwrap_or_default()); | |
+ wasm::compile_language_to_wasm( | |
+ &loader, | |
+ &grammar_path, | |
+ ¤t_dir, | |
+ None, | |
+ wasm_options.docker, | |
+ )?; | |
+ } | |
+ | |
Commands::Playground(playground_options) => { | |
let open_in_browser = !playground_options.quiet; | |
let grammar_path = playground_options |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment