use crate::parser::Parser;
use crate::syntax::node_kind::NodeKind::{GenericMapAspect, PortMapAspect};
use crate::tokens::Keyword as Kw;
use crate::tokens::TokenKind::*;
impl Parser {
fn map_aspect(&mut self, kind: Kw) {
let aspect = match kind {
Kw::Generic => GenericMapAspect,
Kw::Port => PortMapAspect,
_ => unreachable!(),
};
self.node(aspect, |p| {
p.expect_tokens([Keyword(kind), Keyword(Kw::Map), LeftPar]);
p.association_list();
p.expect_token(RightPar);
});
}
fn opt_map_aspect(&mut self, kind: Kw) -> bool {
if self.next_is(Keyword(kind)) && self.next_nth_is(Keyword(Kw::Map), 1) {
self.map_aspect(kind);
true
} else {
false
}
}
pub(crate) fn port_map_aspect(&mut self) {
self.map_aspect(Kw::Port)
}
pub(crate) fn opt_port_map_aspect(&mut self) -> bool {
self.opt_map_aspect(Kw::Port)
}
pub(crate) fn generic_map_aspect(&mut self) {
self.map_aspect(Kw::Generic)
}
pub(crate) fn opt_generic_map_aspect(&mut self) -> bool {
self.opt_map_aspect(Kw::Generic)
}
}