When Alpag happens upon a conflict in grammar, a message with brief description of the conflict is displayed. If conflict can be resolved using some user-defined rule, it is reported as warning, and parser generation succeeds. If conflict cannot be resolved, it is reported as error, and parser generation fails.
Grammar shown below contains a shit-reduce conflict:
If user did not resolve the conflict using one of available arbitration mechanisms, above grammar will produce an error with a message like this:
To interpret the message it is necessary to find state #9 and production @3. State and production identifiers are assigned by alpag during parser generation and can be found in parser report.
To generate parser report use –pr switch when running Alpag.
Report contains following information for state #9:
Elements of itemset are grammar productions for which the state was built. Exact point within productions the state was built for is marked with dot '.'.
Multiple entries in itemset mean that parser does not know yet which of these alternatives is correct and has to read more input to decide. In above example parser is either at the end of production @3 or inside production @4 before 'ELSE', as shown by dots.
In general it is not an error to have state with multiple alternative interpretations, providing that parser is allowed to read more input and finally get to a state with just one itemset element and thus single interpretation.
In above example parser cannot read more input since position (the dot '.') is at the end of one of alternative productions. Providing that this production is the correct alternative, decision to choose it and reduce according to it must be done right now.
Alpag has no sufficient information which alternative to choose, so a shift-reduce conflict is reported. User must resolve the conflict manually and decide whether to reduce by production @3 or shift ELSE and move to state #10 hoping to match production @4.