Struct ielr::input::ConflictSolution
source · pub struct ConflictSolution {
pub prefer: ConflictingAction,
pub over: ConflictingAction,
}
Expand description
A manual solution to a conflict in the grammar.
Example
use ielr::{
input::{ConflictSolution, ConflictingAction, Grammar, Node, Symbol, Token},
output::Lookahead,
};
let expr: Node = Node(0);
let plus: Token = Token::new(1).unwrap();
let int: Token = Token::new(2).unwrap();
let mut grammar = Grammar::new();
let production = grammar
.add_production(
expr,
vec![Symbol::Node(expr), Symbol::Token(plus), Symbol::Node(expr)],
)
.unwrap();
grammar
.add_production(expr, vec![Symbol::Token(int)])
.unwrap();
grammar.add_conflict_solution(ConflictSolution {
prefer: ConflictingAction::Reduce(production),
over: ConflictingAction::Shift(Lookahead::Token(plus)),
});
Fields§
§prefer: ConflictingAction
The action that will be preferred over over
.
This does not mean that this action wil always be kept: there might be other
ConflictingAction
that remove it.
over: ConflictingAction
The action that will be removed in favor of prefer
.
Trait Implementations§
source§impl Clone for ConflictSolution
impl Clone for ConflictSolution
source§fn clone(&self) -> ConflictSolution
fn clone(&self) -> ConflictSolution
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ConflictSolution
impl Debug for ConflictSolution
source§impl Hash for ConflictSolution
impl Hash for ConflictSolution
source§impl Ord for ConflictSolution
impl Ord for ConflictSolution
source§fn cmp(&self, other: &ConflictSolution) -> Ordering
fn cmp(&self, other: &ConflictSolution) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<ConflictSolution> for ConflictSolution
impl PartialEq<ConflictSolution> for ConflictSolution
source§fn eq(&self, other: &ConflictSolution) -> bool
fn eq(&self, other: &ConflictSolution) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<ConflictSolution> for ConflictSolution
impl PartialOrd<ConflictSolution> for ConflictSolution
source§fn partial_cmp(&self, other: &ConflictSolution) -> Option<Ordering>
fn partial_cmp(&self, other: &ConflictSolution) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for ConflictSolution
impl Eq for ConflictSolution
impl StructuralEq for ConflictSolution
impl StructuralPartialEq for ConflictSolution
Auto Trait Implementations§
impl RefUnwindSafe for ConflictSolution
impl Send for ConflictSolution
impl Sync for ConflictSolution
impl Unpin for ConflictSolution
impl UnwindSafe for ConflictSolution
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more