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
|
# File 'lib/lib/haxe/format/json_parser.rb', line 18
def parse_rec
while(true)
c = nil
begin
index = @pos
@pos+=1
c = (@str[index] || 0).ord
end
case(c)
when 32,13,10,9
when 123
obj = { }
field = nil
comma = nil
while(true)
c1 = nil
begin
index1 = @pos
@pos+=1
c1 = (@str[index1] || 0).ord
end
case(c1)
when 32,13,10,9
when 125
self.invalid_char if field != nil || comma == false
return obj
when 58
self.invalid_char if field == nil
begin
value = self.parse_rec
obj[field] = value
end
field = nil
comma = true
when 44
if comma
comma = false
else
self.invalid_char
end
when 34
self.invalid_char if comma
field = self.parse_string
else
self.invalid_char
end
end
when 91
arr = []
comma1 = nil
while(true)
c2 = nil
begin
index2 = @pos
@pos+=1
c2 = (@str[index2] || 0).ord
end
case(c2)
when 32,13,10,9
when 93
self.invalid_char if comma1 == false
return arr
when 44
if comma1
comma1 = false
else
self.invalid_char
end
else
self.invalid_char if comma1
@pos-=1
arr.push(self.parse_rec)
comma1 = true
end
end
when 116
save = @pos
if lambda{|_this_| index3 = @pos
@pos+=1
_r = (@str[index3] || 0).ord}.call(self) != 114 || lambda{|_this_| index4 = @pos
@pos+=1
_r2 = (@str[index4] || 0).ord}.call(self) != 117 || lambda{|_this_| index5 = @pos
@pos+=1
_r3 = (@str[index5] || 0).ord}.call(self) != 101
@pos = save
self.invalid_char
end
return true
when 102
save1 = @pos
if lambda{|_this_| index6 = @pos
@pos+=1
_r4 = (@str[index6] || 0).ord}.call(self) != 97 || lambda{|_this_| index7 = @pos
@pos+=1
_r5 = (@str[index7] || 0).ord}.call(self) != 108 || lambda{|_this_| index8 = @pos
@pos+=1
_r6 = (@str[index8] || 0).ord}.call(self) != 115 || lambda{|_this_| index9 = @pos
@pos+=1
_r7 = (@str[index9] || 0).ord}.call(self) != 101
@pos = save1
self.invalid_char
end
return false
when 110
save2 = @pos
if lambda{|_this_| index10 = @pos
@pos+=1
_r8 = (@str[index10] || 0).ord}.call(self) != 117 || lambda{|_this_| index11 = @pos
@pos+=1
_r9 = (@str[index11] || 0).ord}.call(self) != 108 || lambda{|_this_| index12 = @pos
@pos+=1
_r10 = (@str[index12] || 0).ord}.call(self) != 108
@pos = save2
self.invalid_char
end
return nil
when 34
return self.parse_string
when 48,49,50,51,52,53,54,55,56,57,45
c3 = c
start = @pos - 1
minus = c3 == 45
digit = !minus
zero = c3 == 48
point = false
e = false
pm = false
_end = false
while(true)
begin
index13 = @pos
@pos+=1
c3 = (@str[index13] || 0).ord
end
case(c3)
when 48
self.invalid_number(start) if zero && !point
if minus
minus = false
zero = true
end
digit = true
when 49,50,51,52,53,54,55,56,57
self.invalid_number(start) if zero && !point
minus = false if minus
digit = true
zero = false
when 46
self.invalid_number(start) if minus || point
digit = false
point = true
when 101,69
self.invalid_number(start) if minus || zero || e
digit = false
e = true
when 43,45
self.invalid_number(start) if !e || pm
digit = false
pm = true
else
self.invalid_number(start) if !digit
@pos-=1
_end = true
end
break if _end
end
f = nil
begin
x = @str[start,@pos - start]
f = x.to_f
end
i = f.to_i
if i == f
return i
else
return f
end
else
self.invalid_char
end
end
end
|