Skip to content

Commit

Permalink
+ Extended hoe/racc to be multitask! ruby_parser goes from 8.5s to 1.2s!
Browse files Browse the repository at this point in the history
+ Extended hoe/racc to build .yy files to allow for multi-file generation.
- Fixed missing dep declaration on oedipus_lex.

[git-p4: depot-paths = "//src/hoe/dev/": change = 14003]
  • Loading branch information
zenspider committed Jan 5, 2024
1 parent 5edfce8 commit f9dfb8f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/hoe/racc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,23 @@ def initialize_racc

def activate_racc_deps
dependency "racc", "~> 1.5", :development
dependency "oedipus_lex", "~> 2.6", :development
end

##
# Define tasks for racc plugin

def define_racc_tasks
racc_files = self.spec.files.grep(/\.y$/)
y_files = self.spec.files.grep(/\.y$/)
yy_files = self.spec.files.grep(/\.yy$/)
rex_files = self.spec.files.grep(/\.rex$/)

parser_files = racc_files.map { |f| f.sub(/\.y$/, ".rb") }
yy_re = Regexp.union yy_files.map { |s| s.delete_suffix ".yy" }

parser_files =
y_files.map { |f| f.sub(/\.y$/, ".rb") } +
spec.files.grep(/(#{yy_re})\d+\.rb$/) -
yy_files
lexer_files = rex_files.map { |f| f.sub(/\.rex$/, ".rex.rb") }

self.clean_globs += parser_files
Expand Down Expand Up @@ -88,6 +95,9 @@ def define_racc_tasks

task :isolate # stub task

multitask :parser # make them multithreaded!
multitask :lexer

desc "build the parser" unless parser_files.empty?
task :parser => :isolate

Expand Down

0 comments on commit f9dfb8f

Please sign in to comment.