Permalink
Browse files

- removing a bunch of :nodoc:

  • Loading branch information...
1 parent c3148da commit 48704a4cebe9880c236f9abfafad55633faa5b34 @kschiess committed May 24, 2012
View
8 experiments/heredoc.rb
@@ -29,7 +29,7 @@ def initialize(parslet, name)
@parslet, @name = parslet, name
end
- def try(source, context) # :nodoc:
+ def try(source, context)
parslet.try(source, context).tap { |result|
set_binding(context, name,
flatten(result.result))
@@ -43,7 +43,7 @@ def set_binding(context, name, value)
context.instance_variable_set('@bindings', b)
end
- def to_s_inner(prec) # :nodoc:
+ def to_s_inner(prec)
parslet.to_s(prec)
end
end
@@ -55,7 +55,7 @@ def initialize(parslet, name)
@parslet, @name = parslet, name
end
- def try(source, context) # :nodoc:
+ def try(source, context)
parslet.try(source, context).tap { |result|
unless result.error?
value = flatten(result.result)
@@ -74,7 +74,7 @@ def bound_value(context, name)
b[name]
end
- def to_s_inner(prec) # :nodoc:
+ def to_s_inner(prec)
parslet.to_s(prec)
end
end
View
2 lib/parslet.rb
@@ -49,7 +49,7 @@ module Parslet
# Extends classes that include Parslet with the module
# {Parslet::ClassMethods}.
#
- def self.included(base) # :nodoc:
+ def self.included(base)
base.extend(ClassMethods)
end
View
2 lib/parslet/atoms.rb
@@ -5,7 +5,7 @@ module Parslet::Atoms
# The precedence module controls parenthesis during the #inspect printing
# of parslets. It is not relevant to other aspects of the parsing.
#
- module Precedence # :nodoc:
+ module Precedence
prec = 0
BASE = (prec+=1) # everything else
LOOKAHEAD = (prec+=1) # &SOMETHING
View
6 lib/parslet/atoms/alternative.rb
@@ -26,11 +26,11 @@ def initialize(*alternatives)
# Don't construct a hanging tree of Alternative parslets, instead store them
# all here. This reduces the number of objects created.
#+++
- def |(parslet) # :nodoc:
+ def |(parslet)
self.class.new(*@alternatives + [parslet])
end
- def try(source, context) # :nodoc:
+ def try(source, context)
errors = alternatives.map { |a|
success, value = result = a.apply(source, context)
return result if success
@@ -44,7 +44,7 @@ def try(source, context) # :nodoc:
end
precedence ALTERNATE
- def to_s_inner(prec) # :nodoc:
+ def to_s_inner(prec)
alternatives.map { |a| a.to_s(prec) }.join(' / ')
end
end
View
8 lib/parslet/atoms/base.rb
@@ -74,7 +74,7 @@ def setup_and_apply(source, error_reporter)
# Calls the #try method of this parslet. In case of a parse error, apply
# leaves the source in the state it was before the attempt.
#+++
- def apply(source, context) # :nodoc:
+ def apply(source, context)
old_pos = source.pos
success, value = result = context.try_with_cache(self, source)
@@ -96,18 +96,18 @@ def try(source, context)
# Debug printing - in Treetop syntax.
#
- def self.precedence(prec) # :nodoc:
+ def self.precedence(prec)
define_method(:precedence) { prec }
end
precedence BASE
- def to_s(outer_prec=OUTER) # :nodoc:
+ def to_s(outer_prec=OUTER)
if outer_prec < precedence
"("+to_s_inner(precedence)+")"
else
to_s_inner(precedence)
end
end
- def inspect # :nodoc:
+ def inspect
to_s(OUTER)
end
private
View
13 lib/parslet/atoms/can_flatten.rb
@@ -20,7 +20,7 @@ module CanFlatten
# naming something using <code>.as(...)</code>. It changes the folding
# semantics of repetition.
#
- def flatten(value, named=false) # :nodoc:
+ def flatten(value, named=false)
# Passes through everything that isn't an array of things
return value unless value.instance_of? Array
@@ -53,12 +53,15 @@ def foldl(list, &block)
# Flatten results from a sequence of parslets.
#
- def flatten_sequence(list) # :nodoc:
+ # @api private
+ #
+ def flatten_sequence(list)
foldl(list.compact) { |r, e| # and then merge flat elements
merge_fold(r, e)
}
end
- def merge_fold(l, r) # :nodoc:
+ # @api private
+ def merge_fold(l, r)
# equal pairs: merge. ----------------------------------------------------
if l.class == r.class
if l.is_a?(Hash)
@@ -96,7 +99,9 @@ def merge_fold(l, r) # :nodoc:
# the results, we want to leave an empty list alone - otherwise it is
# turned into an empty string.
#
- def flatten_repetition(list, named) # :nodoc:
+ # @api private
+ #
+ def flatten_repetition(list, named)
if list.any? { |e| e.instance_of?(Hash) }
# If keyed subtrees are in the array, we'll want to discard all
# strings inbetween. To keep them, name them.
View
10 lib/parslet/atoms/entity.rb
@@ -10,14 +10,14 @@
#
class Parslet::Atoms::Entity < Parslet::Atoms::Base
attr_reader :name, :block
- def initialize(name, &block) # :nodoc:
+ def initialize(name, &block)
super()
@name = name
@block = block
end
- def try(source, context) # :nodoc:
+ def try(source, context)
parslet.apply(source, context)
end
@@ -27,16 +27,16 @@ def parslet
}
end
- def to_s_inner(prec) # :nodoc:
+ def to_s_inner(prec)
name.to_s.upcase
end
- def error_tree # :nodoc:
+ def error_tree
parslet.error_tree
end
private
- def raise_not_implemented # :nodoc:
+ def raise_not_implemented
trace = caller.reject {|l| l =~ %r{#{Regexp.escape(__FILE__)}}} # blatantly stolen from dependencies.rb in activesupport
exception = NotImplementedError.new("rule(#{name.inspect}) { ... } returns nil. Still not implemented, but already used?")
exception.set_backtrace(trace)
View
6 lib/parslet/atoms/lookahead.rb
@@ -8,7 +8,7 @@ class Parslet::Atoms::Lookahead < Parslet::Atoms::Base
attr_reader :positive
attr_reader :bound_parslet
- def initialize(bound_parslet, positive=true) # :nodoc:
+ def initialize(bound_parslet, positive=true)
super()
# Model positive and negative lookahead by testing this flag.
@@ -21,7 +21,7 @@ def initialize(bound_parslet, positive=true) # :nodoc:
}
end
- def try(source, context) # :nodoc:
+ def try(source, context)
pos = source.pos
success, value = bound_parslet.apply(source, context)
@@ -41,7 +41,7 @@ def try(source, context) # :nodoc:
end
precedence LOOKAHEAD
- def to_s_inner(prec) # :nodoc:
+ def to_s_inner(prec)
char = positive ? '&' : '!'
"#{char}#{bound_parslet.to_s(prec)}"
View
6 lib/parslet/atoms/re.rb
@@ -9,7 +9,7 @@
#
class Parslet::Atoms::Re < Parslet::Atoms::Base
attr_reader :match, :re
- def initialize(match) # :nodoc:
+ def initialize(match)
super()
@match = match.to_s
@@ -20,7 +20,7 @@ def initialize(match) # :nodoc:
}
end
- def try(source, context) # :nodoc:
+ def try(source, context)
return succ(source.consume(1)) if source.matches?(re)
# No string could be read
@@ -31,7 +31,7 @@ def try(source, context) # :nodoc:
return context.err(self, source, @error_msgs[:failed])
end
- def to_s_inner(prec) # :nodoc:
+ def to_s_inner(prec)
match.inspect[1..-2]
end
end
View
4 lib/parslet/atoms/repetition.rb
@@ -19,7 +19,7 @@ def initialize(parslet, min, max, tag=:repetition)
}
end
- def try(source, context) # :nodoc:
+ def try(source, context)
occ = 0
accum = [@tag] # initialize the result array with the tag (for flattening)
start_pos = source.pos
@@ -53,7 +53,7 @@ def try(source, context) # :nodoc:
end
precedence REPETITION
- def to_s_inner(prec) # :nodoc:
+ def to_s_inner(prec)
minmax = "{#{min}, #{max}}"
minmax = '?' if min == 0 && max == 1
View
6 lib/parslet/atoms/sequence.rb
@@ -15,11 +15,11 @@ def initialize(*parslets)
}
end
- def >>(parslet) # :nodoc:
+ def >>(parslet)
self.class.new(* @parslets+[parslet])
end
- def try(source, context) # :nodoc:
+ def try(source, context)
succ([:sequence]+parslets.map { |p|
success, value = p.apply(source, context)
@@ -32,7 +32,7 @@ def try(source, context) # :nodoc:
end
precedence SEQUENCE
- def to_s_inner(prec) # :nodoc:
+ def to_s_inner(prec)
parslets.map { |p| p.to_s(prec) }.join(' ')
end
end
View
4 lib/parslet/atoms/str.rb
@@ -17,7 +17,7 @@ def initialize(str)
}
end
- def try(source, context) # :nodoc:
+ def try(source, context)
return succ(source.consume(@len)) if source.matches?(str)
# Failures:
@@ -30,7 +30,7 @@ def try(source, context) # :nodoc:
[@error_msgs[:failed], source.consume(@len)], error_pos)
end
- def to_s_inner(prec) # :nodoc:
+ def to_s_inner(prec)
"'#{str}'"
end
end
View
4 lib/parslet/cause.rb
@@ -71,7 +71,7 @@ def ascii_tree
end
private
- def recursive_ascii_tree(node, stream, curved) # :nodoc:
+ def recursive_ascii_tree(node, stream, curved)
append_prefix(stream, curved)
stream.puts node.to_s
@@ -81,7 +81,7 @@ def recursive_ascii_tree(node, stream, curved) # :nodoc:
recursive_ascii_tree(child, stream, curved + [last_child])
end
end
- def append_prefix(stream, curved) # :nodoc:
+ def append_prefix(stream, curved)
return if curved.size < 2
curved[1..-2].each do |c|
stream.print c ? " " : "| "
View
8 lib/parslet/export.rb
@@ -68,7 +68,7 @@ def visit_alternative(alternatives)
# A helper class that formats Citrus and Treetop grammars as a string.
#
- class PrettyPrinter # :nodoc:
+ class PrettyPrinter
attr_reader :visitor
def initialize(visitor_klass)
@visitor = visitor_klass.new(self)
@@ -78,7 +78,7 @@ def initialize(visitor_klass)
# configured in initialize. Returns the string representation of the
# Citrus or Treetop grammar.
#
- def pretty_print(name, parslet) # :nodoc:
+ def pretty_print(name, parslet)
output = "grammar #{name}\n"
output << rule('root', parslet)
@@ -111,7 +111,7 @@ def rule(name, parslet)
# Whenever the visitor encounters an rule in a parslet, it defers the
# pretty printing of the rule by calling this method.
#
- def deferred(name, content) # :nodoc:
+ def deferred(name, content)
@todo ||= []
@todo << [name, content]
end
@@ -120,7 +120,7 @@ def deferred(name, content) # :nodoc:
# transforms some of the things that Ruby allows into other patterns. If
# there is collision, we will not detect it for now.
#
- def mangle_name(str) # :nodoc:
+ def mangle_name(str)
str.to_s.sub(/\?$/, '_p')
end
end
View
2 lib/parslet/expression.rb
@@ -6,8 +6,6 @@
# This can be viewed as an extension to parslet and might even be hosted in
# its own gem one fine day.
#
-# NOT FINISHED & EXPERIMENTAL
-#
class Parslet::Expression
include Parslet
View
4 lib/parslet/expression/treetop.rb
@@ -1,5 +1,5 @@
class Parslet::Expression::Treetop
- class Parser < Parslet::Parser # :nodoc:
+ class Parser < Parslet::Parser
root(:expression)
rule(:expression) { alternatives }
@@ -69,7 +69,7 @@ def spaced(str)
end
end
- class Transform < Parslet::Transform # :nodoc:
+ class Transform < Parslet::Transform
rule(:repetition => simple(:rep), :sign => simple(:sign)) {
min = sign=='+' ? 1 : 0
View
6 lib/parslet/parser.rb
@@ -57,15 +57,15 @@ def root(name)
end
end
- def try(source, context) # :nodoc:
+ def try(source, context)
root.try(source, context)
end
- def error_tree # :nodoc:
+ def error_tree
root.error_tree
end
- def to_s_inner(prec) # :nodoc:
+ def to_s_inner(prec)
root.to_s(prec)
end
end
View
4 lib/parslet/pattern.rb
@@ -63,7 +63,7 @@ def element_match(tree, exp, bindings)
end
end
- def element_match_binding(tree, exp, bindings) # :nodoc:
+ def element_match_binding(tree, exp, bindings)
var_name = exp.variable_name
# TODO test for the hidden :_ feature.
@@ -77,7 +77,7 @@ def element_match_binding(tree, exp, bindings) # :nodoc:
return true
end
- def element_match_ary_single(sequence, exp, bindings) # :nodoc:
+ def element_match_ary_single(sequence, exp, bindings)
return false if sequence.size != exp.size
return sequence.zip(exp).all? { |elt, subexp|
View
6 lib/parslet/pattern/binding.rb
@@ -5,7 +5,7 @@
# It defines the most permissive kind of bind, the one that matches any subtree
# whatever it looks like.
#
-class Parslet::Pattern::SubtreeBind < Struct.new(:symbol) # :nodoc:
+class Parslet::Pattern::SubtreeBind < Struct.new(:symbol)
def variable_name
symbol
end
@@ -33,15 +33,15 @@ def bind_type_name
# Binds a symbol to a simple subtree, one that is not either a sequence of
# elements or a collection of attributes.
#
-class Parslet::Pattern::SimpleBind < Parslet::Pattern::SubtreeBind # :nodoc:
+class Parslet::Pattern::SimpleBind < Parslet::Pattern::SubtreeBind
def can_bind?(subtree)
not [Hash, Array].include?(subtree.class)
end
end
# Binds a symbol to a sequence of simple leafs ([element1, element2, ...])
#
-class Parslet::Pattern::SequenceBind < Parslet::Pattern::SubtreeBind # :nodoc:
+class Parslet::Pattern::SequenceBind < Parslet::Pattern::SubtreeBind
def can_bind?(subtree)
subtree.kind_of?(Array) &&
(not subtree.any? { |el| [Hash, Array].include?(el.class) })
View
6 lib/parslet/slice.rb
@@ -98,10 +98,4 @@ def to_f
def inspect
str.inspect << "@#{offset}"
end
-end
-
-# Raised when trying to do an operation on slices that cannot succeed, like
-# adding non-adjacent slices. See Parslet::Slice.
-#
-class Parslet::InvalidSliceOperation < StandardError
end
View
4 lib/parslet/source/line_cache.rb
@@ -3,7 +3,7 @@
class Parslet::Source
# A cache for line start positions.
#
- class LineCache # :nodoc:
+ class LineCache
def initialize
# Stores line endings as a simple position number. The first line always
# starts at 0; numbers beyond the biggest entry are on any line > size,
@@ -59,7 +59,7 @@ def scan_for_line_endings(start_pos, buf)
# [10, 20, 30]
# # would describe [0, 10], (10, 20], (20, 30]
#
- module RangeSearch # :nodoc:
+ module RangeSearch
def find_mid(left, right)
# NOTE: Jonathan Hinkle reported that when mathn is required, just
# dividing and relying on the integer truncation is not enough.
View
12 lib/parslet/transform.rb
@@ -131,12 +131,12 @@ def rule(expression, &block)
# Allows accessing the class' rules
#
- def rules # :nodoc:
+ def rules
@__transform_rules || []
end
end
- def initialize(&block) # :nodoc:
+ def initialize(&block)
@rules = []
if block
@@ -203,11 +203,11 @@ def call_on_match(bindings, block)
# Allow easy access to all rules, the ones defined in the instance and the
# ones predefined in a subclass definition.
#
- def rules # :nodoc:
+ def rules
self.class.rules + @rules
end
- def transform_elt(elt, context) # :nodoc:
+ def transform_elt(elt, context)
rules.each do |pattern, block|
if bindings=pattern.match(elt, context)
# Produces transformed value
@@ -218,13 +218,13 @@ def transform_elt(elt, context) # :nodoc:
# No rule matched - element is not transformed
return elt
end
- def recurse_hash(hsh, ctx) # :nodoc:
+ def recurse_hash(hsh, ctx)
hsh.inject({}) do |new_hsh, (k,v)|
new_hsh[k] = apply(v, ctx)
new_hsh
end
end
- def recurse_array(ary, ctx) # :nodoc:
+ def recurse_array(ary, ctx)
ary.map { |elt| apply(elt, ctx) }
end
end
View
2 lib/parslet/transform/context.rb
@@ -10,7 +10,7 @@
# a # => :b
# end
#
-class Parslet::Transform::Context < BlankSlate # :nodoc:
+class Parslet::Transform::Context < BlankSlate
reveal :methods
reveal :respond_to?
reveal :inspect

0 comments on commit 48704a4

Please sign in to comment.