Skip to content

Commit

Permalink
Merge pull request #276 from nobu/undocument-embedded-parser
Browse files Browse the repository at this point in the history
Undocument embedded parser
  • Loading branch information
nobu authored Jan 3, 2025
2 parents d9218e4 + 627d46d commit a320c65
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ file 'lib/racc/parser-text.rb' => ['lib/racc/parser.rb', 'lib/racc/info.rb', __F

text = File.read(source)
text.sub!(/\A# *frozen[-_]string[-_]literal:.*\n/, '')
text.gsub!(/^require '(.*)'$/) do
text.gsub!(/(^#.*\n)+(?=module )/, "#--\n")
text.gsub!(/^require '(.*)'$/) do
lib = $1
code = File.read("lib/#{lib}.rb")
code.sub!(/\A(?:#.*\n)+/, '')
%[unless $".find {|p| p.end_with?('/#{lib}.rb')}\n$".push "\#{__dir__}/#{lib}.rb"\n#{code}\nend\n]
rescue
$&
end
text << "#++\n"
File.open(t.name, 'wb') { |io|
io.write(<<-eorb)
# :stopdoc:
module Racc
PARSER_TEXT = <<'__end_of_file__'
#{text}
Expand Down

0 comments on commit a320c65

Please sign in to comment.