Replace 'public' utils with a more generic 'optional_flag'

The 'public' util was arguably not really adding much except a layer of indirection.
  In the end, one useful parsing behavior to abstract is the idea of 'optional flag' that we use for both 'pub' and 'opaque' keywords.
This commit is contained in:
KtorZ
2023-07-05 13:57:34 +02:00
parent 5e8edcb340
commit 93e010b345
5 changed files with 34 additions and 38 deletions

View File

@@ -7,8 +7,8 @@ use super::{
token::{Base, Token},
};
pub fn public() -> impl Parser<Token, (), Error = ParseError> {
just(Token::Pub).ignored()
pub fn optional_flag(token: Token) -> impl Parser<Token, bool, Error = ParseError> {
just(token).ignored().or_not().map(|v| v.is_some())
}
pub fn bytearray(