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

Extract Struct into another file #79

Merged
merged 4 commits into from
Aug 10, 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
1 change: 1 addition & 0 deletions lib/lrama.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
require "lrama/state"
require "lrama/states"
require "lrama/states_reporter"
require "lrama/type"
require "lrama/version"
require "lrama/warning"
6 changes: 2 additions & 4 deletions lib/lrama/grammar.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require "lrama/grammar/aux"
require "lrama/grammar/code"
require "lrama/grammar/error_token"
require "lrama/grammar/precedence"
Expand All @@ -7,16 +8,13 @@
require "lrama/grammar/symbol"
require "lrama/grammar/union"
require "lrama/lexer"
require "lrama/type"

module Lrama
Type = Struct.new(:id, :tag, keyword_init: true)
Token = Lrama::Lexer::Token

# Grammar is the result of parsing an input grammar file
class Grammar
# Grammar file information not used by States but by Output
Aux = Struct.new(:prologue_first_lineno, :prologue, :epilogue_first_lineno, :epilogue, keyword_init: true)

attr_reader :eof_symbol, :error_symbol, :undef_symbol, :accept_symbol, :aux
attr_accessor :union, :expect,
:printers, :error_tokens,
Expand Down
7 changes: 7 additions & 0 deletions lib/lrama/grammar/aux.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Lrama
class Grammar
# Grammar file information not used by States but by Output
class Aux < Struct.new(:prologue_first_lineno, :prologue, :epilogue_first_lineno, :epilogue, keyword_init: true)
end
end
end
5 changes: 3 additions & 2 deletions lib/lrama/lexer/token.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require 'lrama/lexer/token/type'

module Lrama
class Lexer
class Token < Struct.new(:type, :s_value, :alias, keyword_init: true)
Type = Struct.new(:id, :name, keyword_init: true)
class Token

attr_accessor :line, :column, :referred
# For User_code
Expand Down
8 changes: 8 additions & 0 deletions lib/lrama/lexer/token/type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Lrama
class Lexer
class Token < Struct.new(:type, :s_value, :alias, keyword_init: true)
class Type < Struct.new(:id, :name, keyword_init: true)
end
end
end
end
4 changes: 4 additions & 0 deletions lib/lrama/type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Lrama
class Type < Struct.new(:id, :tag, keyword_init: true)
end
end