Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use attr_reader #331

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions lib/lrama/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Context
BaseMin = -Float::INFINITY

# TODO: It might be better to pass `states` to Output directly?
attr_reader :states
attr_reader :states, :yylast, :yypact_ninf, :yytable_ninf, :yydefact, :yydefgoto

def initialize(states)
@states = states
Expand Down Expand Up @@ -46,10 +46,6 @@ def yyfinal
end.id
end

def yylast
@yylast
end

# Number of terms
def yyntokens
@states.terms.count
Expand Down Expand Up @@ -119,30 +115,14 @@ def yytname
end
end

def yypact_ninf
@yypact_ninf
end

def yytable_ninf
@yytable_ninf
end

def yypact
@base[0...yynstates]
end

def yydefact
@yydefact
end

def yypgoto
@base[yynstates..-1]
end

def yydefgoto
@yydefgoto
end

def yytable
@table
end
Expand Down
9 changes: 2 additions & 7 deletions lib/lrama/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

module Lrama
class Lexer
attr_reader :head_line, :head_column
attr_accessor :status
attr_accessor :end_symbol
attr_reader :head_line, :head_column, :line
attr_accessor :status, :end_symbol

SYMBOLS = ['%{', '%}', '%%', '{', '}', '\[', '\]', '\(', '\)', '\,', ':', '\|', ';']
PERCENT_TOKENS = %w(
Expand Down Expand Up @@ -50,10 +49,6 @@ def next_token
end
end

def line
@line
end

def column
@scanner.pos - @head
end
Expand Down