Looking proc_macro2 source as guidence for implementing ParseSlice on custom token type. #321
-
I am trying to implement tracing for my token system but I can't figure out how to implement ParseSlice to support the $() operator. My code is roughly like ->
For reference the current parser rule set is here -> https://github.com/devdave/rython4/blob/d33e78316497d73f7f48a460491104463a509f27/src/parser/grammar.rs I think I am missing a rule to consume multiple NL's ("\n") but I am not sure. Aside from my question, peg-rust is a great contribution to the Rust & open source ecosystem. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It looks like you have a |
Beta Was this translation helpful? Give feedback.
peg_macros/tokens.rs
is a little complicated because it's translating between the tree-structured tokens that rustc uses and a flat array of tokens that rust-peg expects.TokenStream
is the Rust compiler's token implementation used in procedural macros.proc-macro2
is the top of several abstraction layers over the implementation in the Rust compiler internals, but it comes with a fallback implementation that might be easier to understand if you're curious how it works. However you don't need any of that to userust-peg
unless you're trying to use it to implement a procedural Rust macro.It looks like you have a
Vec<Rc<Token>>
, so the better example to look at would be the implementation for