Skip to content

Commit e993cce

Browse files
committed
Nodoc translator implementation details
As well as some functionality from ripper that is nodoc in ruby
1 parent 160d42b commit e993cce

7 files changed

Lines changed: 16 additions & 23 deletions

File tree

lib/prism/translation/parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Parser < ::Parser::Base
3333
# The parser gem has a list of diagnostics with a hard-coded set of error
3434
# messages. We create our own diagnostic class in order to set our own
3535
# error messages.
36-
class PrismDiagnostic < Diagnostic
36+
class PrismDiagnostic < Diagnostic # :nodoc:
3737
# This is the cached message coming from prism.
3838
attr_reader :message
3939

lib/prism/translation/parser/compiler.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ module Translation
66
class Parser
77
# A visitor that knows how to convert a prism syntax tree into the
88
# whitequark/parser gem's syntax tree.
9-
class Compiler < ::Prism::Compiler
9+
class Compiler < ::Prism::Compiler # :nodoc:
1010
# Raised when the tree is malformed or there is a bug in the compiler.
11-
class CompilationError < StandardError
11+
class CompilationError < StandardError # :nodoc:
1212
end
1313

1414
# The Parser::Base instance that is being used to build the AST.

lib/prism/translation/parser/lexer.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Translation
1010
class Parser
1111
# Accepts a list of prism tokens and converts them into the expected
1212
# format for the parser gem.
13-
class Lexer
13+
class Lexer # :nodoc:
1414
# These tokens are always skipped
1515
TYPES_ALWAYS_SKIP = Set.new(%i[IGNORED_NEWLINE __END__ EOF])
1616
private_constant :TYPES_ALWAYS_SKIP
@@ -188,8 +188,8 @@ class Lexer
188188
# without them. We should find another way to do this, but in the
189189
# meantime we'll hide them from the documentation and mark them as
190190
# private constants.
191-
EXPR_BEG = 0x1 # :nodoc:
192-
EXPR_LABEL = 0x400 # :nodoc:
191+
EXPR_BEG = 0x1
192+
EXPR_LABEL = 0x400
193193

194194
# It is used to determine whether `do` is of the token type `kDO` or `kDO_LAMBDA`.
195195
#
@@ -232,7 +232,7 @@ def initialize(source_buffer, lexed, offset_cache)
232232
@offset_cache = offset_cache
233233
end
234234

235-
Range = ::Parser::Source::Range # :nodoc:
235+
Range = ::Parser::Source::Range
236236
private_constant :Range
237237

238238
# Convert the prism tokens into the expected format for the parser gem.

lib/prism/translation/ripper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,8 @@ def parse
593593
##########################################################################
594594
# Visitor methods
595595
##########################################################################
596+
597+
# :stopdoc:
596598

597599
# alias foo bar
598600
# ^^^^^^^^^^^^^
@@ -3458,6 +3460,8 @@ def bounds(location)
34583460
@column = location.start_column
34593461
end
34603462

3463+
# :startdoc:
3464+
34613465
##########################################################################
34623466
# Ripper interface
34633467
##########################################################################

lib/prism/translation/ripper/lexer.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ module Prism
77
module Translation
88
class Ripper
99
class Lexer < Ripper # :nodoc:
10-
# :stopdoc:
11-
class State
10+
class State # :nodoc:
1211
attr_reader :to_int, :to_s
1312

1413
def initialize(i)
@@ -48,7 +47,7 @@ def self.[](i)
4847
end
4948
end
5049

51-
class Elem
50+
class Elem # :nodoc:
5251
attr_accessor :pos, :event, :tok, :state, :message
5352

5453
def initialize(pos, event, tok, state, message = nil)
@@ -128,8 +127,6 @@ def parse(...)
128127
def scan(...)
129128
parse(...)
130129
end
131-
132-
# :startdoc:
133130
end
134131
end
135132
end

lib/prism/translation/ripper/sexp.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ module Translation
88
class Ripper
99
# This class mirrors the ::Ripper::SexpBuilder subclass of ::Ripper that
1010
# returns the arrays of [type, *children].
11-
class SexpBuilder < Ripper
12-
# :stopdoc:
13-
11+
class SexpBuilder < Ripper # :nodoc:
1412
attr_reader :error
1513

1614
private
@@ -65,16 +63,12 @@ def on_error(mesg)
6563
remove_method :on_parse_error
6664
alias on_parse_error on_error
6765
alias compile_error on_error
68-
69-
# :startdoc:
7066
end
7167

7268
# This class mirrors the ::Ripper::SexpBuilderPP subclass of ::Ripper that
7369
# returns the same values as ::Ripper::SexpBuilder except with a couple of
7470
# niceties that flatten linked lists into arrays.
75-
class SexpBuilderPP < SexpBuilder
76-
# :stopdoc:
77-
71+
class SexpBuilderPP < SexpBuilder # :nodoc:
7872
private
7973

8074
def on_heredoc_dedent(val, width)
@@ -118,8 +112,6 @@ def on_mlhs_add_post(list, post)
118112
alias_method "on_#{event}", :_dispatch_event_push
119113
end
120114
end
121-
122-
# :startdoc:
123115
end
124116
end
125117
end

lib/prism/translation/ruby_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Translation
1919
# seattlerb/ruby_parser gem's syntax tree.
2020
class RubyParser
2121
# A prism visitor that builds Sexp objects.
22-
class Compiler < ::Prism::Compiler
22+
class Compiler < ::Prism::Compiler # :nodoc:
2323
# This is the name of the file that we are compiling. We set it on every
2424
# Sexp object that is generated, and also use it to compile `__FILE__`
2525
# nodes.

0 commit comments

Comments
 (0)