packcr 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +73 -0
- data/lib/packcr/cli.rb +18 -16
- data/lib/packcr/code_block.rb +0 -1
- data/lib/packcr/context.rb +20 -18
- data/lib/packcr/generated/context.rb +483 -0
- data/lib/packcr/generated/node/action_node.rb +60 -0
- data/lib/packcr/generated/node/alternate_node.rb +98 -0
- data/lib/packcr/generated/node/capture_node.rb +39 -0
- data/lib/packcr/generated/node/charclass_node.rb +372 -0
- data/lib/packcr/generated/node/eof_node.rb +20 -0
- data/lib/packcr/generated/node/error_node.rb +67 -0
- data/lib/packcr/generated/node/expand_node.rb +30 -0
- data/lib/packcr/generated/node/predicate_node.rb +140 -0
- data/lib/packcr/generated/node/quantity_node.rb +166 -0
- data/lib/packcr/generated/node/reference_node.rb +70 -0
- data/lib/packcr/generated/node/rule_node.rb +63 -0
- data/lib/packcr/generated/node/sequence_node.rb +42 -0
- data/lib/packcr/generated/node/string_node.rb +60 -0
- data/lib/packcr/generator.rb +2 -1
- data/lib/packcr/node/action_node.rb +4 -2
- data/lib/packcr/node/alternate_node.rb +3 -1
- data/lib/packcr/node/capture_node.rb +3 -1
- data/lib/packcr/node/charclass_node.rb +24 -28
- data/lib/packcr/node/eof_node.rb +4 -2
- data/lib/packcr/node/error_node.rb +3 -1
- data/lib/packcr/node/expand_node.rb +8 -5
- data/lib/packcr/node/predicate_node.rb +4 -2
- data/lib/packcr/node/quantity_node.rb +12 -10
- data/lib/packcr/node/reference_node.rb +11 -5
- data/lib/packcr/node/root_node.rb +1 -0
- data/lib/packcr/node/rule_node.rb +7 -4
- data/lib/packcr/node/sequence_node.rb +3 -1
- data/lib/packcr/node/string_node.rb +9 -6
- data/lib/packcr/node.rb +3 -5
- data/lib/packcr/parser.rb +4389 -4064
- data/lib/packcr/stream.rb +17 -12
- data/lib/packcr/templates/context/header.c.erb +3 -3
- data/lib/packcr/templates/context/source.c.erb +481 -690
- data/lib/packcr/templates/context/source.rb.erb +123 -171
- data/lib/packcr/templates/node/action.c.erb +5 -5
- data/lib/packcr/templates/node/action.rb.erb +2 -2
- data/lib/packcr/templates/node/alternate.c.erb +9 -9
- data/lib/packcr/templates/node/alternate.rb.erb +4 -5
- data/lib/packcr/templates/node/capture.c.erb +7 -7
- data/lib/packcr/templates/node/capture.rb.erb +4 -4
- data/lib/packcr/templates/node/charclass.c.erb +12 -12
- data/lib/packcr/templates/node/charclass.rb.erb +6 -6
- data/lib/packcr/templates/node/charclass_any.c.erb +3 -3
- data/lib/packcr/templates/node/charclass_any.rb.erb +2 -2
- data/lib/packcr/templates/node/charclass_fail.c.erb +1 -1
- data/lib/packcr/templates/node/charclass_one.c.erb +10 -10
- data/lib/packcr/templates/node/charclass_one.rb.erb +6 -6
- data/lib/packcr/templates/node/charclass_utf8.c.erb +8 -8
- data/lib/packcr/templates/node/charclass_utf8.rb.erb +3 -3
- data/lib/packcr/templates/node/charclass_utf8_reverse.rb.erb +5 -5
- data/lib/packcr/templates/node/eof.c.erb +1 -1
- data/lib/packcr/templates/node/error.c.erb +11 -11
- data/lib/packcr/templates/node/error.rb.erb +2 -2
- data/lib/packcr/templates/node/expand.c.erb +5 -5
- data/lib/packcr/templates/node/expand.rb.erb +3 -3
- data/lib/packcr/templates/node/predicate.c.erb +10 -10
- data/lib/packcr/templates/node/predicate.rb.erb +6 -6
- data/lib/packcr/templates/node/predicate_neg.c.erb +8 -8
- data/lib/packcr/templates/node/predicate_neg.rb.erb +6 -6
- data/lib/packcr/templates/node/quantity_many.c.erb +47 -0
- data/lib/packcr/templates/node/{quantify_many.rb.erb → quantity_many.rb.erb} +9 -9
- data/lib/packcr/templates/node/quantity_one.c.erb +23 -0
- data/lib/packcr/templates/node/{quantify_one.rb.erb → quantity_one.rb.erb} +8 -8
- data/lib/packcr/templates/node/reference.c.erb +14 -2
- data/lib/packcr/templates/node/reference.rb.erb +16 -4
- data/lib/packcr/templates/node/reference_reverse.rb.erb +16 -4
- data/lib/packcr/templates/node/rule.c.erb +14 -7
- data/lib/packcr/templates/node/rule.rb.erb +26 -19
- data/lib/packcr/templates/node/string_many.c.erb +6 -6
- data/lib/packcr/templates/node/string_many.rb.erb +3 -3
- data/lib/packcr/templates/node/string_one.c.erb +5 -5
- data/lib/packcr/templates/node/string_one.rb.erb +3 -3
- data/lib/packcr/util.rb +21 -16
- data/lib/packcr/version.rb +1 -1
- data/lib/packcr.rb +8 -11
- metadata +40 -10
- data/lib/packcr/templates/node/quantify_many.c.erb +0 -45
- data/lib/packcr/templates/node/quantify_one.c.erb +0 -21
- data/lib/packcr/tokenizer.rb +0 -2948
@@ -1,19 +1,26 @@
|
|
1
|
-
|
1
|
+
static packcr_thunk_chunk_t *packcr_evaluate_rule_<%= name %>(packcr_context_t *ctx, size_t offset<% if gen.location %>, packcr_location_t offset_loc<% end %>, packcr_rule_set_t *limits) {
|
2
|
+
packcr_thunk_chunk_t *const chunk = packcr_thunk_chunk__create(ctx);
|
3
|
+
chunk->pos = ctx->position_offset;
|
4
|
+
<%- if gen.location -%>
|
5
|
+
chunk->pos_loc = ctx->position_offset_loc;
|
6
|
+
<%- end -%>
|
7
|
+
PACKCR_DEBUG(ctx->auxil, PACKCR_DBG_EVALUATE, "<%= name %>", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos));
|
2
8
|
ctx->level++;
|
3
|
-
|
4
|
-
|
9
|
+
packcr_value_table__resize(ctx->auxil, &chunk->values, <%= vars.length %>);
|
10
|
+
packcr_capture_table__resize(ctx->auxil, &chunk->capts, <%= capts.length %>);
|
5
11
|
<%- if vars.length > 0 -%>
|
6
|
-
|
12
|
+
packcr_value_table__clear(ctx->auxil, &chunk->values);
|
7
13
|
<%- end -%>
|
8
14
|
<%- r = expr.reachability -%>
|
9
15
|
<%- -%><%= gen.generate_code(expr, 0, 4, false) -%>
|
10
16
|
ctx->level--;
|
11
|
-
|
17
|
+
PACKCR_DEBUG(ctx->auxil, PACKCR_DBG_MATCH, "<%= name %>", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->position_offset - chunk->pos));
|
12
18
|
return chunk;
|
13
19
|
<%- if r != Packcr::CODE_REACH__ALWAYS_SUCCEED -%>
|
14
20
|
L0000:;
|
15
21
|
ctx->level--;
|
16
|
-
|
17
|
-
|
22
|
+
PACKCR_DEBUG(ctx->auxil, PACKCR_DBG_NOMATCH, "<%= name %>", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->position_offset - chunk->pos));
|
23
|
+
packcr_thunk_chunk__destroy(ctx, chunk);
|
18
24
|
return NULL;
|
19
25
|
<%- end -%>
|
26
|
+
}
|
@@ -1,23 +1,30 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
answer.
|
4
|
-
<%-
|
5
|
-
answer.
|
6
|
-
<%-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
<%-
|
14
|
-
|
1
|
+
def evaluate_rule_<%= name %>(offset<% if gen.location %>, offset_loc<% end %>, limits: nil)
|
2
|
+
answer = ThunkChunk.new
|
3
|
+
answer.pos = @position_offset
|
4
|
+
<%- if gen.location -%>
|
5
|
+
answer.pos_loc = @position_offset_loc
|
6
|
+
<%- end -%>
|
7
|
+
debug { warn "#{ " " * @level}EVAL <%= name %> #{answer.pos} #{@buffer[answer.pos..-1].inspect}" }
|
8
|
+
@level += 1
|
9
|
+
answer.resize_captures(<%= capts.length %>)
|
10
|
+
<%- if vars.length > 0 -%>
|
11
|
+
answer.values = {}
|
12
|
+
<%- end -%>
|
13
|
+
<%- r = expr.reachability -%>
|
14
|
+
<%- if r == Packcr::CODE_REACH__ALWAYS_SUCCEED -%>
|
15
15
|
<%- -%><%= gen.generate_code(expr, 0, 2, false) -%>
|
16
16
|
@level -= 1
|
17
|
-
debug { warn "#{ " " * @level}MATCH <%= name %> #{answer.pos} #{@buffer[answer.pos...@
|
17
|
+
debug { warn "#{ " " * @level}MATCH <%= name %> #{answer.pos} #{@buffer[answer.pos...@position_offset].inspect}" }
|
18
18
|
return answer
|
19
|
+
<%- else -%>
|
20
|
+
catch(0) do
|
21
|
+
<%- -%><%= gen.generate_code(expr, 0, 4, false) -%>
|
22
|
+
@level -= 1
|
23
|
+
debug { warn "#{ " " * @level}MATCH <%= name %> #{answer.pos} #{@buffer[answer.pos...@position_offset].inspect}" }
|
24
|
+
return answer
|
25
|
+
end
|
26
|
+
@level -= 1
|
27
|
+
debug { warn "#{ " " * @level}NOMATCH <%= name %> #{answer.pos} #{@buffer[answer.pos...@position_offset].inspect}" }
|
28
|
+
return nil
|
29
|
+
<%- end -%>
|
19
30
|
end
|
20
|
-
@level -= 1
|
21
|
-
debug { warn "#{ " " * @level}NOMATCH <%= name %> #{answer.pos} #{@buffer[answer.pos...@cur].inspect}" }
|
22
|
-
return nil
|
23
|
-
<%- end -%>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
if (
|
2
|
-
|
2
|
+
packcr_refill_buffer(ctx, <%= n %>) < <%= n %> ||
|
3
3
|
<%- (n - 1).times do |i| -%>
|
4
|
-
(ctx->buffer.buf + ctx->
|
4
|
+
(ctx->buffer.buf + ctx->position_offset)[<%= i %>] != '<%= Packcr.escape_character(value[i]) %>' ||
|
5
5
|
<%- end -%>
|
6
|
-
(ctx->buffer.buf + ctx->
|
7
|
-
) goto L<%= "%04d"
|
6
|
+
(ctx->buffer.buf + ctx->position_offset)[<%= n - 1 %>] != '<%= Packcr.escape_character(value[n - 1]) %>'
|
7
|
+
) goto L<%= format("%04d", onfail) %>;
|
8
8
|
<%- if gen.location -%>
|
9
|
-
|
9
|
+
packcr_location_forward(&ctx->position_offset_loc, ctx->buffer.buf + ctx->position_offset, <%= n %>);
|
10
10
|
<%- end -%>
|
11
|
-
ctx->
|
11
|
+
ctx->position_offset += <%= n %>;
|
@@ -1,10 +1,10 @@
|
|
1
1
|
if (
|
2
2
|
refill_buffer(<%= n %>) < <%= n %> ||
|
3
|
-
@buffer[@
|
3
|
+
@buffer[@position_offset, <%= n %>] != <%= value[0, n].dump %>
|
4
4
|
)
|
5
5
|
throw(<%= onfail %>)
|
6
6
|
end
|
7
7
|
<%- if gen.location -%>
|
8
|
-
@
|
8
|
+
@position_offset_loc = @position_offset_loc.forward(@buffer, @position_offset, <%= n %>)
|
9
9
|
<%- end -%>
|
10
|
-
@
|
10
|
+
@position_offset += <%= n %>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
if (
|
2
|
-
|
3
|
-
ctx->buffer.buf[ctx->
|
4
|
-
) goto L<%= "%04d"
|
2
|
+
packcr_refill_buffer(ctx, 1) < 1 ||
|
3
|
+
ctx->buffer.buf[ctx->position_offset] != '<%= Packcr.escape_character(value[0]) %>'
|
4
|
+
) goto L<%= format("%04d", onfail) %>;
|
5
5
|
<%- if gen.location -%>
|
6
|
-
|
6
|
+
packcr_location_forward(&ctx->position_offset_loc, ctx->buffer.buf + ctx->position_offset, 1);
|
7
7
|
<%- end -%>
|
8
|
-
ctx->
|
8
|
+
ctx->position_offset++;
|
@@ -1,10 +1,10 @@
|
|
1
1
|
if (
|
2
2
|
refill_buffer(1) < 1 ||
|
3
|
-
@buffer[@
|
3
|
+
@buffer[@position_offset] != "<%= Packcr.escape_character(value[0]) %>"
|
4
4
|
)
|
5
5
|
throw(<%= onfail %>)
|
6
6
|
end
|
7
7
|
<%- if gen.location -%>
|
8
|
-
@
|
8
|
+
@position_offset_loc = @position_offset_loc.forward(@buffer, @position_offset, 1)
|
9
9
|
<%- end -%>
|
10
|
-
@
|
10
|
+
@position_offset += 1
|
data/lib/packcr/util.rb
CHANGED
@@ -5,10 +5,10 @@ class Packcr
|
|
5
5
|
def unescape_string(str, is_charclass)
|
6
6
|
if is_charclass
|
7
7
|
str.gsub!("\\" * 2) { "\\" * 4 }
|
8
|
-
str.gsub!("\"" ) { "\\\"" }
|
9
8
|
end
|
9
|
+
str.gsub!("\"") { "\\\"" }
|
10
10
|
str.gsub!(/\\(.)/) do
|
11
|
-
c =
|
11
|
+
c = ::Regexp.last_match(1)
|
12
12
|
case c
|
13
13
|
when "0"
|
14
14
|
"\\x00"
|
@@ -19,7 +19,7 @@ class Packcr
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
str.gsub!(/[^\x00-\x7f]/) do
|
22
|
-
"\\x%02x"
|
22
|
+
format("\\x%02x", ::Regexp.last_match(0).ord)
|
23
23
|
end
|
24
24
|
str.replace "\"#{str}\"".undump
|
25
25
|
end
|
@@ -31,19 +31,20 @@ class Packcr
|
|
31
31
|
def escape_string(str)
|
32
32
|
str = str.b
|
33
33
|
str.gsub(/(\0+)|(\e+)|("+)|('+)|(\\+)|((?:(?![\0\e"'\\])[ -~])+)|([\x01-\x1a\x1c-\x1f\x7f-\xff]+)/n) do
|
34
|
-
n =
|
35
|
-
next "\\0" * n if
|
36
|
-
next "\\x1b" * n if
|
37
|
-
next "\\\"" * n if
|
38
|
-
next "
|
39
|
-
next "\\\\"
|
40
|
-
next
|
41
|
-
|
34
|
+
n = ::Regexp.last_match(0).size
|
35
|
+
next "\\0" * n if ::Regexp.last_match(1)
|
36
|
+
next "\\x1b" * n if ::Regexp.last_match(2)
|
37
|
+
next "\\\"" * n if ::Regexp.last_match(3)
|
38
|
+
next "\\'" * n if ::Regexp.last_match(4)
|
39
|
+
next "\\\\" * n if ::Regexp.last_match(5)
|
40
|
+
next ::Regexp.last_match(6) if ::Regexp.last_match(6)
|
41
|
+
|
42
|
+
::Regexp.last_match(7).dump[1..-2].downcase
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
46
|
def dump_integer_value(value)
|
46
|
-
if value
|
47
|
+
if value.nil?
|
47
48
|
$stdout.print "void"
|
48
49
|
else
|
49
50
|
$stdout.print value
|
@@ -62,8 +63,8 @@ class Packcr
|
|
62
63
|
offset = 0
|
63
64
|
spaces.tr!("\v\f", " ")
|
64
65
|
spaces.gsub!(/\t+/) do
|
65
|
-
chars =
|
66
|
-
o = 8 *
|
66
|
+
chars = ::Regexp.last_match.pre_match.length
|
67
|
+
o = (8 * ::Regexp.last_match(0).length) - ((offset + chars) % 8)
|
67
68
|
offset = (7 - chars) % 8
|
68
69
|
" " * o
|
69
70
|
end
|
@@ -75,15 +76,19 @@ class Packcr
|
|
75
76
|
erb = ERB.new(File.read(template_path), trim_mode: "%-")
|
76
77
|
erb.filename = template_path
|
77
78
|
result = erb.result(b)
|
79
|
+
format_code(result, indent: indent, unwrap: unwrap)
|
80
|
+
end
|
81
|
+
|
82
|
+
def format_code(result, indent: 0, unwrap: false)
|
78
83
|
if unwrap
|
79
84
|
result.gsub!(/\A\{|\}\z/, "")
|
80
85
|
indent -= 4
|
81
86
|
end
|
82
87
|
result.gsub!(/^(?!$)/, " " * indent)
|
83
|
-
result.gsub!(/^( *?) {0,4}<<<</) {
|
88
|
+
result.gsub!(/^( *?) {0,4}<<<</) { ::Regexp.last_match(1) }
|
84
89
|
result
|
85
90
|
end
|
86
91
|
end
|
87
92
|
|
88
93
|
extend Util
|
89
|
-
end
|
94
|
+
end
|
data/lib/packcr/version.rb
CHANGED
data/lib/packcr.rb
CHANGED
@@ -1,14 +1,3 @@
|
|
1
|
-
class Packcr
|
2
|
-
end
|
3
|
-
|
4
|
-
require "packcr/util"
|
5
|
-
require "packcr/code_block"
|
6
|
-
require "packcr/stream"
|
7
|
-
require "packcr/generator"
|
8
|
-
require "packcr/node"
|
9
|
-
require "packcr/context"
|
10
|
-
require "packcr/version"
|
11
|
-
|
12
1
|
class Packcr
|
13
2
|
CODE_REACH__BOTH = 0
|
14
3
|
CODE_REACH__ALWAYS_SUCCEED = 1
|
@@ -30,3 +19,11 @@ class Packcr
|
|
30
19
|
end
|
31
20
|
end
|
32
21
|
end
|
22
|
+
|
23
|
+
require "packcr/util"
|
24
|
+
require "packcr/code_block"
|
25
|
+
require "packcr/stream"
|
26
|
+
require "packcr/generator"
|
27
|
+
require "packcr/node"
|
28
|
+
require "packcr/context"
|
29
|
+
require "packcr/version"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: packcr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wanabe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.43.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.43.0
|
55
69
|
description:
|
56
70
|
email:
|
57
71
|
executables:
|
@@ -59,12 +73,28 @@ executables:
|
|
59
73
|
extensions: []
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
76
|
+
- LICENSE
|
77
|
+
- README.md
|
62
78
|
- exe/packcr
|
63
79
|
- lib/packcr.rb
|
64
80
|
- lib/packcr/broadcast.rb
|
65
81
|
- lib/packcr/cli.rb
|
66
82
|
- lib/packcr/code_block.rb
|
67
83
|
- lib/packcr/context.rb
|
84
|
+
- lib/packcr/generated/context.rb
|
85
|
+
- lib/packcr/generated/node/action_node.rb
|
86
|
+
- lib/packcr/generated/node/alternate_node.rb
|
87
|
+
- lib/packcr/generated/node/capture_node.rb
|
88
|
+
- lib/packcr/generated/node/charclass_node.rb
|
89
|
+
- lib/packcr/generated/node/eof_node.rb
|
90
|
+
- lib/packcr/generated/node/error_node.rb
|
91
|
+
- lib/packcr/generated/node/expand_node.rb
|
92
|
+
- lib/packcr/generated/node/predicate_node.rb
|
93
|
+
- lib/packcr/generated/node/quantity_node.rb
|
94
|
+
- lib/packcr/generated/node/reference_node.rb
|
95
|
+
- lib/packcr/generated/node/rule_node.rb
|
96
|
+
- lib/packcr/generated/node/sequence_node.rb
|
97
|
+
- lib/packcr/generated/node/string_node.rb
|
68
98
|
- lib/packcr/generator.rb
|
69
99
|
- lib/packcr/node.rb
|
70
100
|
- lib/packcr/node/action_node.rb
|
@@ -113,10 +143,10 @@ files:
|
|
113
143
|
- lib/packcr/templates/node/predicate.rb.erb
|
114
144
|
- lib/packcr/templates/node/predicate_neg.c.erb
|
115
145
|
- lib/packcr/templates/node/predicate_neg.rb.erb
|
116
|
-
- lib/packcr/templates/node/
|
117
|
-
- lib/packcr/templates/node/
|
118
|
-
- lib/packcr/templates/node/
|
119
|
-
- lib/packcr/templates/node/
|
146
|
+
- lib/packcr/templates/node/quantity_many.c.erb
|
147
|
+
- lib/packcr/templates/node/quantity_many.rb.erb
|
148
|
+
- lib/packcr/templates/node/quantity_one.c.erb
|
149
|
+
- lib/packcr/templates/node/quantity_one.rb.erb
|
120
150
|
- lib/packcr/templates/node/reference.c.erb
|
121
151
|
- lib/packcr/templates/node/reference.rb.erb
|
122
152
|
- lib/packcr/templates/node/reference_reverse.rb.erb
|
@@ -128,13 +158,13 @@ files:
|
|
128
158
|
- lib/packcr/templates/node/string_many.rb.erb
|
129
159
|
- lib/packcr/templates/node/string_one.c.erb
|
130
160
|
- lib/packcr/templates/node/string_one.rb.erb
|
131
|
-
- lib/packcr/tokenizer.rb
|
132
161
|
- lib/packcr/util.rb
|
133
162
|
- lib/packcr/version.rb
|
134
163
|
homepage: https://github.com/wanabe/packcr
|
135
164
|
licenses:
|
136
165
|
- MIT
|
137
|
-
metadata:
|
166
|
+
metadata:
|
167
|
+
rubygems_mfa_required: 'true'
|
138
168
|
post_install_message:
|
139
169
|
rdoc_options: []
|
140
170
|
require_paths:
|
@@ -143,14 +173,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
173
|
requirements:
|
144
174
|
- - ">="
|
145
175
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
176
|
+
version: 2.7.0
|
147
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
178
|
requirements:
|
149
179
|
- - ">="
|
150
180
|
- !ruby/object:Gem::Version
|
151
181
|
version: '0'
|
152
182
|
requirements: []
|
153
|
-
rubygems_version: 3.4.
|
183
|
+
rubygems_version: 3.4.6
|
154
184
|
signing_key:
|
155
185
|
specification_version: 4
|
156
186
|
summary: Parser generator for C or Ruby
|
@@ -1,45 +0,0 @@
|
|
1
|
-
{
|
2
|
-
<%- if min > 0 -%>
|
3
|
-
const size_t p0 = ctx->cur;
|
4
|
-
<%- if gen.location -%>
|
5
|
-
const pcc_location_t p0_loc = ctx->cur_loc;
|
6
|
-
<%- end -%>
|
7
|
-
const size_t n0 = chunk->thunks.len;
|
8
|
-
<%- end -%>
|
9
|
-
int i;
|
10
|
-
<%- if max < 0 -%>
|
11
|
-
for (i = 0;; i++) {
|
12
|
-
<%- else -%>
|
13
|
-
for (i = 0; i < <%= max %>; i++) {
|
14
|
-
<%- end -%>
|
15
|
-
const size_t p = ctx->cur;
|
16
|
-
<%- if gen.location -%>
|
17
|
-
const pcc_location_t p_loc = ctx->cur_loc;
|
18
|
-
<%- end -%>
|
19
|
-
const size_t n = chunk->thunks.len;
|
20
|
-
<%- l = gen.next_label -%>
|
21
|
-
<%- r = expr.reachability -%>
|
22
|
-
<%= gen.generate_code(expr, l, 8, false) -%>
|
23
|
-
if (ctx->cur == p) break;
|
24
|
-
<%- if r != Packcr::CODE_REACH__ALWAYS_SUCCEED -%>
|
25
|
-
continue;
|
26
|
-
L<%= "%04d" % l %>:;
|
27
|
-
ctx->cur = p;
|
28
|
-
<%- if gen.location -%>
|
29
|
-
ctx->cur_loc = p_loc;
|
30
|
-
<%- end -%>
|
31
|
-
pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
|
32
|
-
break;
|
33
|
-
<%- end -%>
|
34
|
-
}
|
35
|
-
<%- if min > 0 -%>
|
36
|
-
if (i < <%= min %>) {
|
37
|
-
ctx->cur = p0;
|
38
|
-
<%- if gen.location -%>
|
39
|
-
ctx->cur_loc = p0_loc;
|
40
|
-
<%- end -%>
|
41
|
-
pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0);
|
42
|
-
goto L<%= "%04d" % onfail %>;
|
43
|
-
}
|
44
|
-
<%- end -%>
|
45
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
{
|
2
|
-
<%- l = gen.next_label -%>
|
3
|
-
const size_t p = ctx->cur;
|
4
|
-
<%- if gen.location -%>
|
5
|
-
const pcc_location_t p_loc = ctx->cur_loc;
|
6
|
-
<%- end -%>
|
7
|
-
const size_t n = chunk->thunks.len;
|
8
|
-
<%- r = expr.reachability -%>
|
9
|
-
<%= gen.generate_code(expr, l, 4, false) -%>
|
10
|
-
<%- if r != Packcr::CODE_REACH__ALWAYS_SUCCEED -%>
|
11
|
-
<%- m = gen.next_label -%>
|
12
|
-
goto L<%= "%04d" % m %>;
|
13
|
-
L<%= "%04d" % l %>:;
|
14
|
-
<%- if gen.location -%>
|
15
|
-
ctx->cur_loc = p_loc;
|
16
|
-
<%- end -%>
|
17
|
-
ctx->cur = p;
|
18
|
-
pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n);
|
19
|
-
L<%= "%04d" % m %>:;
|
20
|
-
<%- end -%>
|
21
|
-
}
|