1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* Copyright 2022 Arnaud Golfouse
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
use ;
use crateLookahead;
/// 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)),
/// });
/// ```
/// One of the possible actions in [`ConflictSolution`].