expressir 2.4.56-arm-linux → 2.4.58-arm-linux
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/lib/expressir/3.2/expressir_core.so +0 -0
- data/lib/expressir/3.3/expressir_core.so +0 -0
- data/lib/expressir/3.4/expressir_core.so +0 -0
- data/lib/expressir/4.0/expressir_core.so +0 -0
- data/lib/expressir/express/core.rb +7 -6
- data/lib/expressir/express/formatters/remark_formatter.rb +29 -4
- data/lib/expressir/express/grammar/parser.rb +20 -0
- data/lib/expressir/express/parser.rb +16 -7
- data/lib/expressir/express/remark_attacher.rb +3 -2
- data/lib/expressir/express/remark_scanner.rb +83 -18
- data/lib/expressir/model/remark_format.rb +7 -0
- data/lib/expressir/model/remark_info.rb +20 -6
- data/lib/expressir/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2e9037c9969c05edb5084218ef38de0fb46fb70f4f958449437a98f85f3c3edf
|
|
4
|
+
data.tar.gz: 75f12526be071f53d82e04dc5b78de697111a9705a872309ae62558331211db8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eec8ce3ffb7afc50f28ebcf654ead836cc2c2e1a0068ad02b7dfbc2e3efcfc98fc763aa4b03d9817a62850c2de23b81d81f3206dab60c9b8527add85ef444b88
|
|
7
|
+
data.tar.gz: 3ca00c2a9ffb6b8049b12829d9e9ddec54f8a2f40a2bd665d3d0f418d6671c374b09fa782f474611b8142f65f31c9f94a432ef6e004a2bb53cb25889cbb94661
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -44,20 +44,21 @@ module Expressir
|
|
|
44
44
|
# attachment run in the core (issue #20): the wire carries the
|
|
45
45
|
# attached remarks before hydration, so the Ruby RemarkAttacher
|
|
46
46
|
# never runs on this lane.
|
|
47
|
-
def self.parse_to_model_attached(source, path)
|
|
48
|
-
::Expressir::Core.parse_to_model_attached(source, path)
|
|
47
|
+
def self.parse_to_model_attached(source, path, annotations: false)
|
|
48
|
+
::Expressir::Core.parse_to_model_attached(source, path, annotations)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
# Like parse_to_model_attached, but also returns the attached
|
|
52
52
|
# wire JSON string ([model, wire_json]) so the file retains a
|
|
53
53
|
# lossless handle for the Rust formatter (issue #22).
|
|
54
|
-
def self.parse_to_model_attached_with_wire(source, path)
|
|
54
|
+
def self.parse_to_model_attached_with_wire(source, path, annotations: false)
|
|
55
55
|
unless NATIVE_AVAILABLE &&
|
|
56
56
|
::Expressir::Core.respond_to?(:parse_to_model_attached_with_wire)
|
|
57
57
|
raise NotImplementedError, "core wire retention unavailable"
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
model, wire_json =
|
|
60
|
+
model, wire_json =
|
|
61
|
+
::Expressir::Core.parse_to_model_attached_with_wire(source, path, annotations)
|
|
61
62
|
model.wire_parents
|
|
62
63
|
model.core_wire = wire_json
|
|
63
64
|
model
|
|
@@ -66,8 +67,8 @@ module Expressir
|
|
|
66
67
|
# Scan remarks (issue #20): an Array of Hashes mirroring
|
|
67
68
|
# RemarkScanner::Remark's fields (position, end_position, line,
|
|
68
69
|
# text, tag, format), straight from the Rust scanner.
|
|
69
|
-
def self.scan_remarks(source)
|
|
70
|
-
::Expressir::Core.scan_remarks(source)
|
|
70
|
+
def self.scan_remarks(source, annotations: false)
|
|
71
|
+
::Expressir::Core.scan_remarks(source, annotations)
|
|
71
72
|
end
|
|
72
73
|
|
|
73
74
|
# SourceFormatter (issue #22): the rendered EXPRESS text for one
|
|
@@ -41,8 +41,14 @@ module Expressir
|
|
|
41
41
|
|
|
42
42
|
formatted_text = remark.tagged? ? "\"#{remark.tag}\" #{text}" : text
|
|
43
43
|
|
|
44
|
-
if remark.
|
|
44
|
+
if remark.tail_annotation?
|
|
45
|
+
"--- #{formatted_text}"
|
|
46
|
+
elsif remark.tail?
|
|
45
47
|
"-- #{formatted_text}"
|
|
48
|
+
elsif remark.embedded_annotation? && text.include?("\n")
|
|
49
|
+
["(**", formatted_text, "**)"].join("\n")
|
|
50
|
+
elsif remark.embedded_annotation?
|
|
51
|
+
"(** #{formatted_text} *)"
|
|
46
52
|
elsif text.include?("\n")
|
|
47
53
|
["(*", formatted_text, "*)"].join("\n")
|
|
48
54
|
else
|
|
@@ -62,7 +68,15 @@ module Expressir
|
|
|
62
68
|
return "" if text.nil? || text.empty?
|
|
63
69
|
|
|
64
70
|
formatted_text = remark.tagged? ? "\"#{remark.tag}\" #{text}" : text
|
|
65
|
-
remark.
|
|
71
|
+
if remark.tail_annotation?
|
|
72
|
+
" --- #{formatted_text}"
|
|
73
|
+
elsif remark.tail?
|
|
74
|
+
" -- #{formatted_text}"
|
|
75
|
+
elsif remark.embedded_annotation?
|
|
76
|
+
" (** #{formatted_text} *)"
|
|
77
|
+
else
|
|
78
|
+
" (* #{formatted_text} *)"
|
|
79
|
+
end
|
|
66
80
|
end
|
|
67
81
|
|
|
68
82
|
def format_end_scope_remark(node)
|
|
@@ -82,7 +96,7 @@ module Expressir
|
|
|
82
96
|
return "" unless remark.tail?
|
|
83
97
|
|
|
84
98
|
formatted_text = remark.tagged? ? "\"#{remark.tag}\" #{text}" : text
|
|
85
|
-
" -- #{formatted_text}"
|
|
99
|
+
remark.tail_annotation? ? " --- #{formatted_text}" : " -- #{formatted_text}"
|
|
86
100
|
end
|
|
87
101
|
|
|
88
102
|
def format_preamble_remark(remark, indent_str = "")
|
|
@@ -91,8 +105,19 @@ module Expressir
|
|
|
91
105
|
text = remark.text
|
|
92
106
|
text = "\"#{remark.tag}\" #{text}" if remark.tagged?
|
|
93
107
|
|
|
94
|
-
if remark.
|
|
108
|
+
if remark.tail_annotation?
|
|
109
|
+
"#{indent_str}--- #{text}"
|
|
110
|
+
elsif remark.tail?
|
|
95
111
|
"#{indent_str}-- #{text}"
|
|
112
|
+
elsif remark.embedded_annotation? && text.include?("\n")
|
|
113
|
+
lines = text.split("\n")
|
|
114
|
+
[
|
|
115
|
+
"#{indent_str}(**",
|
|
116
|
+
*lines.map { |line| "#{indent_str} #{line.strip}" },
|
|
117
|
+
"#{indent_str}**)",
|
|
118
|
+
].join("\n")
|
|
119
|
+
elsif remark.embedded_annotation?
|
|
120
|
+
"#{indent_str}(** #{text} *)"
|
|
96
121
|
elsif text.include?("\n")
|
|
97
122
|
lines = text.split("\n")
|
|
98
123
|
[
|
|
@@ -103,6 +103,15 @@ module Expressir
|
|
|
103
103
|
@cached_schema_grammar_json
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
+
# Lane retirement (expressir#587): EXPRESSIR_DISABLE_RUBY_PARSE
|
|
107
|
+
# turns the Ruby parse lanes (the artifact replay and the DSL
|
|
108
|
+
# evaluation) into hard failures, so the suite can prove the
|
|
109
|
+
# native lane stands alone. The lanes remain emergency
|
|
110
|
+
# fallbacks without the env.
|
|
111
|
+
def self.ruby_parse_disabled?
|
|
112
|
+
ENV["EXPRESSIR_DISABLE_RUBY_PARSE"] == "1"
|
|
113
|
+
end
|
|
114
|
+
|
|
106
115
|
# Parse using native engine with Rust-side transformation (fastest)
|
|
107
116
|
#
|
|
108
117
|
# This method provides ~17x speedup over pure Ruby parsing.
|
|
@@ -151,6 +160,10 @@ module Expressir
|
|
|
151
160
|
PARG_COMPONENTS_DIR = File.join(__dir__, "parg")
|
|
152
161
|
|
|
153
162
|
def self.parse_artifact(source)
|
|
163
|
+
if ruby_parse_disabled?
|
|
164
|
+
raise NotImplementedError,
|
|
165
|
+
"Ruby parse lanes disabled (EXPRESSIR_DISABLE_RUBY_PARSE)"
|
|
166
|
+
end
|
|
154
167
|
raise LoadError, "Edition-2 artifact not available" unless artifact_available?
|
|
155
168
|
|
|
156
169
|
@parser_mutex.synchronize do
|
|
@@ -168,8 +181,15 @@ module Expressir
|
|
|
168
181
|
# The Ruby-lane parse: the edition-2 artifact first, the DSL
|
|
169
182
|
# parser as fallback (issue #578 STEP 4).
|
|
170
183
|
def self.parse_ruby(source)
|
|
184
|
+
if ruby_parse_disabled?
|
|
185
|
+
raise NotImplementedError,
|
|
186
|
+
"Ruby parse lanes disabled (EXPRESSIR_DISABLE_RUBY_PARSE)"
|
|
187
|
+
end
|
|
188
|
+
|
|
171
189
|
parse_artifact(source)
|
|
172
190
|
rescue StandardError, NotImplementedError
|
|
191
|
+
raise if ruby_parse_disabled?
|
|
192
|
+
|
|
173
193
|
cached_parser.parse(source)
|
|
174
194
|
end
|
|
175
195
|
|
|
@@ -54,9 +54,13 @@ module Expressir
|
|
|
54
54
|
# parser_core_parity_spec)
|
|
55
55
|
# @return [Model::ExpFile] ExpFile containing parsed schemas
|
|
56
56
|
# @raise [Error::SchemaParseFailure] if the schema file fails to parse
|
|
57
|
+
# @param annotations [Boolean] recognize EXPRESSdoc annotations
|
|
58
|
+
# (`--- note`, `(** note *)`) in addition to remarks; they come
|
|
59
|
+
# back with the annotation remark formats (core lane).
|
|
57
60
|
def self.from_file(file, skip_references: nil, include_source: nil,
|
|
58
61
|
root_path: nil, use_native: nil,
|
|
59
|
-
use_core: nil, dialect: nil
|
|
62
|
+
use_core: nil, dialect: nil,
|
|
63
|
+
annotations: false) # rubocop:disable Metrics/AbcSize
|
|
60
64
|
Dialect.normalize(dialect)
|
|
61
65
|
# use_native: false pins the Ruby grammar path; the core path
|
|
62
66
|
# must not silently take over that request.
|
|
@@ -64,7 +68,8 @@ module Expressir
|
|
|
64
68
|
if use_core && Core::NATIVE_AVAILABLE
|
|
65
69
|
return from_file_core(file, skip_references: skip_references,
|
|
66
70
|
include_source: include_source,
|
|
67
|
-
root_path: root_path
|
|
71
|
+
root_path: root_path,
|
|
72
|
+
annotations: annotations)
|
|
68
73
|
end
|
|
69
74
|
|
|
70
75
|
Expressir::Benchmark.measure_file(file) do
|
|
@@ -198,7 +203,8 @@ module Expressir
|
|
|
198
203
|
# directly (lutaml wire shape); Ruby hydrates, then remark
|
|
199
204
|
# attachment runs on the source as usual.
|
|
200
205
|
def self.from_file_core(file, skip_references: nil,
|
|
201
|
-
include_source: nil, root_path: nil,
|
|
206
|
+
include_source: nil, root_path: nil,
|
|
207
|
+
annotations: false, &block)
|
|
202
208
|
unless Core::NATIVE_AVAILABLE
|
|
203
209
|
raise Error::StreamingUnsupportedError,
|
|
204
210
|
"core parse requires the native extension"
|
|
@@ -213,7 +219,8 @@ module Expressir
|
|
|
213
219
|
begin
|
|
214
220
|
if Core.respond_to?(:parse_to_model_attached_with_wire)
|
|
215
221
|
remarks_attached = true
|
|
216
|
-
Core.parse_to_model_attached_with_wire(source, schema_file
|
|
222
|
+
Core.parse_to_model_attached_with_wire(source, schema_file,
|
|
223
|
+
annotations: annotations)
|
|
217
224
|
.tap(&:wire_parents)
|
|
218
225
|
else
|
|
219
226
|
Core.parse_to_model(source, schema_file).tap(&:wire_parents)
|
|
@@ -232,7 +239,8 @@ module Expressir
|
|
|
232
239
|
|
|
233
240
|
finalize_loaded_file(exp_file, source, schema_file,
|
|
234
241
|
include_source: include_source,
|
|
235
|
-
remarks_attached: remarks_attached
|
|
242
|
+
remarks_attached: remarks_attached,
|
|
243
|
+
annotations: annotations)
|
|
236
244
|
|
|
237
245
|
unless skip_references
|
|
238
246
|
Expressir::Benchmark.measure_references do
|
|
@@ -248,9 +256,10 @@ module Expressir
|
|
|
248
256
|
# Shared post-parse steps for every core-path file: remark
|
|
249
257
|
# attachment, header-remark transfer, and path wiring.
|
|
250
258
|
def self.finalize_loaded_file(exp_file, source, schema_file,
|
|
251
|
-
include_source: nil, remarks_attached: false
|
|
259
|
+
include_source: nil, remarks_attached: false,
|
|
260
|
+
annotations: false)
|
|
252
261
|
if source && include_source != false && !remarks_attached
|
|
253
|
-
RemarkAttacher.new(source).attach(exp_file)
|
|
262
|
+
RemarkAttacher.new(source, annotations: annotations).attach(exp_file)
|
|
254
263
|
end
|
|
255
264
|
|
|
256
265
|
transfer_header_to_schema(exp_file, source)
|
|
@@ -39,8 +39,9 @@ module Expressir
|
|
|
39
39
|
# 1-based line number(s) it appears on.
|
|
40
40
|
WHERE_CLAUSE_PATTERN = /\A\s*WHERE\s+(\w+)\s*:/i
|
|
41
41
|
|
|
42
|
-
def initialize(source)
|
|
42
|
+
def initialize(source, annotations: false)
|
|
43
43
|
@source = source
|
|
44
|
+
@annotations = annotations
|
|
44
45
|
@attached_spans = Set.new
|
|
45
46
|
@line_map = LineMap.new(source.b)
|
|
46
47
|
@model = nil
|
|
@@ -52,7 +53,7 @@ module Expressir
|
|
|
52
53
|
|
|
53
54
|
def attach(model)
|
|
54
55
|
@model = model
|
|
55
|
-
remarks = RemarkScanner.new(@source).scan
|
|
56
|
+
remarks = RemarkScanner.new(@source, annotations: @annotations).scan
|
|
56
57
|
|
|
57
58
|
@node_index = NodePositionIndex.new(model, @line_map)
|
|
58
59
|
@scope_resolver = ScopeResolver.new(
|
|
@@ -32,12 +32,22 @@ module Expressir
|
|
|
32
32
|
# occupied in the original source.
|
|
33
33
|
Remark = Struct.new(:position, :end_position, :line, :text, :tag,
|
|
34
34
|
:format, keyword_init: true) do
|
|
35
|
+
# Tail annotations sit where tails sit; the renderer asks
|
|
36
|
+
# #tail_annotation? for the marker.
|
|
35
37
|
def tail?
|
|
36
|
-
|
|
38
|
+
[Model::RemarkFormat::TAIL, Model::RemarkFormat::TAIL_ANNOTATION].include?(format)
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
def embedded?
|
|
40
|
-
|
|
42
|
+
[Model::RemarkFormat::EMBEDDED, Model::RemarkFormat::EMBEDDED_ANNOTATION].include?(format)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def tail_annotation?
|
|
46
|
+
format == Model::RemarkFormat::TAIL_ANNOTATION
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def embedded_annotation?
|
|
50
|
+
format == Model::RemarkFormat::EMBEDDED_ANNOTATION
|
|
41
51
|
end
|
|
42
52
|
|
|
43
53
|
def tagged?
|
|
@@ -56,6 +66,12 @@ module Expressir
|
|
|
56
66
|
EMBEDDED_CLOSE = "*)"
|
|
57
67
|
STRING_QUOTE = "'"
|
|
58
68
|
|
|
69
|
+
# EXPRESSdoc annotation markers (metanorma/annotated-express#94):
|
|
70
|
+
# a `---` tail annotation takes exactly three dashes, and a `(**`
|
|
71
|
+
# embedded annotation closes with the plain remark closer.
|
|
72
|
+
TAIL_ANNOTATION_MARKER = "---"
|
|
73
|
+
EMBEDDED_ANNOTATION_OPEN = "(**"
|
|
74
|
+
|
|
59
75
|
# Byte value of `)` — used to detect the `(*)` overlap pattern where
|
|
60
76
|
# the embedded-remark opener `(*` and closer `*)` share the `*`.
|
|
61
77
|
RPAREN_BYTE = ")".ord
|
|
@@ -67,8 +83,11 @@ module Expressir
|
|
|
67
83
|
QUOTED_TAG = /\A"([^"]*)"\s*(.*)\z/m
|
|
68
84
|
|
|
69
85
|
# @param source [String] EXPRESS source text (any encoding).
|
|
70
|
-
|
|
86
|
+
# @param annotations [Boolean] recognize the EXPRESSdoc annotation
|
|
87
|
+
# forms (`--- note`, `(** note *)`) in addition to remarks.
|
|
88
|
+
def initialize(source, annotations: false)
|
|
71
89
|
@source = source
|
|
90
|
+
@annotations = annotations
|
|
72
91
|
@source_bytes = source.b
|
|
73
92
|
@line_map = LineMap.new(@source_bytes)
|
|
74
93
|
end
|
|
@@ -92,7 +111,7 @@ module Expressir
|
|
|
92
111
|
end
|
|
93
112
|
|
|
94
113
|
def native_scan
|
|
95
|
-
Core.scan_remarks(@source).map do |unit|
|
|
114
|
+
Core.scan_remarks(@source, annotations: @annotations).map do |unit|
|
|
96
115
|
Remark.new(
|
|
97
116
|
position: unit[:position],
|
|
98
117
|
end_position: unit[:end_position],
|
|
@@ -124,19 +143,34 @@ module Expressir
|
|
|
124
143
|
embedded_depth = 0
|
|
125
144
|
tail_start = nil # byte position of first content char after "--"
|
|
126
145
|
tail_line = nil
|
|
146
|
+
tail_annotation = false
|
|
127
147
|
embedded_start = nil # byte position of first content char after "(*"
|
|
128
148
|
embedded_line = nil
|
|
149
|
+
embedded_annotation = false
|
|
150
|
+
|
|
151
|
+
# A `---` tail annotation takes exactly three dashes, the fourth
|
|
152
|
+
# byte (if any) not a dash — dash runs of four or more stay remarks.
|
|
153
|
+
tail_annotation_at = lambda do |at|
|
|
154
|
+
return false unless @annotations
|
|
155
|
+
|
|
156
|
+
src[at, TAIL_ANNOTATION_MARKER.bytesize] == TAIL_ANNOTATION_MARKER &&
|
|
157
|
+
src.getbyte(at + TAIL_ANNOTATION_MARKER.bytesize) != "-".ord
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
embedded_annotation_at = lambda do |at|
|
|
161
|
+
@annotations && src[at, EMBEDDED_ANNOTATION_OPEN.bytesize] == EMBEDDED_ANNOTATION_OPEN
|
|
162
|
+
end
|
|
129
163
|
|
|
130
164
|
while pos < src.bytesize
|
|
131
165
|
case state
|
|
132
166
|
when :in_tail
|
|
133
167
|
nl = src.index("\n", pos)
|
|
134
168
|
if nl
|
|
135
|
-
emit_tail(remarks, tail_start, nl, tail_line)
|
|
169
|
+
emit_tail(remarks, tail_start, nl, tail_line, tail_annotation)
|
|
136
170
|
pos = nl + 1
|
|
137
171
|
state = :top
|
|
138
172
|
else
|
|
139
|
-
emit_tail(remarks, tail_start, src.bytesize, tail_line)
|
|
173
|
+
emit_tail(remarks, tail_start, src.bytesize, tail_line, tail_annotation)
|
|
140
174
|
return remarks
|
|
141
175
|
end
|
|
142
176
|
when :in_embedded
|
|
@@ -154,7 +188,7 @@ module Expressir
|
|
|
154
188
|
embedded_depth -= 1
|
|
155
189
|
pos = closing + EMBEDDED_CLOSE.bytesize
|
|
156
190
|
if embedded_depth.zero?
|
|
157
|
-
emit_embedded(remarks, embedded_start, closing, embedded_line)
|
|
191
|
+
emit_embedded(remarks, embedded_start, closing, embedded_line, embedded_annotation)
|
|
158
192
|
state = :top
|
|
159
193
|
end
|
|
160
194
|
else
|
|
@@ -194,21 +228,36 @@ module Expressir
|
|
|
194
228
|
# share the `*`. Emit with empty content and continue.
|
|
195
229
|
emit_embedded(remarks, next_embed + EMBEDDED_OPEN.bytesize,
|
|
196
230
|
next_embed + EMBEDDED_OPEN.bytesize,
|
|
197
|
-
@line_map.line_number(next_embed))
|
|
231
|
+
@line_map.line_number(next_embed), false)
|
|
198
232
|
pos = next_embed + 3
|
|
199
233
|
state = :top
|
|
200
234
|
else
|
|
201
|
-
|
|
235
|
+
# `(**` opens an annotation when annotations mode is on;
|
|
236
|
+
# the byte after `(*` is a `*`, so the `(*)` overlap can
|
|
237
|
+
# never collide with it.
|
|
238
|
+
embedded_annotation = embedded_annotation_at.call(next_embed)
|
|
239
|
+
open_len = if embedded_annotation
|
|
240
|
+
EMBEDDED_ANNOTATION_OPEN.bytesize
|
|
241
|
+
else
|
|
242
|
+
EMBEDDED_OPEN.bytesize
|
|
243
|
+
end
|
|
244
|
+
embedded_start = next_embed + open_len
|
|
202
245
|
embedded_line = @line_map.line_number(next_embed)
|
|
203
246
|
embedded_depth = 1
|
|
204
247
|
state = :in_embedded
|
|
205
|
-
pos =
|
|
248
|
+
pos = embedded_start
|
|
206
249
|
end
|
|
207
250
|
else
|
|
208
|
-
|
|
251
|
+
tail_annotation = tail_annotation_at.call(next_tail)
|
|
252
|
+
marker_len = if tail_annotation
|
|
253
|
+
TAIL_ANNOTATION_MARKER.bytesize
|
|
254
|
+
else
|
|
255
|
+
TAIL_MARKER.bytesize
|
|
256
|
+
end
|
|
257
|
+
tail_start = next_tail + marker_len
|
|
209
258
|
tail_line = @line_map.line_number(next_tail)
|
|
210
259
|
state = :in_tail
|
|
211
|
-
pos =
|
|
260
|
+
pos = tail_start
|
|
212
261
|
end
|
|
213
262
|
end
|
|
214
263
|
end
|
|
@@ -216,31 +265,47 @@ module Expressir
|
|
|
216
265
|
remarks
|
|
217
266
|
end
|
|
218
267
|
|
|
219
|
-
def emit_tail(remarks, content_start, content_end, line)
|
|
268
|
+
def emit_tail(remarks, content_start, content_end, line, annotation)
|
|
220
269
|
# Slice content from the original (UTF-8) source so the returned text
|
|
221
270
|
# preserves the source encoding. Byte offsets come from the BINARY copy.
|
|
222
271
|
raw = @source.byteslice(content_start...content_end)
|
|
223
272
|
tag, content = parse_tail(raw.strip)
|
|
224
273
|
remarks << Remark.new(
|
|
225
|
-
position: content_start -
|
|
274
|
+
position: content_start - (if annotation
|
|
275
|
+
TAIL_ANNOTATION_MARKER.bytesize
|
|
276
|
+
else
|
|
277
|
+
TAIL_MARKER.bytesize
|
|
278
|
+
end),
|
|
226
279
|
end_position: content_end,
|
|
227
280
|
line: line,
|
|
228
281
|
text: content,
|
|
229
282
|
tag: tag,
|
|
230
|
-
format:
|
|
283
|
+
format: if annotation
|
|
284
|
+
Model::RemarkFormat::TAIL_ANNOTATION
|
|
285
|
+
else
|
|
286
|
+
Model::RemarkFormat::TAIL
|
|
287
|
+
end,
|
|
231
288
|
)
|
|
232
289
|
end
|
|
233
290
|
|
|
234
|
-
def emit_embedded(remarks, content_start, content_end, line)
|
|
291
|
+
def emit_embedded(remarks, content_start, content_end, line, annotation)
|
|
235
292
|
raw = @source.byteslice(content_start...content_end)
|
|
236
293
|
tag, content = parse_embedded(raw)
|
|
237
294
|
remarks << Remark.new(
|
|
238
|
-
position: content_start -
|
|
295
|
+
position: content_start - (if annotation
|
|
296
|
+
EMBEDDED_ANNOTATION_OPEN.bytesize
|
|
297
|
+
else
|
|
298
|
+
EMBEDDED_OPEN.bytesize
|
|
299
|
+
end),
|
|
239
300
|
end_position: content_end + EMBEDDED_CLOSE.bytesize,
|
|
240
301
|
line: line,
|
|
241
302
|
text: content,
|
|
242
303
|
tag: tag,
|
|
243
|
-
format:
|
|
304
|
+
format: if annotation
|
|
305
|
+
Model::RemarkFormat::EMBEDDED_ANNOTATION
|
|
306
|
+
else
|
|
307
|
+
Model::RemarkFormat::EMBEDDED
|
|
308
|
+
end,
|
|
244
309
|
)
|
|
245
310
|
end
|
|
246
311
|
|
|
@@ -12,6 +12,13 @@ module Expressir
|
|
|
12
12
|
module RemarkFormat
|
|
13
13
|
TAIL = "tail"
|
|
14
14
|
EMBEDDED = "embedded"
|
|
15
|
+
|
|
16
|
+
# EXPRESSdoc annotations (metanorma/annotated-express#94): the
|
|
17
|
+
# display channel, parsed only in annotations mode. `---` tail
|
|
18
|
+
# annotations take exactly three dashes; `(** ... *)` embedded
|
|
19
|
+
# annotations close with the remark closer.
|
|
20
|
+
TAIL_ANNOTATION = "tail_annotation"
|
|
21
|
+
EMBEDDED_ANNOTATION = "embedded_annotation"
|
|
15
22
|
end
|
|
16
23
|
end
|
|
17
24
|
end
|
|
@@ -16,16 +16,30 @@ module Expressir
|
|
|
16
16
|
attribute :region, :string
|
|
17
17
|
attribute :source_offset, :integer # byte offset in source text
|
|
18
18
|
|
|
19
|
-
# Check if this is a tail remark
|
|
20
|
-
#
|
|
19
|
+
# Check if this is a tail remark. Tail annotations sit where
|
|
20
|
+
# tails sit, so placement semantics treat them as tails; the
|
|
21
|
+
# renderer asks {#tail_annotation?} for the marker.
|
|
22
|
+
# @return [Boolean] True if format is 'tail' or 'tail_annotation'
|
|
21
23
|
def tail?
|
|
22
|
-
|
|
24
|
+
[RemarkFormat::TAIL, RemarkFormat::TAIL_ANNOTATION].include?(format)
|
|
23
25
|
end
|
|
24
26
|
|
|
25
|
-
# Check if this is an embedded remark
|
|
26
|
-
# @return [Boolean] True if format is 'embedded'
|
|
27
|
+
# Check if this is an embedded remark or embedded annotation
|
|
28
|
+
# @return [Boolean] True if format is 'embedded' or 'embedded_annotation'
|
|
27
29
|
def embedded?
|
|
28
|
-
|
|
30
|
+
[RemarkFormat::EMBEDDED, RemarkFormat::EMBEDDED_ANNOTATION].include?(format)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Check if this is a `---` tail annotation
|
|
34
|
+
# @return [Boolean] True if format is 'tail_annotation'
|
|
35
|
+
def tail_annotation?
|
|
36
|
+
format == RemarkFormat::TAIL_ANNOTATION
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Check if this is a `(** ... *)` embedded annotation
|
|
40
|
+
# @return [Boolean] True if format is 'embedded_annotation'
|
|
41
|
+
def embedded_annotation?
|
|
42
|
+
format == RemarkFormat::EMBEDDED_ANNOTATION
|
|
29
43
|
end
|
|
30
44
|
|
|
31
45
|
# Check if this remark has a tag
|
data/lib/expressir/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: expressir
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.4.
|
|
4
|
+
version: 2.4.58
|
|
5
5
|
platform: arm-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|