c_lexer 2.5.3.0.0 → 2.6.0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/Gemfile.lock +4 -4
- data/README.md +6 -2
- data/c_lexer.gemspec +2 -2
- data/ext/lexer/lexer.c +841 -933
- data/ext/lexer/lexer.rl +7 -9
- data/ext/lexer/literal/literal.h +1 -0
- data/ext/lexer/literal/methods.h +20 -0
- data/lib/c_lexer/version.rb +1 -1
- data/lib/c_lexer.rb +10 -0
- metadata +9 -10
data/ext/lexer/lexer.rl
CHANGED
@@ -1314,18 +1314,16 @@ void Init_lexer()
|
|
1314
1314
|
literal_extend_string(current_literal, escaped_char, ts, te);
|
1315
1315
|
}
|
1316
1316
|
} else {
|
1317
|
-
if (
|
1317
|
+
if (literal_squiggly_heredoc_p(current_literal) && newline_char_p(escaped_char)) {
|
1318
|
+
literal_extend_string(current_literal, tok(lexer, ts, te), ts, te);
|
1319
|
+
} else if (literal_supports_line_continuation_via_slash_p(current_literal) && newline_char_p(escaped_char)) {
|
1320
|
+
VALUE token = tok(lexer, ts, te);
|
1321
|
+
rb_funcall(token, rb_intern("gsub!"), 2, escaped_newline, blank_string);
|
1322
|
+
literal_extend_string(current_literal, token, ts, te);
|
1323
|
+
} else if (literal_regexp_p(current_literal)) {
|
1318
1324
|
VALUE token = tok(lexer, ts, te);
|
1319
1325
|
rb_funcall(token, rb_intern("gsub!"), 2, escaped_newline, blank_string);
|
1320
1326
|
literal_extend_string(current_literal, token, ts, te);
|
1321
|
-
} else if (literal_heredoc_p(current_literal) && newline_char_p(escaped_char)) {
|
1322
|
-
if (literal_squiggly_heredoc_p(current_literal)) {
|
1323
|
-
literal_extend_string(current_literal, tok(lexer, ts, te), ts, te);
|
1324
|
-
} else {
|
1325
|
-
VALUE token = tok(lexer, ts, te);
|
1326
|
-
rb_funcall(token, rb_intern("gsub!"), 2, escaped_newline, blank_string);
|
1327
|
-
literal_extend_string(current_literal, token, ts, te);
|
1328
|
-
}
|
1329
1327
|
} else if (lexer->escape == Qnil) {
|
1330
1328
|
literal_extend_string(current_literal, tok(lexer, ts, te), ts, te);
|
1331
1329
|
} else {
|
data/ext/lexer/literal/literal.h
CHANGED
@@ -58,5 +58,6 @@ static int newline_char_p(VALUE);
|
|
58
58
|
static void literal_infer_indent_level(literal*, VALUE);
|
59
59
|
static int next_state_for_literal(literal*);
|
60
60
|
static void literal_clear_buffer(literal*);
|
61
|
+
static int literal_supports_line_continuation_via_slash_p(literal*);
|
61
62
|
|
62
63
|
#endif
|
data/ext/lexer/literal/methods.h
CHANGED
@@ -369,3 +369,23 @@ inline int newline_char_p(VALUE str)
|
|
369
369
|
{
|
370
370
|
return RTEST(rb_str_equal(str, rb_str_new2("\n")));
|
371
371
|
}
|
372
|
+
|
373
|
+
static int literal_supports_line_continuation_via_slash_p(literal *lit)
|
374
|
+
{
|
375
|
+
if (literal_heredoc_p(lit) || literal_regexp_p(lit)) {
|
376
|
+
return 1;
|
377
|
+
}
|
378
|
+
|
379
|
+
switch (lit->str_type) {
|
380
|
+
case DOUBLE_QUOTE:
|
381
|
+
case PERCENT_Q:
|
382
|
+
case BIG_PERCENT_Q:
|
383
|
+
case BARE_PERCENT:
|
384
|
+
case SYM_DOUBLE_QUOT:
|
385
|
+
case PERCENT_X:
|
386
|
+
case BACKTICK:
|
387
|
+
return 1;
|
388
|
+
default:
|
389
|
+
return 0;
|
390
|
+
}
|
391
|
+
}
|
data/lib/c_lexer/version.rb
CHANGED
data/lib/c_lexer.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'c_lexer/version'
|
2
2
|
require 'parser/ruby25'
|
3
|
+
require 'parser/ruby26'
|
3
4
|
|
4
5
|
require_relative 'lexer'
|
5
6
|
|
@@ -74,6 +75,15 @@ module Parser
|
|
74
75
|
@lexer.static_env = @static_env
|
75
76
|
end
|
76
77
|
end
|
78
|
+
|
79
|
+
class Ruby26WithCLexer < Ruby26
|
80
|
+
def initialize(builder=Parser::Builders::Default.new)
|
81
|
+
super(builder)
|
82
|
+
@lexer = ::Parser::CLexer.new(version)
|
83
|
+
@lexer.diagnostics = @diagnostics
|
84
|
+
@lexer.static_env = @static_env
|
85
|
+
end
|
86
|
+
end
|
77
87
|
end
|
78
88
|
|
79
89
|
module CLexer
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: c_lexer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Bylich
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.6.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.6.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,8 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
188
|
- !ruby/object:Gem::Version
|
189
189
|
version: '0'
|
190
190
|
requirements: []
|
191
|
-
|
192
|
-
rubygems_version: 2.7.6
|
191
|
+
rubygems_version: 3.0.1
|
193
192
|
signing_key:
|
194
193
|
specification_version: 4
|
195
194
|
summary: A Ruby parser written in C
|