iv-phonic 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -3,46 +3,45 @@ Manifest.txt
3
3
  README.rdoc
4
4
  Rakefile
5
5
  test/test_iv_phonic.rb
6
- ext/include/iv/uchar.h
7
- ext/include/iv/space.h
8
- ext/include/iv/lexer.h
9
- ext/include/iv/conversions.h
10
- ext/include/iv/dtoa.h
11
6
  ext/include/iv/mt19937.h
12
- ext/include/iv/ast.h
13
- ext/include/iv/noncopyable.h
14
- ext/include/iv/ast-factory.h
15
- ext/include/iv/stringpiece.h
16
- ext/include/iv/static_assert.h
17
- ext/include/iv/functor.h
18
- ext/include/iv/parser.h
19
- ext/include/iv/errors.h
20
- ext/include/iv/ast-visitor.h
21
7
  ext/include/iv/token.h
22
- ext/include/iv/enable_if.h
23
8
  ext/include/iv/any.h
9
+ ext/include/iv/ast-fwd.h
10
+ ext/include/iv/static_assert.h
11
+ ext/include/iv/ast.h
12
+ ext/include/iv/dtoa.h
13
+ ext/include/iv/ast-visitor.h
14
+ ext/include/iv/ustringpiece.h
15
+ ext/include/iv/ucdata.h
16
+ ext/include/iv/ustring.h
17
+ ext/include/iv/noncopyable.h
24
18
  ext/include/iv/keyword.h
25
- ext/include/iv/cmdline.h
26
- ext/include/iv/xorshift.h
19
+ ext/include/iv/chars.h
20
+ ext/include/iv/enable_if.h
21
+ ext/include/iv/utils.h
22
+ ext/include/iv/conversions.h
27
23
  ext/include/iv/location.h
28
- ext/include/iv/none.h
24
+ ext/include/iv/lexer.h
25
+ ext/include/iv/xorshift.h
26
+ ext/include/iv/space.h
29
27
  ext/include/iv/algorithm.h
30
- ext/include/iv/ustring.h
31
- ext/include/iv/ast-fwd.h
32
- ext/include/iv/utils.h
33
- ext/include/iv/ast-info.h
34
- ext/include/iv/alloc.h
35
- ext/include/iv/chars.h
36
28
  ext/include/iv/fixedcontainer.h
37
- ext/include/iv/ustringpiece.h
29
+ ext/include/iv/functor.h
30
+ ext/include/iv/cmdline.h
38
31
  ext/include/iv/ast-serializer.h
39
- ext/include/iv/ucdata.h
40
- ext/iv/phonic/factory.h
41
- ext/iv/phonic/parser.h
42
- ext/iv/phonic/encoding.h
32
+ ext/include/iv/stringpiece.h
33
+ ext/include/iv/uchar.h
34
+ ext/include/iv/ast-factory.h
35
+ ext/include/iv/alloc.h
36
+ ext/include/iv/ast-info.h
37
+ ext/include/iv/parser.h
38
+ ext/include/iv/none.h
39
+ ext/include/iv/errors.h
40
+ ext/iv/phonic/ast-fwd.h
43
41
  ext/iv/phonic/source.h
44
- ext/iv/phonic/phonic.cc
45
- ext/iv/phonic/rparser.h
46
42
  ext/iv/phonic/creator.h
47
- ext/iv/phonic/ast-fwd.h
48
- ext/iv/phonic/extconf.rb
43
+ ext/iv/phonic/phonic.cc
44
+ ext/iv/phonic/extconf.rb
45
+ ext/iv/phonic/encoding.h
46
+ ext/iv/phonic/parser.h
47
+ ext/iv/phonic/factory.h
data/README.rdoc CHANGED
@@ -8,8 +8,8 @@ phonic is ruby binding for iv AST API
8
8
 
9
9
  == MILESTONE
10
10
 
11
- + parser - done
12
- + specialized AST - working
11
+ * parser - done
12
+ * specialized AST - working
13
13
 
14
14
  == TARGET
15
15
 
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ directory "ext/include/iv"
10
10
 
11
11
  HOE = Hoe.spec 'iv-phonic' do
12
12
  developer('Constellation', 'utatane.tea@gmail.com')
13
- self.version = '0.0.5'
13
+ self.version = '0.0.6'
14
14
  self.readme_file = 'README.rdoc'
15
15
  self.history_file = 'ChangeLog'
16
16
  self.extra_rdoc_files = FileList['*.rdoc']
@@ -48,6 +48,7 @@ inline double StringToDouble(Iter it, Iter last, bool parse_float) {
48
48
  bool is_decimal = true;
49
49
  bool is_signed = false;
50
50
  bool is_sign_found = false;
51
+ bool is_found_zero = false;
51
52
  std::size_t pos = 0;
52
53
  int significant_digits = 0;
53
54
  int insignificant_digits = 0;
@@ -84,9 +85,10 @@ inline double StringToDouble(Iter it, Iter last, bool parse_float) {
84
85
 
85
86
  if (Chars::IsDecimalDigit(*it)) {
86
87
  if (*it == '0') {
88
+ is_found_zero = true;
87
89
  ++it;
88
90
  if (it == last) {
89
- return 0;
91
+ return (is_signed) ? -0.0 : 0.0;
90
92
  }
91
93
  if (!parse_float && (*it == 'x' || *it == 'X')) {
92
94
  if (is_sign_found) {
@@ -148,6 +150,7 @@ inline double StringToDouble(Iter it, Iter last, bool parse_float) {
148
150
  if (*it == '.') {
149
151
  buffer[pos++] = '.';
150
152
  ++it;
153
+ const Iter start = it;
151
154
  while (it != last &&
152
155
  Chars::IsDecimalDigit(*it)) {
153
156
  if (significant_digits < Conversions::kMaxSignificantDigits) {
@@ -156,6 +159,9 @@ inline double StringToDouble(Iter it, Iter last, bool parse_float) {
156
159
  }
157
160
  ++it;
158
161
  }
162
+ if (start == it) {
163
+ return Conversions::kNaN;
164
+ }
159
165
  } else {
160
166
  for (std::string::const_iterator inf_it = Conversions::kInfinity.begin(),
161
167
  inf_last = Conversions::kInfinity.end();
@@ -190,17 +196,29 @@ inline double StringToDouble(Iter it, Iter last, bool parse_float) {
190
196
  buffer[pos++] = *it;
191
197
  ++it;
192
198
  if (it == last) {
199
+ if (parse_float) {
200
+ --it;
201
+ --pos;
202
+ goto exponent_pasing_done;
203
+ }
193
204
  return Conversions::kNaN;
194
205
  }
206
+ bool is_signed_exp = false;
195
207
  if (*it == '+' || *it == '-') {
196
208
  buffer[pos++] = *it;
197
209
  ++it;
210
+ is_signed_exp = true;
198
211
  }
199
- if (it == last) {
200
- return Conversions::kNaN;
201
- }
202
- // more than 1 decimal digit required
203
- if (!Chars::IsDecimalDigit(*it)) {
212
+ if (it == last || !Chars::IsDecimalDigit(*it)) {
213
+ if (parse_float) {
214
+ --it;
215
+ --pos;
216
+ if (is_signed_exp) {
217
+ --it;
218
+ --pos;
219
+ }
220
+ goto exponent_pasing_done;
221
+ }
204
222
  return Conversions::kNaN;
205
223
  }
206
224
  int exponent = 0;
@@ -220,6 +238,9 @@ inline double StringToDouble(Iter it, Iter last, bool parse_float) {
220
238
  pos+=4;
221
239
  }
222
240
 
241
+ // exponent_pasing_done label
242
+ exponent_pasing_done:
243
+
223
244
  while (it != last &&
224
245
  (Chars::IsWhiteSpace(*it) || Chars::IsLineTerminator(*it))) {
225
246
  ++it;
@@ -228,7 +249,7 @@ inline double StringToDouble(Iter it, Iter last, bool parse_float) {
228
249
  if (it == last || parse_float) {
229
250
  if (pos == 0) {
230
251
  // empty
231
- return (parse_float) ? Conversions::kNaN : 0;
252
+ return (parse_float && !is_found_zero) ? Conversions::kNaN : 0;
232
253
  } else {
233
254
  buffer[pos++] = '\0';
234
255
  return std::strtod(buffer.data(), NULL);
@@ -246,6 +267,108 @@ inline double StringToDouble(const UStringPiece& str, bool parse_float) {
246
267
  return StringToDouble(str.begin(), str.end(), parse_float);
247
268
  }
248
269
 
270
+ inline int OctalValue(const int c) {
271
+ if ('0' <= c && c <= '8') {
272
+ return c - '0';
273
+ }
274
+ return -1;
275
+ }
276
+
277
+ inline int HexValue(const int c) {
278
+ if ('0' <= c && c <= '9') {
279
+ return c - '0';
280
+ }
281
+ if ('a' <= c && c <= 'f') {
282
+ return c - 'a' + 10;
283
+ }
284
+ if ('A' <= c && c <= 'F') {
285
+ return c - 'A' + 10;
286
+ }
287
+ return -1;
288
+ }
289
+
290
+ inline int Radix36Value(const int c) {
291
+ if ('0' <= c && c <= '9') {
292
+ return c - '0';
293
+ }
294
+ if ('a' <= c && c <= 'z') {
295
+ return c - 'a' + 10;
296
+ }
297
+ if ('A' <= c && c <= 'Z') {
298
+ return c - 'A' + 10;
299
+ }
300
+ return -1;
301
+ }
302
+
303
+ template<typename Iter>
304
+ inline double StringToIntegerWithRadix(Iter it, Iter last,
305
+ int radix, bool strip_prefix) {
306
+ // remove leading white space
307
+ while (it != last &&
308
+ (Chars::IsWhiteSpace(*it) || Chars::IsLineTerminator(*it))) {
309
+ ++it;
310
+ }
311
+
312
+ // empty string ""
313
+ if (it == last) {
314
+ return Conversions::kNaN;
315
+ }
316
+
317
+ int sign = 1;
318
+ if (*it == '-') {
319
+ sign = -1;
320
+ ++it;
321
+ } else if (*it == '+') {
322
+ ++it;
323
+ }
324
+
325
+ if (it == last) {
326
+ return Conversions::kNaN;
327
+ }
328
+
329
+ if (strip_prefix) {
330
+ if (*it == '0') {
331
+ ++it;
332
+ if (it != last &&
333
+ (*it == 'x' || *it == 'X')) {
334
+ // strip_prefix
335
+ ++it;
336
+ radix = 16;
337
+ } else {
338
+ --it;
339
+ }
340
+ }
341
+ }
342
+
343
+ if (it == last) {
344
+ return Conversions::kNaN;
345
+ }
346
+
347
+ double result = 0;
348
+ const Iter start = it;
349
+ for (; it != last; ++it) {
350
+ const int val = Radix36Value(*it);
351
+ if (val != -1 && val < radix) {
352
+ result = result * radix + val;
353
+ } else {
354
+ return (start == it) ? Conversions::kNaN : sign * result;
355
+ }
356
+ }
357
+ return sign * result;
358
+ }
359
+
360
+ inline double StringToIntegerWithRadix(const StringPiece& range,
361
+ int radix, bool strip_prefix) {
362
+ return StringToIntegerWithRadix(range.begin(), range.end(),
363
+ radix, strip_prefix);
364
+ }
365
+
366
+ inline double StringToIntegerWithRadix(const UStringPiece& range,
367
+ int radix, bool strip_prefix) {
368
+ return StringToIntegerWithRadix(range.begin(), range.end(),
369
+ radix, strip_prefix);
370
+ }
371
+
249
372
  inline std::size_t StringToHash(const UStringPiece& x) {
250
373
  std::size_t len = x.size();
251
374
  std::size_t step = (len >> 5) + 1;
@@ -284,8 +407,8 @@ inline int32_t DoubleToInt32(double d) {
284
407
  d - Conversions::DoubleToInt32_Two32 : d);
285
408
  }
286
409
 
287
- inline int32_t DoubleToUInt32(double d) {
288
- return static_cast<uint32_t>(d);
410
+ inline uint32_t DoubleToUInt32(double d) {
411
+ return static_cast<uint32_t>(DoubleToInt32(d));
289
412
  }
290
413
 
291
414
  inline double DoubleToInteger(double d) {
@@ -299,6 +422,7 @@ inline double DoubleToInteger(double d) {
299
422
  }
300
423
 
301
424
  inline bool ConvertToUInt32(const UStringPiece& str, uint32_t* value) {
425
+ static const uint32_t uint32_t_max = std::numeric_limits<uint32_t>::max();
302
426
  uint16_t ch;
303
427
  *value = 0;
304
428
  UStringPiece::const_iterator it = str.begin();
@@ -320,9 +444,9 @@ inline bool ConvertToUInt32(const UStringPiece& str, uint32_t* value) {
320
444
  return false;
321
445
  }
322
446
  }
323
- return (prev < (std::numeric_limits<uint32_t>::max() / 10) ||
324
- ((prev == (std::numeric_limits<uint32_t>::max() / 10)) &&
325
- (ch < (std::numeric_limits<uint32_t>::max() % 10))));
447
+ return (prev < (uint32_t_max / 10) ||
448
+ ((prev == (uint32_t_max / 10)) &&
449
+ (ch < (uint32_t_max % 10))));
326
450
  }
327
451
 
328
452
  template<typename T>
@@ -12,6 +12,7 @@
12
12
  #include "location.h"
13
13
  #include "noncopyable.h"
14
14
  #include "keyword.h"
15
+ #include "conversions.h"
15
16
 
16
17
  namespace iv {
17
18
  namespace core {
@@ -840,26 +841,6 @@ class Lexer: private Noncopyable<Lexer<Source> >::type {
840
841
  return res;
841
842
  }
842
843
 
843
- inline int OctalValue(const int c) const {
844
- if ('0' <= c && c <= '8') {
845
- return c - '0';
846
- }
847
- return -1;
848
- }
849
-
850
- inline int HexValue(const int c) const {
851
- if ('0' <= c && c <= '9') {
852
- return c - '0';
853
- }
854
- if ('a' <= c && c <= 'f') {
855
- return c - 'a' + 10;
856
- }
857
- if ('A' <= c && c <= 'F') {
858
- return c - 'A' + 10;
859
- }
860
- return -1;
861
- }
862
-
863
844
  void ScanDecimalDigits() {
864
845
  while (Chars::IsDecimalDigit(c_)) {
865
846
  Record8Advance();
@@ -53,8 +53,6 @@ class SpaceAllocator {
53
53
  : space_(alloc.space()) {
54
54
  }
55
55
 
56
- ~SpaceAllocator() throw() {}
57
-
58
56
  inline pointer address(reference x) const {
59
57
  return &x;
60
58
  }
@@ -1,13 +1,17 @@
1
1
  #ifndef _IV_PHONIC_AST_FWD_H_
2
2
  #define _IV_PHONIC_AST_FWD_H_
3
- #include <ruby.h>
4
3
  #include <iv/ast.h>
4
+
5
5
  namespace iv {
6
6
  namespace phonic {
7
+
7
8
  class AstFactory;
9
+
8
10
  } // namespace iv::phonic
11
+
9
12
  namespace core {
10
13
  namespace ast {
14
+
11
15
  template<>
12
16
  class AstNodeBase<iv::phonic::AstFactory>
13
17
  : public Inherit<iv::phonic::AstFactory, kAstNode> {
@@ -20,8 +24,11 @@ class AstNodeBase<iv::phonic::AstFactory>
20
24
  std::size_t begin_;
21
25
  std::size_t end_;
22
26
  };
27
+
23
28
  } } // namespace iv::core::ast
29
+
24
30
  namespace phonic {
31
+
25
32
  #define V(AST) typedef core::ast::AST<AstFactory> AST;
26
33
  AST_NODE_LIST(V)
27
34
  #undef V
@@ -1,6 +1,8 @@
1
1
  #ifndef _IV_PHONIC_CREATOR_H_
2
2
  #define _IV_PHONIC_CREATOR_H_
3
+ extern "C" {
3
4
  #include <ruby.h>
5
+ }
4
6
  #include <iv/ast-visitor.h>
5
7
  #include <iv/utils.h>
6
8
  #include "factory.h"
@@ -1,8 +1,10 @@
1
1
  #ifndef _IV_PHONIC_ENCODING_H_
2
2
  #define _IV_PHONIC_ENCODING_H_
3
+ extern "C" {
3
4
  #include <ruby.h>
4
5
  #include <ruby/encoding.h>
5
6
  #include <ruby/intern.h>
7
+ }
6
8
  namespace iv {
7
9
  namespace phonic {
8
10
 
@@ -1,8 +1,10 @@
1
1
  #ifndef _IV_PHONIC_FACTORY_H_
2
2
  #define _IV_PHONIC_FACTORY_H_
3
3
  #include <tr1/array>
4
+ extern "C" {
4
5
  #include <ruby.h>
5
6
  #include <ruby/oniguruma.h>
7
+ }
6
8
  #include <iv/alloc.h>
7
9
  #include <iv/ustringpiece.h>
8
10
  #include "encoding.h"
@@ -1,6 +1,5 @@
1
1
  #ifndef _IV_PHONIC_PARSER_H_
2
2
  #define _IV_PHONIC_PARSER_H_
3
- #include <ruby.h>
4
3
  #include <iv/parser.h>
5
4
  #include "factory.h"
6
5
  #include "source.h"
@@ -1,10 +1,45 @@
1
+ extern "C" {
1
2
  #include <ruby.h>
2
- #include "rparser.h"
3
+ #include <ruby/encoding.h>
4
+ #include <ruby/intern.h>
5
+ }
6
+ #include <iv/parser.h>
7
+ #include "encoding.h"
8
+ #include "factory.h"
9
+ #include "parser.h"
10
+ #include "creator.h"
11
+ #include "source.h"
3
12
 
4
13
  #define RBFUNC(func) (reinterpret_cast<VALUE(*)(...)>(func))
5
14
 
6
- extern "C" {
15
+ namespace iv {
16
+ namespace phonic {
7
17
 
18
+ static VALUE cParseError;
19
+
20
+ static VALUE Parse(VALUE self, VALUE rb_str) {
21
+ AstFactory factory;
22
+ Check_Type(rb_str, T_STRING);
23
+ VALUE encoded_rb_str = rb_str_encode(rb_str,
24
+ Encoding::UTF16Encoding(),
25
+ 0,
26
+ Qnil);
27
+ const char* str = StringValuePtr(encoded_rb_str);
28
+ const std::size_t len = RSTRING_LEN(encoded_rb_str);
29
+ UTF16Source source(str, len);
30
+ Parser parser(&factory, &source);
31
+ const FunctionLiteral* global = parser.ParseProgram();
32
+ if (!global) {
33
+ rb_raise(cParseError, "%s", parser.error().c_str());
34
+ } else {
35
+ Creator creator;
36
+ return creator.Result(global);
37
+ }
38
+ }
39
+
40
+ } } // namespace iv::phonic
41
+
42
+ extern "C" {
8
43
  void Init_phonic() {
9
44
  iv::phonic::Encoding::Init();
10
45
  // IV
@@ -13,10 +48,10 @@ void Init_phonic() {
13
48
  // IV::Phonic
14
49
  VALUE mIVPhonic = rb_define_module_under(mIV, "Phonic");
15
50
  rb_define_module_function(mIVPhonic, "parse",
16
- RBFUNC(&iv::phonic::RParser::Parse), 1);
17
- iv::phonic::RParser::Init(mIVPhonic);
51
+ RBFUNC(&iv::phonic::Parse), 1);
52
+ iv::phonic::cParseError = rb_define_class_under(
53
+ mIVPhonic, "ParseError", rb_eStandardError);
18
54
  }
19
-
20
55
  }
21
56
 
22
57
  #undef RBFUNC
@@ -4,7 +4,6 @@
4
4
  #include <cassert>
5
5
  #include <string>
6
6
  #include <tr1/cstdint>
7
- #include <ruby.h>
8
7
  #include <iv/stringpiece.h>
9
8
  #include <iv/ustring.h>
10
9
  #include <iv/none.h>
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iv-phonic
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 5
9
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
10
11
  platform: ruby
11
12
  authors:
12
13
  - Constellation
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-11-28 00:00:00 +09:00
18
+ date: 2010-12-02 00:00:00 +09:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 7
28
30
  segments:
29
31
  - 2
30
32
  - 0
@@ -40,6 +42,7 @@ dependencies:
40
42
  requirements:
41
43
  - - ">="
42
44
  - !ruby/object:Gem::Version
45
+ hash: 3
43
46
  segments:
44
47
  - 0
45
48
  version: "0"
@@ -53,11 +56,12 @@ dependencies:
53
56
  requirements:
54
57
  - - ">="
55
58
  - !ruby/object:Gem::Version
59
+ hash: 19
56
60
  segments:
57
61
  - 2
58
- - 6
59
- - 2
60
- version: 2.6.2
62
+ - 7
63
+ - 0
64
+ version: 2.7.0
61
65
  type: :development
62
66
  version_requirements: *id003
63
67
  description: phonic is ruby binding for iv AST API
@@ -76,49 +80,48 @@ files:
76
80
  - README.rdoc
77
81
  - Rakefile
78
82
  - test/test_iv_phonic.rb
79
- - ext/include/iv/uchar.h
80
- - ext/include/iv/space.h
81
- - ext/include/iv/lexer.h
82
- - ext/include/iv/conversions.h
83
- - ext/include/iv/dtoa.h
84
83
  - ext/include/iv/mt19937.h
85
- - ext/include/iv/ast.h
86
- - ext/include/iv/noncopyable.h
87
- - ext/include/iv/ast-factory.h
88
- - ext/include/iv/stringpiece.h
89
- - ext/include/iv/static_assert.h
90
- - ext/include/iv/functor.h
91
- - ext/include/iv/parser.h
92
- - ext/include/iv/errors.h
93
- - ext/include/iv/ast-visitor.h
94
84
  - ext/include/iv/token.h
95
- - ext/include/iv/enable_if.h
96
85
  - ext/include/iv/any.h
86
+ - ext/include/iv/ast-fwd.h
87
+ - ext/include/iv/static_assert.h
88
+ - ext/include/iv/ast.h
89
+ - ext/include/iv/dtoa.h
90
+ - ext/include/iv/ast-visitor.h
91
+ - ext/include/iv/ustringpiece.h
92
+ - ext/include/iv/ucdata.h
93
+ - ext/include/iv/ustring.h
94
+ - ext/include/iv/noncopyable.h
97
95
  - ext/include/iv/keyword.h
98
- - ext/include/iv/cmdline.h
99
- - ext/include/iv/xorshift.h
96
+ - ext/include/iv/chars.h
97
+ - ext/include/iv/enable_if.h
98
+ - ext/include/iv/utils.h
99
+ - ext/include/iv/conversions.h
100
100
  - ext/include/iv/location.h
101
- - ext/include/iv/none.h
101
+ - ext/include/iv/lexer.h
102
+ - ext/include/iv/xorshift.h
103
+ - ext/include/iv/space.h
102
104
  - ext/include/iv/algorithm.h
103
- - ext/include/iv/ustring.h
104
- - ext/include/iv/ast-fwd.h
105
- - ext/include/iv/utils.h
106
- - ext/include/iv/ast-info.h
107
- - ext/include/iv/alloc.h
108
- - ext/include/iv/chars.h
109
105
  - ext/include/iv/fixedcontainer.h
110
- - ext/include/iv/ustringpiece.h
106
+ - ext/include/iv/functor.h
107
+ - ext/include/iv/cmdline.h
111
108
  - ext/include/iv/ast-serializer.h
112
- - ext/include/iv/ucdata.h
113
- - ext/iv/phonic/factory.h
114
- - ext/iv/phonic/parser.h
115
- - ext/iv/phonic/encoding.h
109
+ - ext/include/iv/stringpiece.h
110
+ - ext/include/iv/uchar.h
111
+ - ext/include/iv/ast-factory.h
112
+ - ext/include/iv/alloc.h
113
+ - ext/include/iv/ast-info.h
114
+ - ext/include/iv/parser.h
115
+ - ext/include/iv/none.h
116
+ - ext/include/iv/errors.h
117
+ - ext/iv/phonic/ast-fwd.h
116
118
  - ext/iv/phonic/source.h
117
- - ext/iv/phonic/phonic.cc
118
- - ext/iv/phonic/rparser.h
119
119
  - ext/iv/phonic/creator.h
120
- - ext/iv/phonic/ast-fwd.h
120
+ - ext/iv/phonic/phonic.cc
121
121
  - ext/iv/phonic/extconf.rb
122
+ - ext/iv/phonic/encoding.h
123
+ - ext/iv/phonic/parser.h
124
+ - ext/iv/phonic/factory.h
122
125
  has_rdoc: true
123
126
  homepage: https://github.com/Constellation/iv/tree/master/src/phonic/
124
127
  licenses: []
@@ -134,6 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
137
  requirements:
135
138
  - - ">="
136
139
  - !ruby/object:Gem::Version
140
+ hash: 49
137
141
  segments:
138
142
  - 1
139
143
  - 9
@@ -144,6 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
148
  requirements:
145
149
  - - ">="
146
150
  - !ruby/object:Gem::Version
151
+ hash: 3
147
152
  segments:
148
153
  - 0
149
154
  version: "0"
@@ -1,47 +0,0 @@
1
- #ifndef _IV_PHONIC_RPARSER_H_
2
- #define _IV_PHONIC_RPARSER_H_
3
- #include <cstdlib>
4
- #include <cstring>
5
- #include <ruby.h>
6
- #include <ruby/encoding.h>
7
- #include <ruby/intern.h>
8
- #include <iv/parser.h>
9
- #include "encoding.h"
10
- #include "factory.h"
11
- #include "parser.h"
12
- #include "creator.h"
13
- #include "source.h"
14
- namespace iv {
15
- namespace phonic {
16
-
17
- static VALUE cParseError;
18
-
19
- class RParser {
20
- public:
21
- static VALUE Parse(VALUE self, VALUE rb_str) {
22
- AstFactory factory;
23
- Check_Type(rb_str, T_STRING);
24
- VALUE encoded_rb_str = rb_str_encode(rb_str,
25
- Encoding::UTF16Encoding(),
26
- 0,
27
- Qnil);
28
- const char* str = StringValuePtr(encoded_rb_str);
29
- const std::size_t len = RSTRING_LEN(encoded_rb_str);
30
- UTF16Source source(str, len);
31
- Parser parser(&factory, &source);
32
- const FunctionLiteral* global = parser.ParseProgram();
33
- if (!global) {
34
- rb_raise(cParseError, "%s", parser.error().c_str());
35
- } else {
36
- Creator creator;
37
- return creator.Result(global);
38
- }
39
- }
40
-
41
- static void Init(VALUE mIVPhonic) {
42
- cParseError = rb_define_class_under(mIVPhonic, "ParseError", rb_eStandardError);
43
- }
44
- };
45
-
46
- } } // namespace iv::phonic
47
- #endif // _IV_PHONIC_RPARSER_H_