Merge pull request #1936 from J3RN/add-rust-scanner-note

Add note about including an external scanner in Rust crate
This commit is contained in:
Max Brunsfeld 2022-10-31 14:49:15 -07:00 committed by GitHub
commit fb5fbdd787
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -590,7 +590,7 @@ 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.
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.
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.