everypolitician-daff 1.3.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +252 -0
- data/bin/daff.rb +3 -0
- data/lib/daff.rb +150 -0
- data/lib/lib/coopy/alignment.rb +307 -0
- data/lib/lib/coopy/cell_builder.rb +17 -0
- data/lib/lib/coopy/cell_info.rb +33 -0
- data/lib/lib/coopy/column_change.rb +16 -0
- data/lib/lib/coopy/combined_table.rb +127 -0
- data/lib/lib/coopy/combined_table_body.rb +151 -0
- data/lib/lib/coopy/combined_table_head.rb +103 -0
- data/lib/lib/coopy/compare_flags.rb +127 -0
- data/lib/lib/coopy/compare_table.rb +688 -0
- data/lib/lib/coopy/conflict_info.rb +23 -0
- data/lib/lib/coopy/coopy.rb +1065 -0
- data/lib/lib/coopy/cross_match.rb +17 -0
- data/lib/lib/coopy/csv.rb +290 -0
- data/lib/lib/coopy/diff_render.rb +339 -0
- data/lib/lib/coopy/diff_summary.rb +28 -0
- data/lib/lib/coopy/flat_cell_builder.rb +75 -0
- data/lib/lib/coopy/highlight_patch.rb +977 -0
- data/lib/lib/coopy/highlight_patch_unit.rb +38 -0
- data/lib/lib/coopy/index.rb +131 -0
- data/lib/lib/coopy/index_item.rb +37 -0
- data/lib/lib/coopy/index_pair.rb +96 -0
- data/lib/lib/coopy/json_table.rb +165 -0
- data/lib/lib/coopy/json_tables.rb +129 -0
- data/lib/lib/coopy/merger.rb +197 -0
- data/lib/lib/coopy/meta.rb +20 -0
- data/lib/lib/coopy/mover.rb +197 -0
- data/lib/lib/coopy/ndjson.rb +134 -0
- data/lib/lib/coopy/nested_cell_builder.rb +74 -0
- data/lib/lib/coopy/ordering.rb +54 -0
- data/lib/lib/coopy/property_change.rb +16 -0
- data/lib/lib/coopy/row.rb +11 -0
- data/lib/lib/coopy/row_change.rb +42 -0
- data/lib/lib/coopy/row_stream.rb +11 -0
- data/lib/lib/coopy/simple_meta.rb +314 -0
- data/lib/lib/coopy/simple_table.rb +345 -0
- data/lib/lib/coopy/simple_view.rb +70 -0
- data/lib/lib/coopy/sparse_sheet.rb +51 -0
- data/lib/lib/coopy/sql_column.rb +47 -0
- data/lib/lib/coopy/sql_compare.rb +605 -0
- data/lib/lib/coopy/sql_database.rb +21 -0
- data/lib/lib/coopy/sql_helper.rb +17 -0
- data/lib/lib/coopy/sql_table.rb +335 -0
- data/lib/lib/coopy/sql_table_name.rb +23 -0
- data/lib/lib/coopy/sql_tables.rb +128 -0
- data/lib/lib/coopy/sqlite_helper.rb +316 -0
- data/lib/lib/coopy/table.rb +24 -0
- data/lib/lib/coopy/table_comparison_state.rb +50 -0
- data/lib/lib/coopy/table_diff.rb +1185 -0
- data/lib/lib/coopy/table_io.rb +72 -0
- data/lib/lib/coopy/table_modifier.rb +40 -0
- data/lib/lib/coopy/table_stream.rb +102 -0
- data/lib/lib/coopy/table_view.rb +148 -0
- data/lib/lib/coopy/tables.rb +52 -0
- data/lib/lib/coopy/terminal_diff_render.rb +213 -0
- data/lib/lib/coopy/unit.rb +93 -0
- data/lib/lib/coopy/view.rb +20 -0
- data/lib/lib/coopy/viterbi.rb +177 -0
- data/lib/lib/haxe/ds/int_map.rb +19 -0
- data/lib/lib/haxe/ds/string_map.rb +19 -0
- data/lib/lib/haxe/format/json_parser.rb +265 -0
- data/lib/lib/haxe/format/json_printer.rb +240 -0
- data/lib/lib/haxe/imap.rb +10 -0
- data/lib/lib/haxe/io/bytes.rb +34 -0
- data/lib/lib/haxe/io/eof.rb +18 -0
- data/lib/lib/haxe/io/error.rb +22 -0
- data/lib/lib/haxe/io/output.rb +41 -0
- data/lib/lib/hx_overrides.rb +19 -0
- data/lib/lib/hx_sys.rb +74 -0
- data/lib/lib/lambda.rb +37 -0
- data/lib/lib/list.rb +36 -0
- data/lib/lib/math.rb +5 -0
- data/lib/lib/rb/boot.rb +39 -0
- data/lib/lib/rb/ruby_iterator.rb +50 -0
- data/lib/lib/reflect.rb +41 -0
- data/lib/lib/std.rb +12 -0
- data/lib/lib/string_buf.rb +19 -0
- data/lib/lib/sys/io/file_handle.rb +18 -0
- data/lib/lib/sys/io/file_output.rb +36 -0
- data/lib/lib/sys/io/hx_file.rb +20 -0
- data/lib/lib/type.rb +37 -0
- data/lib/lib/value_type.rb +23 -0
- data/lib/lib/x_list/list_iterator.rb +32 -0
- metadata +235 -0
@@ -0,0 +1,93 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class Unit
|
6
|
+
|
7
|
+
def initialize(l = -2,r = -2,p = -2)
|
8
|
+
@l = l
|
9
|
+
@r = r
|
10
|
+
@p = p
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_accessor :l
|
14
|
+
attr_accessor :r
|
15
|
+
attr_accessor :p
|
16
|
+
|
17
|
+
def lp
|
18
|
+
if @p == -2
|
19
|
+
return @l
|
20
|
+
else
|
21
|
+
return @p
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
return _hx_str(::Coopy::Unit.describe(@p)) + "|" + _hx_str(::Coopy::Unit.describe(@l)) + ":" + _hx_str(::Coopy::Unit.describe(@r)) if @p >= -1
|
27
|
+
_hx_str(::Coopy::Unit.describe(@l)) + ":" + _hx_str(::Coopy::Unit.describe(@r))
|
28
|
+
end
|
29
|
+
|
30
|
+
def from_string(txt)
|
31
|
+
txt += "]"
|
32
|
+
at = 0
|
33
|
+
begin
|
34
|
+
_g1 = 0
|
35
|
+
_g = txt.length
|
36
|
+
while(_g1 < _g)
|
37
|
+
i = _g1
|
38
|
+
_g1+=1
|
39
|
+
ch = (txt[i].ord rescue nil)
|
40
|
+
if ch >= 48 && ch <= 57
|
41
|
+
at *= 10
|
42
|
+
at += ch - 48
|
43
|
+
elsif ch == 45
|
44
|
+
at = -1
|
45
|
+
elsif ch == 124
|
46
|
+
@p = at
|
47
|
+
at = 0
|
48
|
+
elsif ch == 58
|
49
|
+
@l = at
|
50
|
+
at = 0
|
51
|
+
elsif ch == 93
|
52
|
+
@r = at
|
53
|
+
return true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
false
|
58
|
+
end
|
59
|
+
|
60
|
+
# protected - in ruby this doesn't play well with static/inline methods
|
61
|
+
|
62
|
+
def base26(num)
|
63
|
+
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
64
|
+
return "-" if num < 0
|
65
|
+
out = ""
|
66
|
+
begin
|
67
|
+
out = _hx_str(out) + _hx_str(alpha[num.remainder(26)])
|
68
|
+
num = (num / 26).floor - 1
|
69
|
+
end while(num >= 0)
|
70
|
+
out
|
71
|
+
end
|
72
|
+
|
73
|
+
public
|
74
|
+
|
75
|
+
def to_base26string
|
76
|
+
return _hx_str(self.base26(@p)) + "|" + _hx_str(self.base26(@l)) + ":" + _hx_str(self.base26(@r)) if @p >= -1
|
77
|
+
_hx_str(self.base26(@l)) + ":" + _hx_str(self.base26(@r))
|
78
|
+
end
|
79
|
+
|
80
|
+
# protected - in ruby this doesn't play well with static/inline methods
|
81
|
+
|
82
|
+
def Unit.describe(i)
|
83
|
+
if i >= 0
|
84
|
+
return "" + _hx_str(i)
|
85
|
+
else
|
86
|
+
return "-"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
haxe_me ["coopy", "Unit"]
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class View
|
6
|
+
def toString(d) puts "Abstract View.toString called" end
|
7
|
+
def equals(d1,d2) puts "Abstract View.equals called" end
|
8
|
+
def toDatum(str) puts "Abstract View.toDatum called" end
|
9
|
+
def makeHash() puts "Abstract View.makeHash called" end
|
10
|
+
def hashSet(h,str,d) puts "Abstract View.hashSet called" end
|
11
|
+
def isHash(h) puts "Abstract View.isHash called" end
|
12
|
+
def hashExists(h,str) puts "Abstract View.hashExists called" end
|
13
|
+
def hashGet(h,str) puts "Abstract View.hashGet called" end
|
14
|
+
def isTable(t) puts "Abstract View.isTable called" end
|
15
|
+
def getTable(t) puts "Abstract View.getTable called" end
|
16
|
+
def wrapTable(t) puts "Abstract View.wrapTable called" end
|
17
|
+
haxe_me ["coopy", "View"]
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class Viterbi
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@k = @t = 0
|
9
|
+
self.reset
|
10
|
+
@cost = ::Coopy::SparseSheet.new
|
11
|
+
@src = ::Coopy::SparseSheet.new
|
12
|
+
@path = ::Coopy::SparseSheet.new
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
attr_accessor :k
|
18
|
+
attr_accessor :t
|
19
|
+
attr_accessor :index
|
20
|
+
attr_accessor :mode
|
21
|
+
attr_accessor :path_valid
|
22
|
+
attr_accessor :best_cost
|
23
|
+
attr_accessor :cost
|
24
|
+
attr_accessor :src
|
25
|
+
attr_accessor :path
|
26
|
+
|
27
|
+
public
|
28
|
+
|
29
|
+
def reset
|
30
|
+
@index = 0
|
31
|
+
@mode = 0
|
32
|
+
@path_valid = false
|
33
|
+
@best_cost = 0
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_size(states,sequence_length)
|
37
|
+
@k = states
|
38
|
+
@t = sequence_length
|
39
|
+
@cost.resize(@k,@t,0)
|
40
|
+
@src.resize(@k,@t,-1)
|
41
|
+
@path.resize(1,@t,-1)
|
42
|
+
end
|
43
|
+
|
44
|
+
protected
|
45
|
+
|
46
|
+
def assert_mode(_next)
|
47
|
+
@index+=1 if _next == 0 && @mode == 1
|
48
|
+
@mode = _next
|
49
|
+
end
|
50
|
+
|
51
|
+
public
|
52
|
+
|
53
|
+
def add_transition(s0,s1,c)
|
54
|
+
resize = false
|
55
|
+
if s0 >= @k
|
56
|
+
@k = s0 + 1
|
57
|
+
resize = true
|
58
|
+
end
|
59
|
+
if s1 >= @k
|
60
|
+
@k = s1 + 1
|
61
|
+
resize = true
|
62
|
+
end
|
63
|
+
if resize
|
64
|
+
@cost.non_destructive_resize(@k,@t,0)
|
65
|
+
@src.non_destructive_resize(@k,@t,-1)
|
66
|
+
@path.non_destructive_resize(1,@t,-1)
|
67
|
+
end
|
68
|
+
@path_valid = false
|
69
|
+
self.assert_mode(1)
|
70
|
+
if @index >= @t
|
71
|
+
@t = @index + 1
|
72
|
+
@cost.non_destructive_resize(@k,@t,0)
|
73
|
+
@src.non_destructive_resize(@k,@t,-1)
|
74
|
+
@path.non_destructive_resize(1,@t,-1)
|
75
|
+
end
|
76
|
+
sourced = false
|
77
|
+
if @index > 0
|
78
|
+
c += @cost.get(s0,@index - 1)
|
79
|
+
sourced = @src.get(s0,@index - 1) != -1
|
80
|
+
else
|
81
|
+
sourced = true
|
82
|
+
end
|
83
|
+
if sourced
|
84
|
+
if c < @cost.get(s1,@index) || @src.get(s1,@index) == -1
|
85
|
+
@cost.set(s1,@index,c)
|
86
|
+
@src.set(s1,@index,s0)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def end_transitions
|
92
|
+
@path_valid = false
|
93
|
+
self.assert_mode(0)
|
94
|
+
end
|
95
|
+
|
96
|
+
def begin_transitions
|
97
|
+
@path_valid = false
|
98
|
+
self.assert_mode(1)
|
99
|
+
end
|
100
|
+
|
101
|
+
def calculate_path
|
102
|
+
return if @path_valid
|
103
|
+
self.end_transitions
|
104
|
+
best = 0
|
105
|
+
bestj = -1
|
106
|
+
if @index <= 0
|
107
|
+
@path_valid = true
|
108
|
+
return
|
109
|
+
end
|
110
|
+
begin
|
111
|
+
_g1 = 0
|
112
|
+
_g = @k
|
113
|
+
while(_g1 < _g)
|
114
|
+
j = _g1
|
115
|
+
_g1+=1
|
116
|
+
if (@cost.get(j,@index - 1) < best || bestj == -1) && @src.get(j,@index - 1) != -1
|
117
|
+
best = @cost.get(j,@index - 1)
|
118
|
+
bestj = j
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
@best_cost = best
|
123
|
+
begin
|
124
|
+
_g11 = 0
|
125
|
+
_g2 = @index
|
126
|
+
while(_g11 < _g2)
|
127
|
+
j1 = _g11
|
128
|
+
_g11+=1
|
129
|
+
i = @index - 1 - j1
|
130
|
+
@path.set(0,i,bestj)
|
131
|
+
puts "Problem in Viterbi" if !(bestj != -1 && (bestj >= 0 && bestj < @k))
|
132
|
+
bestj = @src.get(bestj,i)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
@path_valid = true
|
136
|
+
end
|
137
|
+
|
138
|
+
def to_s
|
139
|
+
self.calculate_path
|
140
|
+
txt = ""
|
141
|
+
begin
|
142
|
+
_g1 = 0
|
143
|
+
_g = @index
|
144
|
+
while(_g1 < _g)
|
145
|
+
i = _g1
|
146
|
+
_g1+=1
|
147
|
+
if @path.get(0,i) == -1
|
148
|
+
txt += "*"
|
149
|
+
else
|
150
|
+
txt += @path.get(0,i)
|
151
|
+
end
|
152
|
+
txt += " " if @k >= 10
|
153
|
+
end
|
154
|
+
end
|
155
|
+
txt += " costs " + _hx_str(self.get_cost)
|
156
|
+
txt
|
157
|
+
end
|
158
|
+
|
159
|
+
def length
|
160
|
+
self.calculate_path if @index > 0
|
161
|
+
@index
|
162
|
+
end
|
163
|
+
|
164
|
+
def get(i)
|
165
|
+
self.calculate_path
|
166
|
+
@path.get(0,i)
|
167
|
+
end
|
168
|
+
|
169
|
+
def get_cost
|
170
|
+
self.calculate_path
|
171
|
+
@best_cost
|
172
|
+
end
|
173
|
+
|
174
|
+
haxe_me ["coopy", "Viterbi"]
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
@@ -0,0 +1,265 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Haxe
|
5
|
+
module Format
|
6
|
+
class JsonParser
|
7
|
+
|
8
|
+
def initialize(str)
|
9
|
+
@str = str
|
10
|
+
@pos = 0
|
11
|
+
end
|
12
|
+
|
13
|
+
# protected - in ruby this doesn't play well with static/inline methods
|
14
|
+
|
15
|
+
attr_accessor :str
|
16
|
+
attr_accessor :pos
|
17
|
+
|
18
|
+
def parse_rec
|
19
|
+
while(true)
|
20
|
+
c = nil
|
21
|
+
begin
|
22
|
+
index = @pos
|
23
|
+
@pos+=1
|
24
|
+
c = (@str[index] || 0).ord
|
25
|
+
end
|
26
|
+
case(c)
|
27
|
+
when 32,13,10,9
|
28
|
+
when 123
|
29
|
+
obj = { }
|
30
|
+
field = nil
|
31
|
+
comma = nil
|
32
|
+
while(true)
|
33
|
+
c1 = nil
|
34
|
+
begin
|
35
|
+
index1 = @pos
|
36
|
+
@pos+=1
|
37
|
+
c1 = (@str[index1] || 0).ord
|
38
|
+
end
|
39
|
+
case(c1)
|
40
|
+
when 32,13,10,9
|
41
|
+
when 125
|
42
|
+
self.invalid_char if field != nil || comma == false
|
43
|
+
return obj
|
44
|
+
when 58
|
45
|
+
self.invalid_char if field == nil
|
46
|
+
begin
|
47
|
+
value = self.parse_rec
|
48
|
+
obj[field] = value
|
49
|
+
end
|
50
|
+
field = nil
|
51
|
+
comma = true
|
52
|
+
when 44
|
53
|
+
if comma
|
54
|
+
comma = false
|
55
|
+
else
|
56
|
+
self.invalid_char
|
57
|
+
end
|
58
|
+
when 34
|
59
|
+
self.invalid_char if comma
|
60
|
+
field = self.parse_string
|
61
|
+
else
|
62
|
+
self.invalid_char
|
63
|
+
end
|
64
|
+
end
|
65
|
+
when 91
|
66
|
+
arr = []
|
67
|
+
comma1 = nil
|
68
|
+
while(true)
|
69
|
+
c2 = nil
|
70
|
+
begin
|
71
|
+
index2 = @pos
|
72
|
+
@pos+=1
|
73
|
+
c2 = (@str[index2] || 0).ord
|
74
|
+
end
|
75
|
+
case(c2)
|
76
|
+
when 32,13,10,9
|
77
|
+
when 93
|
78
|
+
self.invalid_char if comma1 == false
|
79
|
+
return arr
|
80
|
+
when 44
|
81
|
+
if comma1
|
82
|
+
comma1 = false
|
83
|
+
else
|
84
|
+
self.invalid_char
|
85
|
+
end
|
86
|
+
else
|
87
|
+
self.invalid_char if comma1
|
88
|
+
@pos-=1
|
89
|
+
arr.push(self.parse_rec)
|
90
|
+
comma1 = true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
when 116
|
94
|
+
save = @pos
|
95
|
+
if lambda{|_this_| index3 = @pos
|
96
|
+
@pos+=1
|
97
|
+
_r = (@str[index3] || 0).ord}.call(self) != 114 || lambda{|_this_| index4 = @pos
|
98
|
+
@pos+=1
|
99
|
+
_r2 = (@str[index4] || 0).ord}.call(self) != 117 || lambda{|_this_| index5 = @pos
|
100
|
+
@pos+=1
|
101
|
+
_r3 = (@str[index5] || 0).ord}.call(self) != 101
|
102
|
+
@pos = save
|
103
|
+
self.invalid_char
|
104
|
+
end
|
105
|
+
return true
|
106
|
+
when 102
|
107
|
+
save1 = @pos
|
108
|
+
if lambda{|_this_| index6 = @pos
|
109
|
+
@pos+=1
|
110
|
+
_r4 = (@str[index6] || 0).ord}.call(self) != 97 || lambda{|_this_| index7 = @pos
|
111
|
+
@pos+=1
|
112
|
+
_r5 = (@str[index7] || 0).ord}.call(self) != 108 || lambda{|_this_| index8 = @pos
|
113
|
+
@pos+=1
|
114
|
+
_r6 = (@str[index8] || 0).ord}.call(self) != 115 || lambda{|_this_| index9 = @pos
|
115
|
+
@pos+=1
|
116
|
+
_r7 = (@str[index9] || 0).ord}.call(self) != 101
|
117
|
+
@pos = save1
|
118
|
+
self.invalid_char
|
119
|
+
end
|
120
|
+
return false
|
121
|
+
when 110
|
122
|
+
save2 = @pos
|
123
|
+
if lambda{|_this_| index10 = @pos
|
124
|
+
@pos+=1
|
125
|
+
_r8 = (@str[index10] || 0).ord}.call(self) != 117 || lambda{|_this_| index11 = @pos
|
126
|
+
@pos+=1
|
127
|
+
_r9 = (@str[index11] || 0).ord}.call(self) != 108 || lambda{|_this_| index12 = @pos
|
128
|
+
@pos+=1
|
129
|
+
_r10 = (@str[index12] || 0).ord}.call(self) != 108
|
130
|
+
@pos = save2
|
131
|
+
self.invalid_char
|
132
|
+
end
|
133
|
+
return nil
|
134
|
+
when 34
|
135
|
+
return self.parse_string
|
136
|
+
when 48,49,50,51,52,53,54,55,56,57,45
|
137
|
+
c3 = c
|
138
|
+
start = @pos - 1
|
139
|
+
minus = c3 == 45
|
140
|
+
digit = !minus
|
141
|
+
zero = c3 == 48
|
142
|
+
point = false
|
143
|
+
e = false
|
144
|
+
pm = false
|
145
|
+
_end = false
|
146
|
+
while(true)
|
147
|
+
begin
|
148
|
+
index13 = @pos
|
149
|
+
@pos+=1
|
150
|
+
c3 = (@str[index13] || 0).ord
|
151
|
+
end
|
152
|
+
case(c3)
|
153
|
+
when 48
|
154
|
+
self.invalid_number(start) if zero && !point
|
155
|
+
if minus
|
156
|
+
minus = false
|
157
|
+
zero = true
|
158
|
+
end
|
159
|
+
digit = true
|
160
|
+
when 49,50,51,52,53,54,55,56,57
|
161
|
+
self.invalid_number(start) if zero && !point
|
162
|
+
minus = false if minus
|
163
|
+
digit = true
|
164
|
+
zero = false
|
165
|
+
when 46
|
166
|
+
self.invalid_number(start) if minus || point
|
167
|
+
digit = false
|
168
|
+
point = true
|
169
|
+
when 101,69
|
170
|
+
self.invalid_number(start) if minus || zero || e
|
171
|
+
digit = false
|
172
|
+
e = true
|
173
|
+
when 43,45
|
174
|
+
self.invalid_number(start) if !e || pm
|
175
|
+
digit = false
|
176
|
+
pm = true
|
177
|
+
else
|
178
|
+
self.invalid_number(start) if !digit
|
179
|
+
@pos-=1
|
180
|
+
_end = true
|
181
|
+
end
|
182
|
+
break if _end
|
183
|
+
end
|
184
|
+
f = nil
|
185
|
+
begin
|
186
|
+
x = @str[start,@pos - start]
|
187
|
+
f = x.to_f
|
188
|
+
end
|
189
|
+
i = f.to_i
|
190
|
+
if i == f
|
191
|
+
return i
|
192
|
+
else
|
193
|
+
return f
|
194
|
+
end
|
195
|
+
else
|
196
|
+
self.invalid_char
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def parse_string
|
202
|
+
start = @pos
|
203
|
+
buf_b = ""
|
204
|
+
while(true)
|
205
|
+
c = nil
|
206
|
+
begin
|
207
|
+
index = @pos
|
208
|
+
@pos+=1
|
209
|
+
c = (@str[index] || 0).ord
|
210
|
+
end
|
211
|
+
break if c == 34
|
212
|
+
if c == 92
|
213
|
+
buf_b += @str[start,@pos - start - 1]
|
214
|
+
begin
|
215
|
+
index1 = @pos
|
216
|
+
@pos+=1
|
217
|
+
c = (@str[index1] || 0).ord
|
218
|
+
end
|
219
|
+
case(c)
|
220
|
+
when 114
|
221
|
+
buf_b += [13].pack("U")
|
222
|
+
when 110
|
223
|
+
buf_b += [10].pack("U")
|
224
|
+
when 116
|
225
|
+
buf_b += [9].pack("U")
|
226
|
+
when 98
|
227
|
+
buf_b += [8].pack("U")
|
228
|
+
when 102
|
229
|
+
buf_b += [12].pack("U")
|
230
|
+
when 47,92,34
|
231
|
+
buf_b += [c].pack("U")
|
232
|
+
when 117
|
233
|
+
uc = nil
|
234
|
+
begin
|
235
|
+
x = "0x" + _hx_str(@str[@pos,4])
|
236
|
+
uc = x.to_i
|
237
|
+
end
|
238
|
+
@pos += 4
|
239
|
+
buf_b += [uc].pack("U")
|
240
|
+
else
|
241
|
+
raise hx_raise("Invalid escape sequence \\" + _hx_str([c].pack("U")) + " at position " + _hx_str((@pos - 1)))
|
242
|
+
end
|
243
|
+
start = @pos
|
244
|
+
elsif c == 0
|
245
|
+
raise hx_raise("Unclosed string")
|
246
|
+
end
|
247
|
+
end
|
248
|
+
buf_b += @str[start,@pos - start - 1]
|
249
|
+
buf_b
|
250
|
+
end
|
251
|
+
|
252
|
+
def invalid_char
|
253
|
+
@pos-=1
|
254
|
+
raise hx_raise("Invalid char " + _hx_str((@str[@pos] || 0).ord) + " at position " + _hx_str(@pos))
|
255
|
+
end
|
256
|
+
|
257
|
+
def invalid_number(start)
|
258
|
+
raise hx_raise("Invalid number at position " + _hx_str(start) + ": " + _hx_str(@str[start,@pos - start]))
|
259
|
+
end
|
260
|
+
|
261
|
+
haxe_me ["haxe", "format", "JsonParser"]
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
265
|
+
end
|