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 
     | 
    
      # File 'lib/mof/scanner.rb', line 27
def fill_queue
  if @file.closed? || @file.eof?
    unless @file.closed?
      @file.close unless @file == $stdin
    end
    unless @fstack.empty?
	@file, @name, @lineno, @iconv, $/, @result = @fstack.pop
      return fill_queue
    end
    @q.push [false, false]
    return false
  end
  @line = @file.gets
  return true unless @line
  @lineno += 1
  @line.chomp!    if @iconv
    if String.method_defined? encode
      @line = @line.encode( "ISO-8859-1", @iconv )
    else
      @line = Iconv.conv( "ISO-8859-1", @iconv, @line )
    end
  end
  scanner = StringScanner.new(@line)
  until scanner.eos?
    if @in_comment
	if scanner.scan(%r{.*\*/})
 @in_comment = false
	else
 break
	end
    end
    case
    when scanner.scan(/\s+/)
	next        	
    when m = scanner.scan(/\n+/)
	@lineno += m.size
	next        
    when m = scanner.scan(%r{/\*})
      @in_comment = true
	
    when m = scanner.scan(%r{//.*})
	next        	
    when m = scanner.scan(%r{[(){}\[\],;\$#:=]})
	@q.push [m, m]
            when m = scanner.scan(%r{(\+|-)?(0x|0X)([0123456789]|[abcdef]|[ABCDEF])+})
	@q.push [:hexValue, m.to_i]
        when m = scanner.scan(%r{(\+|-)?0[01234567]+})
	@q.push [:octalValue, m.to_i]
        when m = scanner.scan(%r{(\+|-)?(0|1)(b|B)})
	@q.push [:binaryValue, m.to_i]
	
        
    when m = scanner.scan(%r{(\+|-)?\d*\.\d+})
	@q.push [:realValue, m.to_f]
    when m = scanner.scan(%r{[123456789]\d*})
	@q.push [:positiveDecimalValue, m.to_i]
   
            when m = scanner.scan(%r{(\+|-)?\d+})
	@q.push [:decimalValue, m.to_i]
        
    when m = scanner.scan(%r{\'([^\'])\'})
	@q.push [:charValue, scanner[1]]
        
        when m = scanner.scan(%r{\"(([^\\\"]|(\\[nrt\(\)/\"\'\\]))*)\"})
	@q.push [:stringValue, scanner[1]]
    when m = scanner.scan(%r{\w+})
	case m.downcase
	when "amended" then @q.push [:AMENDED, m]
	when "any" then @q.push [:ANY, m]
	when "as" then @q.push [:AS, nil]
	when "association" then @q.push [:ASSOCIATION, m]
	when "class" then @q.push( [:CLASS, m] )
	when "disableoverride" then @q.push [:DISABLEOVERRIDE, m]
	when "void" then @q.push [:DT_VOID, CIM::Type.new(:void)]
	when "boolean" then @q.push [:DT_BOOLEAN, CIM::Type.new(:boolean)]
	when "char16" then @q.push [:DT_CHAR16, CIM::Type.new(m)]
	when "datetime" then @q.push [:DT_DATETIME, CIM::Type.new(m)]
	when "real32" then @q.push [:DT_REAL32, CIM::Type.new(m)]
	when "real64" then @q.push [:DT_REAL64, CIM::Type.new(m)]
	when "sint16" then @q.push [:DT_SINT16, CIM::Type.new(m)]
	when "sint32" then @q.push [:DT_SINT32, CIM::Type.new(m)]
	when "sint64" then @q.push [:DT_SINT64, CIM::Type.new(m)]
	when "sint8" then @q.push [:DT_SINT8, CIM::Type.new(m)]
	when "string" then @q.push [:DT_STR, CIM::Type.new(m)]
	when "uint16" then @q.push [:DT_UINT16, CIM::Type.new(m)]
	when "uint32" then @q.push [:DT_UINT32, CIM::Type.new(m)]
	when "uint64" then @q.push [:DT_UINT64, CIM::Type.new(m)]
	when "uint8" then @q.push [:DT_UINT8, CIM::Type.new(m)]
	when "enableoverride" then @q.push [:ENABLEOVERRIDE, m]
	when "false" then @q.push [:booleanValue, false]
	when "flavor" then @q.push [:FLAVOR, nil]
	when "include" then @q.push [:INCLUDE, nil]
	when "indication" then @q.push [:INDICATION, m]
	when "instance" then @q.push [:INSTANCE, m]
	when "method" then @q.push [:METHOD, m]
	when "null" then @q.push [:nullValue, CIM::Variant.new(:null,nil)]
	when "of" then @q.push [:OF, nil]
	when "parameter" then @q.push [:PARAMETER, m]
	when "pragma" then @q.push [:PRAGMA, nil]
	when "property" then @q.push [:PROPERTY, m]
	when "qualifier" then @q.push [:QUALIFIER, m]
	when "ref" then @q.push [:REF, nil]
	when "reference" then @q.push [:REFERENCE, m]
	when "restricted" then @q.push [:RESTRICTED, m]
	when "schema" then @q.push [:SCHEMA, m]
	when "scope" then @q.push [:SCOPE, nil]
	when "toinstance" then @q.push [:TOINSTANCE, m]
	when "tosubclass" then @q.push [:TOSUBCLASS, m]
	when "translatable" then @q.push [:TRANSLATABLE, m]
	when "true" then @q.push [:booleanValue, true]
	else
 @q.push( [:IDENTIFIER, m] )
	end     
    else
	require File.join(File.dirname(__FILE__), 'helper')
	raise MOF::Helper::ScannerError.new( @name, @lineno, @line, scanner.rest ) unless scanner.rest.empty?
    end   end   true
end
     |