forked from ruby/lrama
-
Notifications
You must be signed in to change notification settings - Fork 0
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 ruby#458 from Little-Rubyist/add_types_to_state
Add types to classes in state directory
- Loading branch information
Showing
9 changed files
with
121 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Lrama | ||
class State | ||
class Reduce | ||
@item: States::Item | ||
@look_ahead: Array[Grammar::Symbol]? | ||
@not_selected_symbols: Array[Grammar::Symbol] | ||
|
||
attr_reader item: States::Item | ||
attr_reader look_ahead: Array[Grammar::Symbol]? | ||
attr_reader not_selected_symbols: Array[Grammar::Symbol] | ||
attr_accessor default_reduction: bool | ||
|
||
def initialize: (States::Item item) -> void | ||
def rule: -> Grammar::Rule | ||
def look_ahead=: (Array[Grammar::Symbol] look_ahead) -> Array[Grammar::Symbol] | ||
def add_not_selected_symbol: (Grammar::Symbol sym) -> Array[Grammar::Symbol] | ||
def selected_look_ahead: () -> (::Array[Grammar::Symbol?]) | ||
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 State | ||
class ReduceReduceConflict | ||
attr_accessor symbols: Array[Grammar::Symbol?] | ||
attr_accessor reduce1: State::Reduce | ||
attr_accessor reduce2: State::Reduce | ||
|
||
def initialize: (?symbols: Array[Grammar::Symbol?], ?reduce1: State::Reduce, ?reduce2: State::Reduce) -> void | ||
|
||
def type: () -> :reduce_reduce | ||
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,14 @@ | ||
module Lrama | ||
class State | ||
class ResolvedConflict | ||
attr_accessor symbol: Grammar::Symbol | ||
attr_accessor reduce: State::Reduce | ||
attr_accessor which: (:reduce | :shift) | ||
attr_accessor same_prec: bool | ||
|
||
def initialize: (?symbol: Grammar::Symbol, ?reduce: State::Reduce, ?which: (:reduce | :shift), ?same_prec: bool) -> void | ||
|
||
def report_message: () -> (::String | 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,14 @@ | ||
module Lrama | ||
class State | ||
class Shift | ||
@next_sym: Grammar::Symbol | ||
@next_items: Array[States::Item] | ||
|
||
attr_reader next_sym: Grammar::Symbol | ||
attr_reader next_items: Array[States::Item] | ||
attr_accessor not_selected: bool | ||
|
||
def initialize: (Grammar::Symbol next_sym, Array[States::Item] next_items) -> void | ||
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 State | ||
class ShiftReduceConflict | ||
attr_accessor symbols: Array[Grammar::Symbol] | ||
attr_accessor shift: State::Shift | ||
attr_accessor reduce: State::Reduce | ||
|
||
def initialize: (?symbols: Array[Grammar::Symbol], ?shift: State::Shift, ?reduce: State::Reduce) -> void | ||
|
||
def type: () -> :shift_reduce | ||
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,44 @@ | ||
module Lrama | ||
class States | ||
class Item | ||
extend Forwardable | ||
|
||
attr_accessor rule: untyped | ||
attr_accessor position: Integer | ||
|
||
# Optimization for States#setup_state | ||
def hash: () -> untyped | ||
|
||
def rule_id: () -> untyped | ||
|
||
def empty_rule?: () -> untyped | ||
|
||
def number_of_rest_symbols: () -> untyped | ||
|
||
def next_sym: () -> untyped | ||
|
||
def next_next_sym: () -> untyped | ||
|
||
def previous_sym: () -> untyped | ||
|
||
def end_of_rule?: () -> untyped | ||
|
||
def beginning_of_rule?: () -> untyped | ||
|
||
def start_item?: () -> untyped | ||
|
||
def new_by_next_position: () -> untyped | ||
|
||
def symbols_before_dot: () -> untyped | ||
|
||
def symbols_after_dot: () -> untyped | ||
|
||
def to_s: () -> ::String | ||
|
||
def display_name: () -> ::String | ||
|
||
# Right after position | ||
def display_rest: () -> ::String | ||
end | ||
end | ||
end |