treetop 1.6.14 → 1.6.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/treetop/compiler/metagrammar.rb +224 -4
- data/lib/treetop/compiler/metagrammar.treetop +16 -1
- data/lib/treetop/compiler/node_classes/grammar.rb +1 -1
- data/lib/treetop/version.rb +1 -1
- data/treetop.gemspec +2 -3
- metadata +5 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c975c5bf78d8e2cb04b79326c830723e2186fcf272c3fac468b06c1d4ec047aa
|
|
4
|
+
data.tar.gz: 0bdc88dcddcfbe354c1d15e74fa49712bee7dc0506b1e2a6bc5702f7e6926053
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 11564890bd345622a58d3e875046ffb68b340de8c82af7ba3de6c80d8b522ceb573706d13ed9e2199529af5f74c17e1e91232983e33707d9c6162f185eb31527
|
|
7
|
+
data.tar.gz: 216606034e72709ab75dcaccda6e09ffbddaf2bcf49b88576362d1b5a79084faf8486a69edf31c0e906072d725e86b2772a4e19f35a199518b42fb03b8d28a32
|
data/README.md
CHANGED
|
@@ -799,13 +799,19 @@ module Treetop
|
|
|
799
799
|
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
|
800
800
|
r0 = r1
|
|
801
801
|
else
|
|
802
|
-
r2 =
|
|
802
|
+
r2 = _nt_parsing_endless_rule
|
|
803
803
|
if r2
|
|
804
804
|
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
|
805
805
|
r0 = r2
|
|
806
806
|
else
|
|
807
|
-
|
|
808
|
-
|
|
807
|
+
r3 = _nt_include_declaration
|
|
808
|
+
if r3
|
|
809
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
|
810
|
+
r0 = r3
|
|
811
|
+
else
|
|
812
|
+
@index = i0
|
|
813
|
+
r0 = nil
|
|
814
|
+
end
|
|
809
815
|
end
|
|
810
816
|
end
|
|
811
817
|
|
|
@@ -1028,6 +1034,172 @@ module Treetop
|
|
|
1028
1034
|
r0
|
|
1029
1035
|
end
|
|
1030
1036
|
|
|
1037
|
+
module ParsingEndlessRule0
|
|
1038
|
+
def nonterminal
|
|
1039
|
+
elements[2]
|
|
1040
|
+
end
|
|
1041
|
+
|
|
1042
|
+
def parsing_expression
|
|
1043
|
+
elements[6]
|
|
1044
|
+
end
|
|
1045
|
+
|
|
1046
|
+
end
|
|
1047
|
+
|
|
1048
|
+
def _nt_parsing_endless_rule
|
|
1049
|
+
start_index = index
|
|
1050
|
+
if node_cache[:parsing_endless_rule].has_key?(index)
|
|
1051
|
+
cached = node_cache[:parsing_endless_rule][index]
|
|
1052
|
+
if cached
|
|
1053
|
+
node_cache[:parsing_endless_rule][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
|
1054
|
+
@index = cached.interval.end
|
|
1055
|
+
end
|
|
1056
|
+
return cached
|
|
1057
|
+
end
|
|
1058
|
+
|
|
1059
|
+
i0, s0 = index, []
|
|
1060
|
+
if (match_len = has_terminal?('rule', false, index))
|
|
1061
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
|
1062
|
+
@index += match_len
|
|
1063
|
+
else
|
|
1064
|
+
terminal_parse_failure('\'rule\'')
|
|
1065
|
+
r1 = nil
|
|
1066
|
+
end
|
|
1067
|
+
s0 << r1
|
|
1068
|
+
if r1
|
|
1069
|
+
s2, i2 = [], index
|
|
1070
|
+
loop do
|
|
1071
|
+
r3 = _nt_nbwhite
|
|
1072
|
+
if r3
|
|
1073
|
+
s2 << r3
|
|
1074
|
+
else
|
|
1075
|
+
break
|
|
1076
|
+
end
|
|
1077
|
+
end
|
|
1078
|
+
if s2.empty?
|
|
1079
|
+
@index = i2
|
|
1080
|
+
r2 = nil
|
|
1081
|
+
else
|
|
1082
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
|
1083
|
+
end
|
|
1084
|
+
s0 << r2
|
|
1085
|
+
if r2
|
|
1086
|
+
r4 = _nt_nonterminal
|
|
1087
|
+
s0 << r4
|
|
1088
|
+
if r4
|
|
1089
|
+
s5, i5 = [], index
|
|
1090
|
+
loop do
|
|
1091
|
+
r6 = _nt_nbwhite
|
|
1092
|
+
if r6
|
|
1093
|
+
s5 << r6
|
|
1094
|
+
else
|
|
1095
|
+
break
|
|
1096
|
+
end
|
|
1097
|
+
end
|
|
1098
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
|
1099
|
+
s0 << r5
|
|
1100
|
+
if r5
|
|
1101
|
+
if (match_len = has_terminal?('=', false, index))
|
|
1102
|
+
r7 = true
|
|
1103
|
+
@index += match_len
|
|
1104
|
+
else
|
|
1105
|
+
terminal_parse_failure('\'=\'')
|
|
1106
|
+
r7 = nil
|
|
1107
|
+
end
|
|
1108
|
+
s0 << r7
|
|
1109
|
+
if r7
|
|
1110
|
+
s8, i8 = [], index
|
|
1111
|
+
loop do
|
|
1112
|
+
r9 = _nt_nbwhite
|
|
1113
|
+
if r9
|
|
1114
|
+
s8 << r9
|
|
1115
|
+
else
|
|
1116
|
+
break
|
|
1117
|
+
end
|
|
1118
|
+
end
|
|
1119
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
|
1120
|
+
s0 << r8
|
|
1121
|
+
if r8
|
|
1122
|
+
r10 = _nt_parsing_expression
|
|
1123
|
+
s0 << r10
|
|
1124
|
+
if r10
|
|
1125
|
+
i11 = index
|
|
1126
|
+
r12 = lambda { |v| v.last.text_value !~ /[\n\r]/ }.call(s0)
|
|
1127
|
+
if !r12
|
|
1128
|
+
terminal_parse_failure("<semantic predicate>")
|
|
1129
|
+
end
|
|
1130
|
+
if r12
|
|
1131
|
+
@index = i11
|
|
1132
|
+
r11 = instantiate_node(SyntaxNode,input, index...index)
|
|
1133
|
+
else
|
|
1134
|
+
@index = i11
|
|
1135
|
+
r11 = nil
|
|
1136
|
+
end
|
|
1137
|
+
s0 << r11
|
|
1138
|
+
if r11
|
|
1139
|
+
s13, i13 = [], index
|
|
1140
|
+
loop do
|
|
1141
|
+
i14 = index
|
|
1142
|
+
r15 = _nt_nbwhite
|
|
1143
|
+
if r15
|
|
1144
|
+
r15 = SyntaxNode.new(input, (index-1)...index) if r15 == true
|
|
1145
|
+
r14 = r15
|
|
1146
|
+
else
|
|
1147
|
+
r16 = _nt_comment_to_eol
|
|
1148
|
+
if r16
|
|
1149
|
+
r16 = SyntaxNode.new(input, (index-1)...index) if r16 == true
|
|
1150
|
+
r14 = r16
|
|
1151
|
+
else
|
|
1152
|
+
@index = i14
|
|
1153
|
+
r14 = nil
|
|
1154
|
+
end
|
|
1155
|
+
end
|
|
1156
|
+
if r14
|
|
1157
|
+
s13 << r14
|
|
1158
|
+
else
|
|
1159
|
+
break
|
|
1160
|
+
end
|
|
1161
|
+
end
|
|
1162
|
+
r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
|
|
1163
|
+
s0 << r13
|
|
1164
|
+
if r13
|
|
1165
|
+
s17, i17 = [], index
|
|
1166
|
+
loop do
|
|
1167
|
+
r18 = _nt_eol
|
|
1168
|
+
if r18
|
|
1169
|
+
s17 << r18
|
|
1170
|
+
else
|
|
1171
|
+
break
|
|
1172
|
+
end
|
|
1173
|
+
end
|
|
1174
|
+
if s17.empty?
|
|
1175
|
+
@index = i17
|
|
1176
|
+
r17 = nil
|
|
1177
|
+
else
|
|
1178
|
+
r17 = instantiate_node(SyntaxNode,input, i17...index, s17)
|
|
1179
|
+
end
|
|
1180
|
+
s0 << r17
|
|
1181
|
+
end
|
|
1182
|
+
end
|
|
1183
|
+
end
|
|
1184
|
+
end
|
|
1185
|
+
end
|
|
1186
|
+
end
|
|
1187
|
+
end
|
|
1188
|
+
end
|
|
1189
|
+
end
|
|
1190
|
+
if s0.last
|
|
1191
|
+
r0 = instantiate_node(ParsingRule,input, i0...index, s0)
|
|
1192
|
+
r0.extend(ParsingEndlessRule0)
|
|
1193
|
+
else
|
|
1194
|
+
@index = i0
|
|
1195
|
+
r0 = nil
|
|
1196
|
+
end
|
|
1197
|
+
|
|
1198
|
+
node_cache[:parsing_endless_rule][start_index] = r0
|
|
1199
|
+
|
|
1200
|
+
r0
|
|
1201
|
+
end
|
|
1202
|
+
|
|
1031
1203
|
def _nt_parsing_expression
|
|
1032
1204
|
start_index = index
|
|
1033
1205
|
if node_cache[:parsing_expression].has_key?(index)
|
|
@@ -4207,6 +4379,54 @@ module Treetop
|
|
|
4207
4379
|
r0
|
|
4208
4380
|
end
|
|
4209
4381
|
|
|
4382
|
+
def _nt_nbwhite
|
|
4383
|
+
start_index = index
|
|
4384
|
+
if node_cache[:nbwhite].has_key?(index)
|
|
4385
|
+
cached = node_cache[:nbwhite][index]
|
|
4386
|
+
if cached
|
|
4387
|
+
node_cache[:nbwhite][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
|
4388
|
+
@index = cached.interval.end
|
|
4389
|
+
end
|
|
4390
|
+
return cached
|
|
4391
|
+
end
|
|
4392
|
+
|
|
4393
|
+
if has_terminal?(@regexps[gr = '\A[ \\t]'] ||= Regexp.new(gr), :regexp, index)
|
|
4394
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
4395
|
+
@index += 1
|
|
4396
|
+
else
|
|
4397
|
+
terminal_parse_failure('[ \\t]')
|
|
4398
|
+
r0 = nil
|
|
4399
|
+
end
|
|
4400
|
+
|
|
4401
|
+
node_cache[:nbwhite][start_index] = r0
|
|
4402
|
+
|
|
4403
|
+
r0
|
|
4404
|
+
end
|
|
4405
|
+
|
|
4406
|
+
def _nt_eol
|
|
4407
|
+
start_index = index
|
|
4408
|
+
if node_cache[:eol].has_key?(index)
|
|
4409
|
+
cached = node_cache[:eol][index]
|
|
4410
|
+
if cached
|
|
4411
|
+
node_cache[:eol][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
|
4412
|
+
@index = cached.interval.end
|
|
4413
|
+
end
|
|
4414
|
+
return cached
|
|
4415
|
+
end
|
|
4416
|
+
|
|
4417
|
+
if has_terminal?(@regexps[gr = '\A[\\n\\r]'] ||= Regexp.new(gr), :regexp, index)
|
|
4418
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
|
4419
|
+
@index += 1
|
|
4420
|
+
else
|
|
4421
|
+
terminal_parse_failure('[\\n\\r]')
|
|
4422
|
+
r0 = nil
|
|
4423
|
+
end
|
|
4424
|
+
|
|
4425
|
+
node_cache[:eol][start_index] = r0
|
|
4426
|
+
|
|
4427
|
+
r0
|
|
4428
|
+
end
|
|
4429
|
+
|
|
4210
4430
|
def _nt_white
|
|
4211
4431
|
start_index = index
|
|
4212
4432
|
if node_cache[:white].has_key?(index)
|
|
@@ -4237,7 +4457,7 @@ module Treetop
|
|
|
4237
4457
|
end
|
|
4238
4458
|
end
|
|
4239
4459
|
|
|
4240
|
-
MetagrammarParser = Metagrammar::Parser
|
|
4460
|
+
remove_const(:MetagrammarParser) if const_defined?(:MetagrammarParser); MetagrammarParser = Metagrammar::Parser
|
|
4241
4461
|
|
|
4242
4462
|
end
|
|
4243
4463
|
end
|
|
@@ -55,7 +55,7 @@ module Treetop
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
rule declaration
|
|
58
|
-
parsing_rule / include_declaration
|
|
58
|
+
parsing_rule / parsing_endless_rule / include_declaration
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
rule include_declaration
|
|
@@ -70,6 +70,13 @@ module Treetop
|
|
|
70
70
|
'rule' space nonterminal space ('do' space)? parsing_expression space 'end' <ParsingRule>
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
+
rule parsing_endless_rule
|
|
74
|
+
'rule' nbwhite+ nonterminal nbwhite* '=' nbwhite*
|
|
75
|
+
parsing_expression &{ |v| v.last.text_value !~ /[\n\r]/ } # Parsing expression must not break line
|
|
76
|
+
(nbwhite / comment_to_eol)* eol+
|
|
77
|
+
<ParsingRule>
|
|
78
|
+
end
|
|
79
|
+
|
|
73
80
|
rule parsing_expression
|
|
74
81
|
choice / sequence / primary
|
|
75
82
|
end
|
|
@@ -578,6 +585,14 @@ module Treetop
|
|
|
578
585
|
'#' (!"\n" .)*
|
|
579
586
|
end
|
|
580
587
|
|
|
588
|
+
rule nbwhite
|
|
589
|
+
[ \t]
|
|
590
|
+
end
|
|
591
|
+
|
|
592
|
+
rule eol
|
|
593
|
+
[\n\r]
|
|
594
|
+
end
|
|
595
|
+
|
|
581
596
|
rule white
|
|
582
597
|
[ \t\n\r]
|
|
583
598
|
end
|
|
@@ -15,7 +15,7 @@ module Treetop
|
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
builder.newline
|
|
18
|
-
builder << "#{parser_name} = #{grammar_name.text_value}::Parser"
|
|
18
|
+
builder << "remove_const(:#{parser_name}) if const_defined?(:#{parser_name}); #{parser_name} = #{grammar_name.text_value}::Parser"
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def indent_level
|
data/lib/treetop/version.rb
CHANGED
data/treetop.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
spec.authors = ["Nathan Sobo", "Clifford Heath"]
|
|
11
11
|
|
|
12
12
|
spec.email = "cliffordheath@gmail.com"
|
|
13
|
-
spec.date = Date.
|
|
13
|
+
spec.date = Date.parse(`git show -s --format=%ci`)
|
|
14
14
|
spec.summary = "A Ruby-based text parsing and interpretation DSL"
|
|
15
15
|
spec.description = "A Parsing Expression Grammar (PEG) Parser generator DSL for Ruby"
|
|
16
16
|
spec.homepage = "https://github.com/cjheath/treetop"
|
|
@@ -25,10 +25,9 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
]
|
|
26
26
|
|
|
27
27
|
spec.add_runtime_dependency(%q<polyglot>, ["~> 0.3"])
|
|
28
|
-
spec.add_development_dependency(%q<activesupport>, [">= 4"])
|
|
29
28
|
spec.add_development_dependency(%q<i18n>, ["~> 1.0"])
|
|
30
29
|
spec.add_development_dependency(%q<rr>, ["~> 3.0"])
|
|
31
30
|
spec.add_development_dependency(%q<rspec>, ["~> 3"])
|
|
32
|
-
spec.add_development_dependency(%q<rake>, ["
|
|
31
|
+
spec.add_development_dependency(%q<rake>, ["~> 11"])
|
|
33
32
|
end
|
|
34
33
|
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: treetop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.6.
|
|
4
|
+
version: 1.6.16
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nathan Sobo
|
|
8
8
|
- Clifford Heath
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date: 2025-
|
|
11
|
+
date: 2025-11-10 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: polyglot
|
|
@@ -25,20 +24,6 @@ dependencies:
|
|
|
25
24
|
- - "~>"
|
|
26
25
|
- !ruby/object:Gem::Version
|
|
27
26
|
version: '0.3'
|
|
28
|
-
- !ruby/object:Gem::Dependency
|
|
29
|
-
name: activesupport
|
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
|
31
|
-
requirements:
|
|
32
|
-
- - ">="
|
|
33
|
-
- !ruby/object:Gem::Version
|
|
34
|
-
version: '4'
|
|
35
|
-
type: :development
|
|
36
|
-
prerelease: false
|
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
-
requirements:
|
|
39
|
-
- - ">="
|
|
40
|
-
- !ruby/object:Gem::Version
|
|
41
|
-
version: '4'
|
|
42
27
|
- !ruby/object:Gem::Dependency
|
|
43
28
|
name: i18n
|
|
44
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -85,14 +70,14 @@ dependencies:
|
|
|
85
70
|
name: rake
|
|
86
71
|
requirement: !ruby/object:Gem::Requirement
|
|
87
72
|
requirements:
|
|
88
|
-
- - "
|
|
73
|
+
- - "~>"
|
|
89
74
|
- !ruby/object:Gem::Version
|
|
90
75
|
version: '11'
|
|
91
76
|
type: :development
|
|
92
77
|
prerelease: false
|
|
93
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
94
79
|
requirements:
|
|
95
|
-
- - "
|
|
80
|
+
- - "~>"
|
|
96
81
|
- !ruby/object:Gem::Version
|
|
97
82
|
version: '11'
|
|
98
83
|
description: A Parsing Expression Grammar (PEG) Parser generator DSL for Ruby
|
|
@@ -183,7 +168,6 @@ homepage: https://github.com/cjheath/treetop
|
|
|
183
168
|
licenses:
|
|
184
169
|
- MIT
|
|
185
170
|
metadata: {}
|
|
186
|
-
post_install_message:
|
|
187
171
|
rdoc_options: []
|
|
188
172
|
require_paths:
|
|
189
173
|
- lib
|
|
@@ -198,8 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
198
182
|
- !ruby/object:Gem::Version
|
|
199
183
|
version: '0'
|
|
200
184
|
requirements: []
|
|
201
|
-
rubygems_version: 3.
|
|
202
|
-
signing_key:
|
|
185
|
+
rubygems_version: 3.6.9
|
|
203
186
|
specification_version: 4
|
|
204
187
|
summary: A Ruby-based text parsing and interpretation DSL
|
|
205
188
|
test_files: []
|