I am developing my own HTML parser using proc_macro and syn . Sample:
#[derive(Debug)] struct BlockElement { stag: Ident, child: Vec<Element>, ctag: Ident } impl Synom for BlockElement { named!(parse -> Self, do_parse!( punct!(<) >> stag: syn!(Ident) >> punct!(>) >> child: syn!(ElementList) >> punct!(<) >> punct!(/) >> ctag: syn!(Ident) >> punct!(>) >> (BlockElement { stag, child: child.inner, ctag }) )); }
Although I know how to throw errors using Span after it has been parsed, I cannot figure out how to do this during parsing. These are just errors with failed to parse anything . How to determine where the parsing is and give the corresponding error?
rust
csharad
source share