summaryrefslogtreecommitdiff
path: root/lib/racc/debugflags.rb
blob: ee34cf23149843f87e0b07eb75033c04a574bf96 (plain)
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
#--
#
#
#
# Copyright (c) 1999-2006 Minero Aoki
#
# This program is free software.
# You can distribute/modify this program under the same terms of ruby.
# see the file "COPYING".
#
#++

module Racc

  class DebugFlags
    def DebugFlags.parse_option_string(s)
      parse = rule = token = state = la = prec = conf = false
      s.split(//).each do |ch|
        case ch
        when 'p' then parse = true
        when 'r' then rule = true
        when 't' then token = true
        when 's' then state = true
        when 'l' then la = true
        when 'c' then prec = true
        when 'o' then conf = true
        else
          raise "unknown debug flag char: #{ch.inspect}"
        end
      end
      new(parse, rule, token, state, la, prec, conf)
    end

    def initialize(parse = false, rule = false, token = false, state = false,
                   la = false, prec = false, conf = false)
      @parse = parse
      @rule = rule
      @token = token
      @state = state
      @la = la
      @prec = prec
      @any = (parse || rule || token || state || la || prec)
      @status_logging = conf
    end

    attr_reader :parse
    attr_reader :rule
    attr_reader :token
    attr_reader :state
    attr_reader :la
    attr_reader :prec

    def any?
      @any
    end

    attr_reader :status_logging
  end

end