diff --git a/cli/loader/src/lib.rs b/cli/loader/src/lib.rs index 319a8cc1..48e95262 100644 --- a/cli/loader/src/lib.rs +++ b/cli/loader/src/lib.rs @@ -524,7 +524,12 @@ impl Loader { command.arg("/O2"); } command.arg(parser_path); + if let Some(scanner_path) = scanner_path.as_ref() { + if scanner_path.extension() != Some("c".as_ref()) { + eprintln!("Warning: Using a C++ scanner is now deprecated. Please migrate your scanner code to C, as C++ support will be removed in the near future."); + } + command.arg(scanner_path); } command @@ -560,6 +565,7 @@ impl Loader { if scanner_path.extension() == Some("c".as_ref()) { command.arg("-xc").arg("-std=c99").arg(scanner_path); } else { + eprintln!("Warning: Using a C++ scanner is now deprecated. Please migrate your scanner code to C, as C++ support will be removed in the near future."); command.arg(scanner_path); } } @@ -750,6 +756,7 @@ impl Loader { .and_then(|ext| ext.to_str()) .map_or(false, |ext| ["cc", "cpp"].contains(&ext)) { + eprintln!("Warning: Using a C++ scanner is now deprecated. Please migrate your scanner code to C, as C++ support will be removed in the near future."); command.arg("-xc++"); } command.arg(scanner_filename); diff --git a/docs/section-3-creating-parsers.md b/docs/section-3-creating-parsers.md index ffe9181e..2642f23c 100644 --- a/docs/section-3-creating-parsers.md +++ b/docs/section-3-creating-parsers.md @@ -649,7 +649,11 @@ grammar({ Then, add another C or C++ source file to your project. Currently, its path must be `src/scanner.c` or `src/scanner.cc` for the CLI to recognize it. Be sure to add this file to the `sources` section of your `binding.gyp` file so that it will be included when your project is compiled by Node.js and uncomment the appropriate block in your `bindings/rust/build.rs` file so that it will be included in your Rust crate. > **Note** -> While it is possible to write an external scanner in C++, it can be difficult to get working cross-platform and introduces extra requirements; therefore it is *greatly* preferred to use C. +> +> C++ scanners are now deprecated and will be removed in the near future. +> While it is currently possible to write an external scanner in C++, it can be difficult +> to get working cross-platform and introduces extra requirements; therefore it +> is *greatly* preferred to use C. In this new source file, define an [`enum`][enum] type containing the names of all of your external tokens. The ordering of this enum must match the order in your grammar's `externals` array; the actual names do not matter.