Skip to content

Commit

Permalink
Merge pull request #79 from ydah/extract-struct
Browse files Browse the repository at this point in the history
Extract Struct into another file
  • Loading branch information
yui-knk authored Aug 10, 2023
2 parents c688164 + 98f0333 commit c029c8f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
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

0 comments on commit c029c8f

Please sign in to comment.