Skip to content
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
6 changes: 6 additions & 0 deletions lib/prism/translation/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def initialize(message, level, reason, location)
end
end

# Create the parser with our custom builder class
def initialize(builder = Parser::Builder.new)
super
end

Racc_debug_parser = false # :nodoc:

def version # :nodoc:
Expand Down Expand Up @@ -313,6 +318,7 @@ def convert_for_prism(version)
end
end

require_relative "parser/builder"
require_relative "parser/compiler"
require_relative "parser/lexer"

Expand Down
13 changes: 13 additions & 0 deletions lib/prism/translation/parser/builder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module Prism
module Translation
class Parser
# A builder that knows how to convert more modern Ruby syntax
# into whitequark/parser gem's syntax tree.
class Builder < ::Parser::Builders::Default

end
end
end
end
1 change: 1 addition & 0 deletions prism.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Gem::Specification.new do |spec|
"lib/prism/translation/parser33.rb",
"lib/prism/translation/parser34.rb",
"lib/prism/translation/parser35.rb",
"lib/prism/translation/parser/builder.rb",
"lib/prism/translation/parser/compiler.rb",
"lib/prism/translation/parser/lexer.rb",
"lib/prism/translation/ripper.rb",
Expand Down
1 change: 1 addition & 0 deletions test/prism/ruby/parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

# First, opt in to every AST feature.
Parser::Builders::Default.modernize
Prism::Translation::Parser::Builder.modernize

# The parser gem rejects some strings that would most likely lead to errors
# in consumers due to encoding problems. RuboCop however monkey-patches this
Expand Down
Loading