-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #483 from Little-Rubyist/add_types_to_counterexamples
Add types to counterexamples
- Loading branch information
Showing
20 changed files
with
430 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,10 @@ def to_s | |
"#<Path(#{type})>" | ||
end | ||
alias :inspect :to_s | ||
|
||
def type | ||
raise NotImplementedError | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module Lrama | ||
class Counterexamples | ||
@states: States | ||
@transitions: Hash[[StateItem, Grammar::Symbol], StateItem] | ||
@reverse_transitions: Hash[[StateItem, Grammar::Symbol], Set[StateItem]] | ||
@productions: Hash[StateItem, Set[States::Item]] | ||
@reverse_productions: Hash[[State, Grammar::Symbol], Set[States::Item]] | ||
|
||
attr_reader transitions: Hash[[StateItem, Grammar::Symbol], StateItem] | ||
attr_reader productions: Hash[StateItem, Set[States::Item]] | ||
|
||
def initialize: (States states) -> void | ||
def to_s: () -> "#<Counterexamples>" | ||
alias inspect to_s | ||
def compute: (State conflict_state) -> Array[Example] | ||
|
||
private | ||
|
||
def setup_transitions: () -> void | ||
def setup_productions: () -> void | ||
def shift_reduce_example: (State conflict_state, State::ShiftReduceConflict conflict) -> Example | ||
def reduce_reduce_examples: (State conflict_state, State::ReduceReduceConflict conflict) -> Example | ||
def find_shift_conflict_shortest_path: (::Array[StartPath|TransitionPath|ProductionPath]? reduce_path, State conflict_state, States::Item conflict_item) -> ::Array[StartPath|TransitionPath|ProductionPath] | ||
def find_shift_conflict_shortest_state_items: (::Array[StartPath|TransitionPath|ProductionPath]? reduce_path, State conflict_state, States::Item conflict_item) -> Array[StateItem] | ||
def build_paths_from_state_items: (Array[StateItem] state_items) -> ::Array[StartPath|TransitionPath|ProductionPath] | ||
def shortest_path: (State conflict_state, States::Item conflict_reduce_item, Grammar::Symbol conflict_term) -> ::Array[StartPath|TransitionPath|ProductionPath]? | ||
def follow_l: (States::Item item, Set[Grammar::Symbol] current_l) -> Set[Grammar::Symbol] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Lrama | ||
class Counterexamples | ||
class Derivation | ||
@item: States::Item | ||
|
||
@left: Derivation? | ||
|
||
@right: Derivation? | ||
|
||
attr_reader item: States::Item | ||
|
||
attr_reader left: Derivation? | ||
|
||
attr_reader right: Derivation? | ||
|
||
attr_writer right: Derivation? | ||
|
||
def initialize: (States::Item item, Derivation? left, ?Derivation? right) -> void | ||
|
||
def to_s: () -> ::String | ||
|
||
alias inspect to_s | ||
|
||
def render_strings_for_report: () -> Array[String] | ||
|
||
def render_for_report: () -> String | ||
|
||
private | ||
|
||
def _render_for_report: (Derivation derivation, Integer offset, Array[String] strings, Integer index) -> Integer | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module Lrama | ||
class Counterexamples | ||
class Example | ||
@path1: ::Array[StartPath | TransitionPath | ProductionPath] | ||
|
||
@path2: ::Array[StartPath | TransitionPath | ProductionPath] | ||
|
||
@conflict: (State::ShiftReduceConflict | State::ReduceReduceConflict) | ||
|
||
@conflict_symbol: Grammar::Symbol | ||
|
||
@counterexamples: Counterexamples | ||
|
||
@derivations1: Derivation | ||
|
||
@derivations2: Derivation | ||
|
||
attr_reader path1: ::Array[StartPath | TransitionPath | ProductionPath] | ||
|
||
attr_reader path2: ::Array[StartPath | TransitionPath | ProductionPath] | ||
|
||
attr_reader conflict: (State::ShiftReduceConflict | State::ReduceReduceConflict) | ||
|
||
attr_reader conflict_symbol: Grammar::Symbol | ||
|
||
def initialize: (::Array[StartPath | TransitionPath | ProductionPath]? path1, ::Array[StartPath | TransitionPath | ProductionPath]? path2, (State::ShiftReduceConflict | State::ReduceReduceConflict) conflict, Grammar::Symbol conflict_symbol, Counterexamples counterexamples) -> void | ||
|
||
def type: () -> (:shift_reduce | :reduce_reduce) | ||
|
||
def path1_item: () -> States::Item | ||
|
||
def path2_item: () -> States::Item | ||
|
||
def derivations1: () -> Derivation | ||
|
||
def derivations2: () -> Derivation | ||
|
||
private | ||
|
||
def _derivations: (::Array[StartPath | TransitionPath | ProductionPath] paths) -> Derivation | ||
|
||
def find_derivation_for_symbol: (StateItem state_item, Grammar::Symbol sym) -> Derivation? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Lrama | ||
class Counterexamples | ||
class Path | ||
@from_state_item: StateItem? | ||
|
||
@to_state_item: StateItem | ||
|
||
def initialize: (StateItem? from_state_item, StateItem to_state_item) -> void | ||
|
||
def from: () -> StateItem? | ||
|
||
def to: () -> StateItem | ||
|
||
def to_s: () -> ::String | ||
|
||
alias inspect to_s | ||
|
||
def type: -> bot | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Lrama | ||
class Counterexamples | ||
class ProductionPath < Path | ||
def type: () -> :production | ||
|
||
def transition?: () -> false | ||
|
||
def production?: () -> true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Lrama | ||
class Counterexamples | ||
class StartPath < Path | ||
def initialize: (StateItem to_state_item) -> void | ||
|
||
def type: () -> :start | ||
|
||
def transition?: () -> false | ||
|
||
def production?: () -> false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Lrama | ||
class Counterexamples | ||
class StateItem | ||
attr_accessor state: State | ||
attr_accessor item: States::Item | ||
|
||
def initialize: (State state, States::Item item) -> void | ||
end | ||
end | ||
end |
Oops, something went wrong.