Questions Regarding Combinators, Efficiency And Workflow #627
FlipperPlz
started this conversation in
General
Replies: 1 comment
-
semi answer for question 3: The state and context can be used to hold information for parsing. However with this I don't know how to define context, currently I use the state in text::ascii::ident::<ParserInput<&'ast str>, char, Full<Rich<'ast, char, BSpan>, State, ()>>()
.map_with(| identity, extra| {
let state: &mut State = extra.state();
let Some(candidate_macro): Option<&RvMacroDefinition> = state.next_macro(identity) else {
return Token::Text(identity);
};
if !candidate_macro.in_scope() {
return Token::Text(identity);
}
let argument_count = candidate_macro.arguments();
let call = MacroCall {
macro_name: identity,
arguments: None,
};
if argument_count == 0 {
let expanded = candidate_macro.expand(None);
return Token::MacroCall(call, expanded)
}
return Token::MacroCall(call, String::new())
}).then(
//E.G here I want to enforce the argument_count identified in the above map
any().repeated().separated_by(just(Self::PARAM_SEPARATOR).ignored())
.exactly(argument_count)
)
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Introduction
Hey again!! The title may be incorrect here but I will try to explain myself as much as possible. Currently as stated in the previous post, I am implementing a context-less preprocessor (context-less as in it can be run on any document starting at any offset) in doing so I have been stumped implementing macros, as you will see I provided a "minimal" example of what I have written so far but I have a few issues so far. In fear of making you think that I'm just sending you a block of code and asking you to "help me" or "fix it" I will try as best as possible to form my issues into proper generalized questions regarding the use of the library, bare with me if you can. :3
Questions
If you could answer any of these questions or nudge me in the right direction it would be greatly appreciated. Thank you for making this library and still supporting it
"Minimal" Reproducible Example
This example contains every issue I was running into
Beta Was this translation helpful? Give feedback.
All reactions