Skip to content

Commit

Permalink
Regenerate literals with updated kpeg
Browse files Browse the repository at this point in the history
This kpeg does not emit trailing whitespace which will prevent nobu from
getting free commits when he cleans up whitespace in ruby trunk.
  • Loading branch information
drbrain committed Sep 18, 2013
1 parent 3210043 commit fca27d7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
27 changes: 15 additions & 12 deletions lib/rdoc/markdown/literals_1_8.rb
Expand Up @@ -3,7 +3,7 @@
##
# Provides Literals appropriate for your ruby version.
#--
# This set of literals is for ruby 1.8 regular expressions.
# This set of literals is for Ruby 1.8 regular expressions.
class RDoc::Markdown::Literals
# :stopdoc:

Expand All @@ -19,8 +19,7 @@ def initialize(str, debug=false)
# Prepares for parsing +str+. If you define a custom initialize you must
# call this method before #parse
def setup_parser(str, debug=false)
@string = str
@pos = 0
set_string str, 0
@memoizations = Hash.new { |h,k| h[k] = {} }
@result = nil
@failed_rule = nil
Expand All @@ -33,7 +32,6 @@ def setup_parser(str, debug=false)
attr_reader :failing_rule_offset
attr_accessor :result, :pos


def current_column(target=pos)
if c = string.rindex("\n", target-1)
return target - c - 1
Expand Down Expand Up @@ -67,6 +65,13 @@ def get_text(start)
@string[start..@pos-1]
end

# Sets the string and current parsing position for the parser.
def set_string string, pos
@string = string
@string_size = string ? string.size : 0
@pos = pos
end

def show_pos
width = 10
if @pos < width
Expand Down Expand Up @@ -173,19 +178,19 @@ def scan(reg)
return nil
end

if "".respond_to? :getbyte
if "".respond_to? :ord
def get_byte
if @pos >= @string.size
if @pos >= @string_size
return nil
end

s = @string.getbyte @pos
s = @string[@pos].ord
@pos += 1
s
end
else
def get_byte
if @pos >= @string.size
if @pos >= @string_size
return nil
end

Expand Down Expand Up @@ -234,8 +239,7 @@ def external_invoke(other, rule, *args)
old_pos = @pos
old_string = @string

@pos = other.pos
@string = other.string
set_string other.string, other.pos

begin
if val = __send__(rule, *args)
Expand All @@ -246,8 +250,7 @@ def external_invoke(other, rule, *args)
end
val
ensure
@pos = old_pos
@string = old_string
set_string old_string, old_pos
end
end

Expand Down
25 changes: 14 additions & 11 deletions lib/rdoc/markdown/literals_1_9.rb
Expand Up @@ -23,8 +23,7 @@ def initialize(str, debug=false)
# Prepares for parsing +str+. If you define a custom initialize you must
# call this method before #parse
def setup_parser(str, debug=false)
@string = str
@pos = 0
set_string str, 0
@memoizations = Hash.new { |h,k| h[k] = {} }
@result = nil
@failed_rule = nil
Expand All @@ -37,7 +36,6 @@ def setup_parser(str, debug=false)
attr_reader :failing_rule_offset
attr_accessor :result, :pos


def current_column(target=pos)
if c = string.rindex("\n", target-1)
return target - c - 1
Expand Down Expand Up @@ -71,6 +69,13 @@ def get_text(start)
@string[start..@pos-1]
end

# Sets the string and current parsing position for the parser.
def set_string string, pos
@string = string
@string_size = string ? string.size : 0
@pos = pos
end

def show_pos
width = 10
if @pos < width
Expand Down Expand Up @@ -177,19 +182,19 @@ def scan(reg)
return nil
end

if "".respond_to? :getbyte
if "".respond_to? :ord
def get_byte
if @pos >= @string.size
if @pos >= @string_size
return nil
end

s = @string.getbyte @pos
s = @string[@pos].ord
@pos += 1
s
end
else
def get_byte
if @pos >= @string.size
if @pos >= @string_size
return nil
end

Expand Down Expand Up @@ -238,8 +243,7 @@ def external_invoke(other, rule, *args)
old_pos = @pos
old_string = @string

@pos = other.pos
@string = other.string
set_string other.string, other.pos

begin
if val = __send__(rule, *args)
Expand All @@ -250,8 +254,7 @@ def external_invoke(other, rule, *args)
end
val
ensure
@pos = old_pos
@string = old_string
set_string old_string, old_pos
end
end

Expand Down

0 comments on commit fca27d7

Please sign in to comment.