[#22684] [Bug #1247] YAML::load converts some dates into strings — Matthew Wilson <redmine@...>

Bug #1247: YAML::load converts some dates into strings

10 messages 2009/03/05

[#22725] [Bug #1253] Fix MSVC Build Issues — Charlie Savage <redmine@...>

Bug #1253: Fix MSVC Build Issues

13 messages 2009/03/07

[#22727] Moving ruby 1.9.1 forward on windows — Charlie Savage <cfis@...>

Hi everyone,

14 messages 2009/03/08

[#22731] [Bug #1255] += for large strings egrigiously slow — James Lee <redmine@...>

Bug #1255: += for large strings egrigiously slow

11 messages 2009/03/08

[#22736] Ruby 1.9.1 and tail recursion optimization — =?ISO-8859-15?Q?Wolfgang_N=E1dasi-Donner?= <ed.odanow@...>

Moin, moin!

13 messages 2009/03/08
[#22739] Re: Ruby 1.9.1 and tail recursion optimization — =?ISO-8859-15?Q?Wolfgang_N=E1dasi-Donner?= <ed.odanow@...> 2009/03/08

Wolfgang N疆asi-Donner schrieb:

[#22748] [Feature #1256] Add constant TAILRECURSION to let a program recognize if tail recursion optimization is implemented — Wolfgang Nádasi-Donner <redmine@...>

Feature #1256: Add constant TAILRECURSION to let a program recognize if tail recursion optimization is implemented

7 messages 2009/03/08

[#22803] Relegate 1.8.6 to Engine Yard, part II — Urabe Shyouhei <shyouhei@...>

Hello and sorry for my being slow for this issue. It's OK now for me to pass

21 messages 2009/03/10

[#22812] [Bug #1261] cross-compiling Ruby extensions using mkmf doesn't fully respect DESTDIR — Daniel Golle <redmine@...>

Bug #1261: cross-compiling Ruby extensions using mkmf doesn't fully respect DESTDIR

8 messages 2009/03/10

[#22892] Ruby Time — valodzka <valodzka@...>

Got tired of current ruby Time limitation, I have written this -

24 messages 2009/03/14
[#22949] Re: Ruby Time — Tanaka Akira <akr@...> 2009/03/19

In article <9e19ed87-9d12-4f98-af3c-bd49a71b0bd4@p11g2000yqe.googlegroups.com>,

[#22974] Re: Ruby Time — valodzka <valodzka@...> 2009/03/20

[#22977] Re: Ruby Time — Urabe Shyouhei <shyouhei@...> 2009/03/20

valodzka wrote:

[#22981] Re: Ruby Time — valodzka <valodzka@...> 2009/03/21

> I bet you'll get tired of updating that database. There's a major difference

[#22893] [Feature #1291] O_CLOEXEC flag missing for Kernel::open — David Martin <redmine@...>

Feature #1291: O_CLOEXEC flag missing for Kernel::open

10 messages 2009/03/15

[#22939] [Bug #1303] A name considered a local variable on RHS of an assignment that defines it — Tomas Matousek <redmine@...>

Bug #1303: A name considered a local variable on RHS of an assignment that defines it

8 messages 2009/03/19

[#23063] [Bug #1332] Reading file on Windows is 500x slower then with previous Ruby version — Damjan Rems <redmine@...>

Bug #1332: Reading file on Windows is 500x slower then with previous Ruby version

11 messages 2009/03/30

[#23075] [Bug #1336] Change in string representation of Floats — Brian Ford <redmine@...>

Bug #1336: Change in string representation of Floats

37 messages 2009/03/31
[#23179] [Bug #1336] Change in string representation of Floats — Roger Pack <redmine@...> 2009/04/11

Issue #1336 has been updated by Roger Pack.

[#23181] Re: [Bug #1336] Change in string representation of Floats — Brent Roman <brent@...> 2009/04/11

[#23186] Re: [Bug #1336] Change in string representation of Floats — Yukihiro Matsumoto <matz@...> 2009/04/12

Hi,

[#23187] Re: [Bug #1336] Change in string representation of Floats — Brent Roman <brent@...> 2009/04/13

[#23188] Re: [Bug #1336] Change in string representation of Floats — Yukihiro Matsumoto <matz@...> 2009/04/13

Hi,

[ruby-core:22783] Tool to extract non-RIPPER content from parse.y

From: daz <dooby@...10.karoo.co.uk>
Date: 2009-03-09 17:46:08 UTC
List: ruby-core #22783
* parse.y used to be so easy to read ;)

Could this, or something like this, go into <source>/sample/
 where exyacc.rb is distributed?

It's not really a RIPPER tool because it does nothing to help that.

It may look ugly but the FSM I wrote is 3 times the line count. :)

I wouldn't want anyone else to have to waste time writing this.

Use as you wish - no need to ask.


daz


#---------------------------  unRIPPER.rb
#
# Strip #IF/ELSE/ENDIF RIPPER code (as #undef RIPPER)
#  and all RIPPER pre-processing blocks from parse.y
#
# Written in 'perlish' with inspiration from:
#      <RubySource>/sample/exyacc.rb
#
# daz - 2009/03/09 (12:00) - Free of copyright
#

require 'optparse'

### ==========

Ecc  = "\x10"  # Comment End Code (temp)
Hcc  = "\x11"  # Comment Control Code (replaces '#' within C-comment)
IFcc = "\x12"  # #IF(*)  Control Code

IF_RE = 
/^(?!\n)\s*#\s*#{IFcc}(N?DEF)?\s+([^\n]*?)\n^([^#{IFcc}]*?\n)^(?!\n)\s*#\s*END#{IFcc}[^\n]*?\n/mi

# RIPPER pre-processing regex (for '/*%%%*/' and '/*%c%*/' blocks)
#  ( ref: <RubyDir>/ext/ripper/tools/preproc.rb )
RIP_RE = %r{^\s*?/\*%(%|c)%\*/.*?\r?\n(.*?)^\s*/\*%(c?).*?%\*/.*?\r?\n}m
#                [   ( 1 )   ]       ^(_2_)^   [   (3)]   [  ]       

### ==========

def run(input, output)
  y_source = nil
  File.open(input) do |fin|
    y_source = fin.read
  end

  # Make all '*/' a single character to simplify next regex
  y_source.gsub!(%r{\*/}, Ecc)
  #
  # Temporarily substitute '#'-within-comment by Hcc code
  #  to prevent disruption of real #IF blocks.
  y_source.gsub!(%r</\*[^#{Ecc}]*?#{Ecc}>) do |cm|
    cm.gsub!(/(^\s*?)#(\s*IF|ELIF|ELSE|ENDIF)/i, "\\1#{Hcc}\\2")
    cm.chop! << '*/'  # restore '*/' (from Ecc control code)
  end

  # Temporarily replace all 'IF's and END'IF's with a control code
  #  so that nested blocks are correctly grouped.
  y_source.gsub!(/^(\s*)#(\s*)IF(N?DEF)?(\s)/i, "\\1#\\2#{IFcc}\\3\\4")
  y_source.gsub!(/^(\s*)#(\s*END)IF(\s)/i,      "\\1#\\2#{IFcc}\\3")


  # Process #IF/#ELSE/#ENDIF blocks
  rep = true
  rep = y_source.gsub!(IF_RE) do |if_blk|
    m0, df, dfid, ieblk = [$&, ($1 && $1.downcase == 'def'), $2, $3]
    if true and dfid == 'RIPPER'
      iblk, eblk = ieblk.split(/(?!\n)^\s*#\s*ELSE(?>.*?\n)/i)
      (df ? eblk : iblk)  #IF def : ndef RIPPER
    else
      m0.gsub!("#{IFcc}", 'if') # copy entire non-RIPPER IF/ENDIF
    end
  end while rep

  # Restore all '#'-within-comment
  y_source.gsub!("#{Hcc}", '/*?*/')


  ## Remove RIPPER pre-processing directives
  y_source.gsub!(RIP_RE) do
    m0, m1, m2, m3 = [$&, $1, $2, $3]
    if m1 == 'c'
      if m3 != 'c' or m2 !~ /\A\s*\z/
        puts  '~~'*30,  m0,  ' ~'*30
        p [m1, m2, m3], m0
        puts '^^'*30
        raise '? FIXME ?'
      end
      m2 = ''
    end
    m2
  end

  yield y_source if block_given?

  if output
    File.open(output, 'w') do |fout|
      fout.write y_source
    end
  else
    STDOUT.write y_source
  end
end


output = nil
parser = OptionParser.new
parser.banner = "Usage: #{File.basename($0)} [--output=PATH] <parse.y>"
parser.on('--output=PATH', 'The output file - defaults to STDOUT') do |path|
  output = path.gsub("\\", '/')
end
parser.on('--help', 'Prints this message and quits.') do
  puts parser.help
  exit true
end
begin
  parser.parse!
rescue OptionParser::ParseError => err
  STDERR.puts err.message
  STDERR.puts parser.help
  exit false
end
unless ARGV.size == 1
  p ARGV
  abort "Wrong number of arguments (#{ARGV.size} for 1)"
end

input = ARGV[0].gsub("\\", '/')

out_name = output || 'STDOUT'
STDERR.puts 'Input : '  << input
STDERR.puts 'Output: '  << out_name
raise '^ ? Oops ? ^' if output == input

run(input, output) do |y_source|
  # --- Any custom processing, here ---
  STDERR.puts 'Writing output file ' << out_name
  #     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
end
#--------------------------- END



In This Thread

Prev Next