Class: RubyLexX

Inherits:
RubyLex
  • Object
show all
Defined in:
lib/gettext/parser/ruby.rb

Overview

:nodoc: all

Instance Method Summary collapse

Instance Method Details

#parseObject

Parser#parse resemlbes RubyLex#lex



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
# File 'lib/gettext/parser/ruby.rb', line 20

def parse
  until (  (tk = token).kind_of?(RubyToken::TkEND_OF_SCRIPT) && !@continue or tk.nil?  )
    s = get_readed
    if RubyToken::TkSTRING === tk
      def tk.value
        @value
      end

      def tk.value=(s)
        @value = s
      end

      if @here_header
        s = s.sub(/\A.*?\n/, '').sub(/^.*\n\Z/, '')
      else
        begin
          s = eval(s)
        rescue Exception
          # Do nothing.
        end
      end

      tk.value = s
    end

    if $DEBUG
      if tk.is_a? TkSTRING
        $stderr.puts("#{tk}: #{tk.value}")
      elsif tk.is_a? TkIDENTIFIER
        $stderr.puts("#{tk}: #{tk.name}")
      else
        $stderr.puts(tk)
      end
    end

    yield tk
  end
  return nil
end