This file is indexed.

/usr/bin/racc2y is in racc 1.4.5-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#!/usr/bin/ruby1.8
#
# r2yacc  --  racc to yacc converter
#
# Copyright (c) 1999-2005 Minero Aoki
#
# This program is feee software.
# You can distribute/modify this program under the terms of
# the GNU LGPL, Lesser General Public License version 2.1.
# For details of the LGPL, see the file "COPYING".
#

require 'optparse'
require 'racc/compiler'

RACC2Y_VERSION = '1.1.1'

def usage(stat = 0)
  $stderr.puts 'wrong option' unless stat == 0
  (stat == 0 ? $stdout : $stderr).print(<<EOS)
Usage: racc2y [-AHIF] [-o outfile] raccfile
    -o <file>  output file name  [y.<inputfile>]
    -A         did not output actions
    -H         output 'header'
    -I         output 'inner'
    -F         output 'footer'
EOS
  exit stat
end

def main
  op = OptionParser.new do |op|
    op.banner = 'Usage: racc2y [-AHIF] [-o outfile] raccfile'

    op.on('-o <file>', 'output file name  [y.<inputfile>]') do |file|
      $OPT_o = file
    end
    op.on('-A', 'did not output actions') do
      $OPT_A = true
    end
    op.on('-H', 'output \'header\'') do
      $OPT_H = true
    end
    op.on('-I', 'output \'inner\'') do
      $OPT_I = true
    end
    op.on('-F', 'output \'footer\'') do
      $OPT_F = true
    end
    op.on('--help', 'print this message and quit') do
      $OPT_help = true
    end
    op.on('--version', 'print version and quit') do
      $OPT_version = true
    end
    op.on('--copyright', 'print copyright and quit') do
      $OPT_copyright = true
    end

    begin
      op.parse!
    rescue
      usage(1)
    end
  end

  if $OPT_version
    puts "racc2y version #{RACC2Y_VERSION}"
    exit 0
  end
  if $OPT_copyright
    puts 'Copyright (c) 1999-2003 Minero Aoki'
    exit 0
  end
  usage 0 if $OPT_help
  usage 1 unless ARGV.size == 1

  fname = ARGV[0]
  outf = $OPT_o || 'y.' + File.basename(fname)
  begin
    str = nil
    File.open(fname) {|f| str = f.read }
  rescue Errno::ENOENT
    $stderr.puts "#{File.basename $0}: no such file: #{fname}"
    exit 1
  end
  conv = Converter.new
  conv.parse str, fname
  File.open(outf, 'w') {|f|
    conv.output(f)
  }
end

class Converter

  def initialize
    @symboltable = Racc::SymbolTable.new(self)
    @ruletable   = Racc::RuleTable.new(self)
    @parser      = Racc::GrammarFileParser.new(self)
    @result_var = true
  end

  attr_reader :ruletable
  attr_reader :symboltable
  attr_reader :parser

  attr_accessor :result_var

  def debug()   false end
  def verbose() false end
  def d_parse() false end
  def d_token() false end
  def d_rule()  false end
  def d_state() false end

  def parse(str, fname)
    @fname = fname
    @parser.parse str
    @ruletable.init
    u = Racc::GrammarFileParser.get_usercode(fname)
    @header, = *u['header']
    @inner,  = *u['inner']
    @footer, = *u['footer']
  end

  def output(f)
    rule = t = nil

    f.print(<<EOS)
/*

    generated from #{@fname} by racc2y version #{RACC2Y_VERSION}

*/

EOS
    if $OPT_H and @header
      f.puts '%{'
      f.puts '/*---- header ----*/'
      f.puts @header
      f.puts '%}'
      f.puts
    end

    output_defs f
    output_grammer f

    if $OPT_I and @inner
      f.puts
      f.puts '/*---- inner ----*/'
      f.puts
      f.puts @inner
    end
    if $OPT_F and @footer
      f.puts
      f.puts '/*---- footer ----*/'
      f.puts
      f.puts @footer
    end
  end

  def output_defs(f)
    output_token f
    f.puts
    prec = getprecs
    unless prec.empty?
      output_prec f, prec
    end
  end

  def output_token(f)
    f.puts '/* tokens */'
    anc = @symboltable.anchor
    err = @symboltable.error
    total = 6
    f.print '%token'
    @symboltable.each do |t|
      next unless t.terminal?
      next if t.dummy?
      next if t == err
      next if t == anc

      unless String === t.value
        if total > 60
          f.print "\n     "
          total = 0
        end
        total += f.write(" #{tok t}")
      end
    end
    f.puts
  end

  def getprecs
    prec = []
    @symboltable.each do |t|
      next unless t.prec
      if a = prec[t.prec]
        a.push t
      else
        prec[t.prec] = [t.assoc, t]
      end
    end

    prec
  end

  def output_prec(f, tab)
    f.puts '/* precedance table */'
    tab.each do |a|
      if a
        f.printf '%%%-8s', a.shift.id2name.downcase
        a.each do |t|
          f.print ' ', tok(t)
        end
        f.puts
      end
    end
    f.puts
  end


  def output_grammer(f)
    f.puts '%%'

    targ   = nil
    indent = 10
    fmt    = "\n%-10s:"
    emb    = []

    @ruletable.each do |rule|
      if rule.target.dummy?
        emb.push rule.action if rule.action
        next
      end

      if rule.target == targ
        f.print ' ' * indent, '|'
      else
        targ = rule.target
        f.printf fmt, tok(targ)
      end
      rule.symbols.each do |t|
        if t.dummy?   # target of dummy rule for embedded action
          f.puts
          output_act f,
                     emb.shift,
                     indent
          f.print ' ' * (indent + 1)
        else
          f.print ' ', tok(t)
        end
      end
      if rule.specified_prec
        f.print ' %prec ', tok(rule.specified_prec)
      end
      f.puts
      if rule.action
        output_act f, rule.action, indent
      end
    end

    f.puts "\n%%"
  end

  def output_act(f, str, indent)
    f.print ' ' * (indent + 4), "{\n"
    f.print ' ' * (indent + 6), str, "\n" unless $OPT_A
    f.print ' ' * (indent + 4), "}\n"
  end

  def tok(t)
    s = t.to_s
    s.gsub '"', "'"
  end

end


main