expressir 2.1.29 → 2.1.31
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/.github/workflows/docs.yml +98 -0
- data/.github/workflows/links.yml +100 -0
- data/.github/workflows/rake.yml +4 -0
- data/.github/workflows/release.yml +5 -0
- data/.github/workflows/validate_schemas.yml +1 -1
- data/.gitignore +3 -0
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +209 -55
- data/Gemfile +2 -1
- data/README.adoc +650 -83
- data/docs/Gemfile +12 -0
- data/docs/_config.yml +141 -0
- data/docs/_guides/changes/changes-format.adoc +778 -0
- data/docs/_guides/changes/importing-eengine.adoc +898 -0
- data/docs/_guides/changes/index.adoc +396 -0
- data/docs/_guides/changes/programmatic-usage.adoc +1038 -0
- data/docs/_guides/changes/validating-changes.adoc +681 -0
- data/docs/_guides/cli/benchmark-performance.adoc +834 -0
- data/docs/_guides/cli/coverage-analysis.adoc +921 -0
- data/docs/_guides/cli/format-schemas.adoc +547 -0
- data/docs/_guides/cli/index.adoc +8 -0
- data/docs/_guides/cli/managing-changes.adoc +927 -0
- data/docs/_guides/cli/validate-ascii.adoc +645 -0
- data/docs/_guides/cli/validate-schemas.adoc +534 -0
- data/docs/_guides/index.adoc +165 -0
- data/docs/_guides/ler/creating-packages.adoc +664 -0
- data/docs/_guides/ler/index.adoc +305 -0
- data/docs/_guides/ler/loading-packages.adoc +707 -0
- data/docs/_guides/ler/package-formats.adoc +748 -0
- data/docs/_guides/ler/querying-packages.adoc +826 -0
- data/docs/_guides/ler/validating-packages.adoc +750 -0
- data/docs/_guides/liquid/basic-templates.adoc +813 -0
- data/docs/_guides/liquid/documentation-generation.adoc +1042 -0
- data/docs/_guides/liquid/drops-reference.adoc +829 -0
- data/docs/_guides/liquid/filters-and-tags.adoc +912 -0
- data/docs/_guides/liquid/index.adoc +468 -0
- data/docs/_guides/manifests/creating-manifests.adoc +483 -0
- data/docs/_guides/manifests/index.adoc +307 -0
- data/docs/_guides/manifests/resolving-manifests.adoc +557 -0
- data/docs/_guides/manifests/validating-manifests.adoc +713 -0
- data/docs/_guides/ruby-api/formatting-schemas.adoc +605 -0
- data/docs/_guides/ruby-api/index.adoc +257 -0
- data/docs/_guides/ruby-api/parsing-files.adoc +421 -0
- data/docs/_guides/ruby-api/search-engine.adoc +609 -0
- data/docs/_guides/ruby-api/working-with-repository.adoc +577 -0
- data/docs/_pages/data-model.adoc +665 -0
- data/docs/_pages/express-language.adoc +506 -0
- data/docs/_pages/getting-started.adoc +414 -0
- data/docs/_pages/index.adoc +116 -0
- data/docs/_pages/introduction.adoc +256 -0
- data/docs/_pages/ler-packages.adoc +837 -0
- data/docs/_pages/parsers.adoc +683 -0
- data/docs/_pages/schema-manifests.adoc +431 -0
- data/docs/_references/index.adoc +228 -0
- data/docs/_tutorials/creating-ler-package.adoc +735 -0
- data/docs/_tutorials/documentation-coverage.adoc +795 -0
- data/docs/_tutorials/index.adoc +221 -0
- data/docs/_tutorials/liquid-templates.adoc +806 -0
- data/docs/_tutorials/parsing-your-first-schema.adoc +522 -0
- data/docs/_tutorials/querying-schemas.adoc +751 -0
- data/docs/_tutorials/working-with-multiple-schemas.adoc +676 -0
- data/docs/index.adoc +242 -0
- data/docs/lychee.toml +84 -0
- data/examples/demo_ler_usage.sh +86 -0
- data/examples/ler/README.md +111 -0
- data/examples/ler/simple_example.ler +0 -0
- data/examples/ler/simple_schema.exp +33 -0
- data/examples/ler_build.rb +75 -0
- data/examples/ler_cli.rb +79 -0
- data/examples/ler_demo_complete.rb +276 -0
- data/examples/ler_query.rb +91 -0
- data/examples/ler_query_examples.rb +305 -0
- data/examples/ler_stats.rb +81 -0
- data/examples/phase3_demo.rb +159 -0
- data/examples/query_demo_simple.rb +131 -0
- data/expressir.gemspec +2 -0
- data/lib/expressir/changes/schema_change.rb +32 -22
- data/lib/expressir/changes/{edition_change.rb → version_change.rb} +3 -3
- data/lib/expressir/cli.rb +12 -4
- data/lib/expressir/commands/changes_import_eengine.rb +2 -2
- data/lib/expressir/commands/changes_validate.rb +1 -1
- data/lib/expressir/commands/manifest.rb +427 -0
- data/lib/expressir/commands/package.rb +1274 -0
- data/lib/expressir/commands/validate.rb +70 -37
- data/lib/expressir/commands/validate_ascii.rb +607 -0
- data/lib/expressir/commands/validate_load.rb +88 -0
- data/lib/expressir/express/formatter.rb +5 -1
- data/lib/expressir/express/formatters/remark_item_formatter.rb +25 -0
- data/lib/expressir/express/parser.rb +33 -0
- data/lib/expressir/manifest/resolver.rb +213 -0
- data/lib/expressir/manifest/validator.rb +195 -0
- data/lib/expressir/model/declarations/entity.rb +6 -0
- data/lib/expressir/model/dependency_resolver.rb +270 -0
- data/lib/expressir/model/indexes/entity_index.rb +103 -0
- data/lib/expressir/model/indexes/reference_index.rb +148 -0
- data/lib/expressir/model/indexes/type_index.rb +149 -0
- data/lib/expressir/model/interface_validator.rb +384 -0
- data/lib/expressir/model/repository.rb +400 -5
- data/lib/expressir/model/repository_validator.rb +295 -0
- data/lib/expressir/model/search_engine.rb +525 -0
- data/lib/expressir/model.rb +4 -94
- data/lib/expressir/package/builder.rb +200 -0
- data/lib/expressir/package/metadata.rb +81 -0
- data/lib/expressir/package/reader.rb +165 -0
- data/lib/expressir/schema_manifest.rb +11 -1
- data/lib/expressir/version.rb +1 -1
- data/lib/expressir.rb +16 -3
- metadata +115 -5
- data/docs/benchmarking.adoc +0 -107
- data/docs/liquid_drops.adoc +0 -1547
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Validate ASCII Content
|
|
3
|
+
parent: CLI Guides
|
|
4
|
+
grand_parent: Guides
|
|
5
|
+
nav_order: 4
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
== Validate ASCII Content
|
|
9
|
+
|
|
10
|
+
=== Purpose
|
|
11
|
+
|
|
12
|
+
The [`validate ascii`](../../../lib/expressir/commands/validate_ascii.rb:1) command validates that EXPRESS schema files contain only ASCII characters outside of remarks. This ensures compatibility with systems that don't support Unicode, while allowing Unicode in documentation comments.
|
|
13
|
+
|
|
14
|
+
**Key Feature**: Tagged remarks (both embedded `(* ... *)` and tail `-- ...` comments) are excluded from validation, allowing documentation to contain Unicode characters without triggering validation errors.
|
|
15
|
+
|
|
16
|
+
=== References
|
|
17
|
+
|
|
18
|
+
* link:validate-schemas.html[Validate Schemas]
|
|
19
|
+
* link:../../pages/express-language.html[EXPRESS Language Documentation]
|
|
20
|
+
* link:../../tutorials/parsing-your-first-schema.html[Tutorial: Parsing Your First Schema]
|
|
21
|
+
|
|
22
|
+
=== Concepts
|
|
23
|
+
|
|
24
|
+
ASCII validation:: Checking that EXPRESS code (excluding remarks) contains only 7-bit ASCII characters (0x00-0x7F)
|
|
25
|
+
Tagged remarks:: Documentation comments that may contain Unicode without affecting validation
|
|
26
|
+
Replacement suggestions:: Proposed ASCII or AsciiMath alternatives for non-ASCII characters
|
|
27
|
+
ISO 10303-11 encoding:: Standard encoding format for representing Unicode characters in EXPRESS
|
|
28
|
+
Schema manifest:: YAML file containing schema definitions that can be validated
|
|
29
|
+
|
|
30
|
+
=== Basic Usage
|
|
31
|
+
|
|
32
|
+
==== Validate Single File
|
|
33
|
+
|
|
34
|
+
[source,bash]
|
|
35
|
+
----
|
|
36
|
+
expressir validate ascii schema.exp
|
|
37
|
+
----
|
|
38
|
+
|
|
39
|
+
Output when no violations found:
|
|
40
|
+
[source]
|
|
41
|
+
----
|
|
42
|
+
Scanned 1 EXPRESS file(s)
|
|
43
|
+
Found 0 non-ASCII sequence(s) in 0 file(s)
|
|
44
|
+
----
|
|
45
|
+
|
|
46
|
+
Output when violations found:
|
|
47
|
+
[source]
|
|
48
|
+
----
|
|
49
|
+
schemas/schema.exp:
|
|
50
|
+
Line 5, Column 15:
|
|
51
|
+
value: π × radius;
|
|
52
|
+
^ Non-ASCII sequence
|
|
53
|
+
"π" - Hex: 0x3c0, UTF-8 bytes: 0xcf 0x80
|
|
54
|
+
Replacement: AsciiMath: pi
|
|
55
|
+
"×" - Hex: 0xd7, UTF-8 bytes: 0xc3 0x97
|
|
56
|
+
Replacement: AsciiMath: xx
|
|
57
|
+
|
|
58
|
+
Found 1 non-ASCII sequence(s) in schema.exp
|
|
59
|
+
|
|
60
|
+
Summary:
|
|
61
|
+
Scanned 1 EXPRESS file(s)
|
|
62
|
+
Found 1 non-ASCII sequence(s) in 1 file(s)
|
|
63
|
+
----
|
|
64
|
+
|
|
65
|
+
==== Validate Directory
|
|
66
|
+
|
|
67
|
+
[source,bash]
|
|
68
|
+
----
|
|
69
|
+
# Non-recursive (top-level only)
|
|
70
|
+
expressir validate ascii schemas/
|
|
71
|
+
|
|
72
|
+
# Recursive (all subdirectories)
|
|
73
|
+
expressir validate ascii schemas/ --recursive
|
|
74
|
+
----
|
|
75
|
+
|
|
76
|
+
==== Validate from Schema Manifest
|
|
77
|
+
|
|
78
|
+
[source,bash]
|
|
79
|
+
----
|
|
80
|
+
# Validate all schemas defined in a manifest
|
|
81
|
+
expressir validate ascii manifest.yaml
|
|
82
|
+
|
|
83
|
+
# With verbose output
|
|
84
|
+
expressir validate ascii manifest.yaml --verbose
|
|
85
|
+
|
|
86
|
+
# Output results in YAML format
|
|
87
|
+
expressir validate ascii manifest.yaml -y
|
|
88
|
+
----
|
|
89
|
+
|
|
90
|
+
=== Command Options
|
|
91
|
+
|
|
92
|
+
==== Available Options
|
|
93
|
+
|
|
94
|
+
[options="header"]
|
|
95
|
+
|===
|
|
96
|
+
| Option | Short | Description | Default
|
|
97
|
+
|
|
98
|
+
| `--recursive`
|
|
99
|
+
| `-r`
|
|
100
|
+
| Validate EXPRESS files under the specified path recursively
|
|
101
|
+
| false
|
|
102
|
+
|
|
103
|
+
| `--yaml`
|
|
104
|
+
| `-y`
|
|
105
|
+
| Output results in YAML format
|
|
106
|
+
| false
|
|
107
|
+
|
|
108
|
+
| `--check-remarks`
|
|
109
|
+
|
|
|
110
|
+
| Include remarks in ASCII validation (by default, remarks are excluded)
|
|
111
|
+
| false
|
|
112
|
+
|
|
113
|
+
| `--verbose`
|
|
114
|
+
|
|
|
115
|
+
| Show verbose output
|
|
116
|
+
| false
|
|
117
|
+
|
|
118
|
+
| `--help`
|
|
119
|
+
| `-h`
|
|
120
|
+
| Display help message
|
|
121
|
+
| -
|
|
122
|
+
|===
|
|
123
|
+
|
|
124
|
+
==== Check Remarks Option
|
|
125
|
+
|
|
126
|
+
By default, the validator excludes remarks from validation. Use `--check-remarks` to include them:
|
|
127
|
+
|
|
128
|
+
[source,bash]
|
|
129
|
+
----
|
|
130
|
+
# Default: exclude remarks from validation
|
|
131
|
+
expressir validate ascii schema.exp
|
|
132
|
+
|
|
133
|
+
# Include remarks in validation
|
|
134
|
+
expressir validate ascii schema.exp --check-remarks
|
|
135
|
+
----
|
|
136
|
+
|
|
137
|
+
When `--check-remarks` is enabled, Unicode characters in remarks will be flagged as violations.
|
|
138
|
+
This is useful when you need strict ASCII-only content including documentation.
|
|
139
|
+
|
|
140
|
+
==== Recursive Option
|
|
141
|
+
|
|
142
|
+
[source,bash]
|
|
143
|
+
----
|
|
144
|
+
expressir validate ascii schemas/ --recursive
|
|
145
|
+
----
|
|
146
|
+
|
|
147
|
+
Scans all `.exp` files in the directory tree:
|
|
148
|
+
[source]
|
|
149
|
+
----
|
|
150
|
+
schemas/
|
|
151
|
+
├── base.exp ✓ Scanned
|
|
152
|
+
├── types/
|
|
153
|
+
│ ├── common.exp ✓ Scanned
|
|
154
|
+
│ └── custom.exp ✓ Scanned
|
|
155
|
+
└── entities/
|
|
156
|
+
└── core.exp ✓ Scanned
|
|
157
|
+
----
|
|
158
|
+
|
|
159
|
+
==== YAML Output
|
|
160
|
+
|
|
161
|
+
[source,bash]
|
|
162
|
+
----
|
|
163
|
+
expressir validate ascii schema.exp --yaml
|
|
164
|
+
----
|
|
165
|
+
|
|
166
|
+
Generates machine-readable output:
|
|
167
|
+
[source,yaml]
|
|
168
|
+
----
|
|
169
|
+
---
|
|
170
|
+
summary:
|
|
171
|
+
total_files: 1
|
|
172
|
+
files_with_violations: 1
|
|
173
|
+
total_violations: 1
|
|
174
|
+
total_unique_characters: 2
|
|
175
|
+
total_occurrences: 2
|
|
176
|
+
violations:
|
|
177
|
+
"/path/to/schema.exp":
|
|
178
|
+
file: schema.exp
|
|
179
|
+
count: 1
|
|
180
|
+
non_ascii_characters:
|
|
181
|
+
- character: "π"
|
|
182
|
+
hex: "0x3c0"
|
|
183
|
+
utf8: "0xcf 0x80"
|
|
184
|
+
is_math: true
|
|
185
|
+
replacement_type: asciimath
|
|
186
|
+
replacement: pi
|
|
187
|
+
occurrence_count: 1
|
|
188
|
+
occurrences:
|
|
189
|
+
- line_number: 5
|
|
190
|
+
column: 15
|
|
191
|
+
line: " value: π × radius;"
|
|
192
|
+
----
|
|
193
|
+
|
|
194
|
+
=== Remark Exclusion
|
|
195
|
+
|
|
196
|
+
==== Why Exclude Remarks
|
|
197
|
+
|
|
198
|
+
EXPRESS remarks serve as documentation and may legitimately contain:
|
|
199
|
+
|
|
200
|
+
* Unicode characters for proper names
|
|
201
|
+
* Mathematical symbols in formulas
|
|
202
|
+
* Non-English text in descriptions
|
|
203
|
+
* Special characters in examples
|
|
204
|
+
|
|
205
|
+
The validation excludes these because:
|
|
206
|
+
|
|
207
|
+
1. Remarks are not exported to EEP format
|
|
208
|
+
2. EXPRESS Engine doesn't process remark content
|
|
209
|
+
3. Documentation should be human-readable
|
|
210
|
+
|
|
211
|
+
==== Tail Remarks
|
|
212
|
+
|
|
213
|
+
Tail remarks start with `--` and continue to end of line:
|
|
214
|
+
|
|
215
|
+
[source,express]
|
|
216
|
+
----
|
|
217
|
+
ENTITY person;
|
|
218
|
+
name : STRING; -- Name in Japanese: 名前
|
|
219
|
+
age : INTEGER; -- This is allowed ✓
|
|
220
|
+
END_ENTITY;
|
|
221
|
+
----
|
|
222
|
+
|
|
223
|
+
The Unicode characters in remarks are **not flagged** as violations.
|
|
224
|
+
|
|
225
|
+
==== Embedded Remarks
|
|
226
|
+
|
|
227
|
+
Embedded remarks use `(* ... *)` delimiters:
|
|
228
|
+
|
|
229
|
+
[source,express]
|
|
230
|
+
----
|
|
231
|
+
ENTITY (
|
|
232
|
+
This entity represents a person.
|
|
233
|
+
Japanese: 人
|
|
234
|
+
Chinese: 人
|
|
235
|
+
Korean: 사람
|
|
236
|
+
*) person;
|
|
237
|
+
name : STRING;
|
|
238
|
+
END_ENTITY;
|
|
239
|
+
----
|
|
240
|
+
|
|
241
|
+
All Unicode in the embedded remark is **excluded from validation**.
|
|
242
|
+
|
|
243
|
+
==== Code vs. Remarks
|
|
244
|
+
|
|
245
|
+
.Example showing the distinction
|
|
246
|
+
[example]
|
|
247
|
+
====
|
|
248
|
+
[source,express]
|
|
249
|
+
----
|
|
250
|
+
SCHEMA test_schema;
|
|
251
|
+
|
|
252
|
+
(* This remark contains: 中文字 日本語 한글 *) <1>
|
|
253
|
+
ENTITY measurement;
|
|
254
|
+
value : REAL; -- Unit: μm (micrometers) <2>
|
|
255
|
+
symbol : STRING := 'μ'; <3>
|
|
256
|
+
END_ENTITY;
|
|
257
|
+
|
|
258
|
+
END_SCHEMA;
|
|
259
|
+
----
|
|
260
|
+
<1> Unicode in embedded remark: **Not flagged**
|
|
261
|
+
<2> Unicode in tail remark: **Not flagged**
|
|
262
|
+
<3> Unicode in code: **Flagged as violation**
|
|
263
|
+
====
|
|
264
|
+
|
|
265
|
+
=== Validation Output
|
|
266
|
+
|
|
267
|
+
==== Text Format
|
|
268
|
+
|
|
269
|
+
The default output shows:
|
|
270
|
+
|
|
271
|
+
* File location
|
|
272
|
+
* Line and column numbers
|
|
273
|
+
* Problematic text with visual indicator
|
|
274
|
+
* Character details (hex, UTF-8 bytes)
|
|
275
|
+
* Replacement suggestions
|
|
276
|
+
* Summary statistics
|
|
277
|
+
|
|
278
|
+
.Example output
|
|
279
|
+
[example]
|
|
280
|
+
====
|
|
281
|
+
[source]
|
|
282
|
+
----
|
|
283
|
+
schemas/geometry.exp:
|
|
284
|
+
Line 12, Column 8:
|
|
285
|
+
area := π × r × r;
|
|
286
|
+
^ Non-ASCII sequence
|
|
287
|
+
"π" - Hex: 0x3c0, UTF-8 bytes: 0xcf 0x80
|
|
288
|
+
Replacement: AsciiMath: pi
|
|
289
|
+
"×" - Hex: 0xd7, UTF-8 bytes: 0xc3 0x97
|
|
290
|
+
Replacement: AsciiMath: xx
|
|
291
|
+
|
|
292
|
+
Found 1 non-ASCII sequence(s) in geometry.exp
|
|
293
|
+
|
|
294
|
+
┌────────────────────── Non-ASCII Characters Summary ──────────────────────┐
|
|
295
|
+
│ File │ Symbol │ Replacement │ Occurrences │
|
|
296
|
+
├────────────────────┼─────────────┼──────────────────┼──────────────────────┤
|
|
297
|
+
│ geometry.exp │ "π" (0x3c0) │ AsciiMath: pi │ 1 │
|
|
298
|
+
│ geometry.exp │ "×" (0xd7) │ AsciiMath: xx │ 1 │
|
|
299
|
+
│ TOTAL │ 2 unique │ │ 2 │
|
|
300
|
+
└────────────────────┴─────────────┴──────────────────┴──────────────────────┘
|
|
301
|
+
----
|
|
302
|
+
====
|
|
303
|
+
|
|
304
|
+
==== Replacement Suggestions
|
|
305
|
+
|
|
306
|
+
The validator provides two types of replacement suggestions:
|
|
307
|
+
|
|
308
|
+
**AsciiMath Replacements**::
|
|
309
|
+
For mathematical symbols
|
|
310
|
+
+
|
|
311
|
+
[options="header"]
|
|
312
|
+
|===
|
|
313
|
+
| Unicode | Hex | AsciiMath
|
|
314
|
+
|
|
315
|
+
| π
|
|
316
|
+
| 0x3c0
|
|
317
|
+
| `pi`
|
|
318
|
+
|
|
319
|
+
| ×
|
|
320
|
+
| 0xd7
|
|
321
|
+
| `xx`
|
|
322
|
+
|
|
323
|
+
| ÷
|
|
324
|
+
| 0xf7
|
|
325
|
+
| `div`
|
|
326
|
+
|
|
327
|
+
| ≤
|
|
328
|
+
| 0x2264
|
|
329
|
+
| `le`
|
|
330
|
+
|
|
331
|
+
| ≥
|
|
332
|
+
| 0x2265
|
|
333
|
+
| `ge`
|
|
334
|
+
|
|
335
|
+
| α
|
|
336
|
+
| 0x3b1
|
|
337
|
+
| `alpha`
|
|
338
|
+
|
|
339
|
+
| β
|
|
340
|
+
| 0x3b2
|
|
341
|
+
| `beta`
|
|
342
|
+
|
|
343
|
+
| θ
|
|
344
|
+
| 0x3b8
|
|
345
|
+
| `theta`
|
|
346
|
+
|===
|
|
347
|
+
|
|
348
|
+
**ISO 10303-11 Encoding**::
|
|
349
|
+
For other characters
|
|
350
|
+
+
|
|
351
|
+
[source]
|
|
352
|
+
----
|
|
353
|
+
"神" → "0000795E"
|
|
354
|
+
"戸" → "00006238"
|
|
355
|
+
"中" → "00004E2D"
|
|
356
|
+
"文" → "00006587"
|
|
357
|
+
----
|
|
358
|
+
|
|
359
|
+
=== Use Cases
|
|
360
|
+
|
|
361
|
+
==== Pre-Export Validation
|
|
362
|
+
|
|
363
|
+
Before exporting to EEP format:
|
|
364
|
+
|
|
365
|
+
[source,bash]
|
|
366
|
+
----
|
|
367
|
+
#!/bin/bash
|
|
368
|
+
# Validate before EEP export
|
|
369
|
+
|
|
370
|
+
if expressir validate ascii schemas/*.exp; then
|
|
371
|
+
echo "✓ ASCII-only - safe for EEP export"
|
|
372
|
+
./export-to-eep.sh
|
|
373
|
+
else
|
|
374
|
+
echo "✗ Non-ASCII found - review violations before export"
|
|
375
|
+
exit 1
|
|
376
|
+
fi
|
|
377
|
+
----
|
|
378
|
+
|
|
379
|
+
==== CI/CD Integration
|
|
380
|
+
|
|
381
|
+
GitHub Actions workflow:
|
|
382
|
+
|
|
383
|
+
[source,yaml]
|
|
384
|
+
----
|
|
385
|
+
name: Validate ASCII
|
|
386
|
+
|
|
387
|
+
on: [push, pull_request]
|
|
388
|
+
|
|
389
|
+
jobs:
|
|
390
|
+
ascii-check:
|
|
391
|
+
runs-on: ubuntu-latest
|
|
392
|
+
steps:
|
|
393
|
+
- uses: actions/checkout@v2
|
|
394
|
+
|
|
395
|
+
- name: Set up Ruby
|
|
396
|
+
uses: ruby/setup-ruby@v1
|
|
397
|
+
with:
|
|
398
|
+
ruby-version: '3.0'
|
|
399
|
+
|
|
400
|
+
- name: Install Expressir
|
|
401
|
+
run: gem install expressir
|
|
402
|
+
|
|
403
|
+
- name: Check ASCII compliance
|
|
404
|
+
run: |
|
|
405
|
+
if expressir validate ascii schemas/ --recursive; then
|
|
406
|
+
echo "✓ All schemas are ASCII-compliant"
|
|
407
|
+
else
|
|
408
|
+
echo "✗ Non-ASCII characters found in code"
|
|
409
|
+
echo "Note: Unicode in remarks is OK"
|
|
410
|
+
exit 1
|
|
411
|
+
fi
|
|
412
|
+
----
|
|
413
|
+
|
|
414
|
+
==== Batch Processing with Report
|
|
415
|
+
|
|
416
|
+
[source,bash]
|
|
417
|
+
----
|
|
418
|
+
#!/bin/bash
|
|
419
|
+
# Generate ASCII validation report
|
|
420
|
+
|
|
421
|
+
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
|
422
|
+
REPORT="ascii_validation_${TIMESTAMP}.yaml"
|
|
423
|
+
|
|
424
|
+
echo "Running ASCII validation..."
|
|
425
|
+
expressir validate ascii schemas/ --recursive --yaml > "$REPORT"
|
|
426
|
+
|
|
427
|
+
if [ $? -eq 0 ]; then
|
|
428
|
+
echo "✓ All schemas are ASCII-compliant"
|
|
429
|
+
echo "Report saved to: $REPORT"
|
|
430
|
+
else
|
|
431
|
+
echo "✗ Violations found - see report: $REPORT"
|
|
432
|
+
|
|
433
|
+
# Parse YAML and show summary
|
|
434
|
+
echo ""
|
|
435
|
+
echo "Summary:"
|
|
436
|
+
grep -A 4 "summary:" "$REPORT"
|
|
437
|
+
fi
|
|
438
|
+
----
|
|
439
|
+
|
|
440
|
+
==== Pre-commit Hook
|
|
441
|
+
|
|
442
|
+
[source,bash]
|
|
443
|
+
----
|
|
444
|
+
#!/bin/bash
|
|
445
|
+
# .git/hooks/pre-commit
|
|
446
|
+
|
|
447
|
+
# Get staged .exp files
|
|
448
|
+
STAGED_EXP=$(git diff --cached --name-only --diff-filter=ACM | grep '\.exp$')
|
|
449
|
+
|
|
450
|
+
if [ -z "$STAGED_EXP" ]; then
|
|
451
|
+
exit 0
|
|
452
|
+
fi
|
|
453
|
+
|
|
454
|
+
echo "Checking ASCII compliance of staged schemas..."
|
|
455
|
+
|
|
456
|
+
for file in $STAGED_EXP; do
|
|
457
|
+
if ! expressir validate ascii "$file"; then
|
|
458
|
+
echo ""
|
|
459
|
+
echo "❌ $file contains non-ASCII characters in code"
|
|
460
|
+
echo " (Unicode in remarks is OK)"
|
|
461
|
+
echo ""
|
|
462
|
+
echo "Please either:"
|
|
463
|
+
echo " 1. Remove non-ASCII from code sections"
|
|
464
|
+
echo " 2. Move Unicode text to remarks"
|
|
465
|
+
echo " 3. Use ISO 10303-11 encoding"
|
|
466
|
+
exit 1
|
|
467
|
+
fi
|
|
468
|
+
done
|
|
469
|
+
|
|
470
|
+
echo "✓ All staged schemas are ASCII-compliant"
|
|
471
|
+
----
|
|
472
|
+
|
|
473
|
+
=== Common Scenarios
|
|
474
|
+
|
|
475
|
+
==== Greek Letters in Formulas
|
|
476
|
+
|
|
477
|
+
.Problem
|
|
478
|
+
[example]
|
|
479
|
+
====
|
|
480
|
+
[source,express]
|
|
481
|
+
----
|
|
482
|
+
FUNCTION area (radius : REAL) : REAL;
|
|
483
|
+
RETURN π × radius × radius; (* ✗ Non-ASCII *)
|
|
484
|
+
END_FUNCTION;
|
|
485
|
+
----
|
|
486
|
+
====
|
|
487
|
+
|
|
488
|
+
.Solution 1: Use ASCII names
|
|
489
|
+
[example]
|
|
490
|
+
====
|
|
491
|
+
[source,express]
|
|
492
|
+
----
|
|
493
|
+
FUNCTION area (radius : REAL) : REAL;
|
|
494
|
+
LOCAL
|
|
495
|
+
pi : REAL := 3.14159265359;
|
|
496
|
+
END_LOCAL;
|
|
497
|
+
RETURN pi * radius * radius; (* ✓ ASCII *)
|
|
498
|
+
END_FUNCTION;
|
|
499
|
+
----
|
|
500
|
+
====
|
|
501
|
+
|
|
502
|
+
.Solution 2: Move to remark
|
|
503
|
+
[example]
|
|
504
|
+
----
|
|
505
|
+
FUNCTION area (radius : REAL) : REAL;
|
|
506
|
+
-- Formula: π × r²
|
|
507
|
+
RETURN 3.14159265359 * radius * radius;
|
|
508
|
+
END_FUNCTION;
|
|
509
|
+
----
|
|
510
|
+
====
|
|
511
|
+
|
|
512
|
+
==== International Names
|
|
513
|
+
|
|
514
|
+
.Problem
|
|
515
|
+
[example]
|
|
516
|
+
====
|
|
517
|
+
[source,express]
|
|
518
|
+
----
|
|
519
|
+
ENTITY 製品; (* ✗ Non-ASCII in entity name *)
|
|
520
|
+
名前 : STRING; (* ✗ Non-ASCII in attribute name *)
|
|
521
|
+
END_ENTITY;
|
|
522
|
+
----
|
|
523
|
+
====
|
|
524
|
+
|
|
525
|
+
.Solution: Use English names with Unicode in remarks
|
|
526
|
+
[example]
|
|
527
|
+
----
|
|
528
|
+
ENTITY product; (* Japanese: 製品 *)
|
|
529
|
+
name : STRING; -- Japanese: 名前
|
|
530
|
+
END_ENTITY;
|
|
531
|
+
----
|
|
532
|
+
====
|
|
533
|
+
|
|
534
|
+
==== Mathematical Operators
|
|
535
|
+
|
|
536
|
+
.Problem
|
|
537
|
+
[example]
|
|
538
|
+
====
|
|
539
|
+
[source,express]
|
|
540
|
+
----
|
|
541
|
+
result := a × b ÷ c; (* ✗ Non-ASCII operators *)
|
|
542
|
+
----
|
|
543
|
+
====
|
|
544
|
+
|
|
545
|
+
.Solution: Use ASCII operators
|
|
546
|
+
[example]
|
|
547
|
+
----
|
|
548
|
+
result := a * b / c; (* ✓ ASCII operators *)
|
|
549
|
+
----
|
|
550
|
+
====
|
|
551
|
+
|
|
552
|
+
=== Best Practices
|
|
553
|
+
|
|
554
|
+
**Use Remarks for Unicode**::
|
|
555
|
+
Place all Unicode text in remarks where it won't affect processing
|
|
556
|
+
+
|
|
557
|
+
[source,express]
|
|
558
|
+
----
|
|
559
|
+
-- Description in Chinese: 這是一個測試實體
|
|
560
|
+
ENTITY test_entity;
|
|
561
|
+
(* Korean description: 이것은 테스트 엔티티입니다 *)
|
|
562
|
+
value : REAL;
|
|
563
|
+
END_ENTITY;
|
|
564
|
+
----
|
|
565
|
+
|
|
566
|
+
**Validate Before Export**::
|
|
567
|
+
Always check ASCII compliance before exporting to formats that don't support Unicode
|
|
568
|
+
|
|
569
|
+
**Document Replacements**::
|
|
570
|
+
When replacing Unicode with ASCII, document the original in remarks
|
|
571
|
+
+
|
|
572
|
+
[source,express]
|
|
573
|
+
----
|
|
574
|
+
-- Original formula used μ (mu) for micro units
|
|
575
|
+
microns : REAL; -- micrometers
|
|
576
|
+
----
|
|
577
|
+
|
|
578
|
+
**Use Constants for Special Values**::
|
|
579
|
+
Define constants for repeated special values
|
|
580
|
+
+
|
|
581
|
+
[source,express]
|
|
582
|
+
----
|
|
583
|
+
CONSTANT
|
|
584
|
+
pi : REAL := 3.14159265359;
|
|
585
|
+
planck_h : REAL := 6.62607015E-34; -- Planck constant
|
|
586
|
+
END_CONSTANT;
|
|
587
|
+
----
|
|
588
|
+
|
|
589
|
+
**Automate Validation**::
|
|
590
|
+
Add to CI/CD pipelines for continuous compliance checking
|
|
591
|
+
|
|
592
|
+
=== Troubleshooting
|
|
593
|
+
|
|
594
|
+
==== False Positives in Remarks
|
|
595
|
+
|
|
596
|
+
**Problem**: Characters in remarks are being flagged
|
|
597
|
+
|
|
598
|
+
**Cause**: Incorrect remark syntax
|
|
599
|
+
|
|
600
|
+
**Solution**: Verify remark delimiters:
|
|
601
|
+
[source,express]
|
|
602
|
+
----
|
|
603
|
+
(* Correct embedded remark *)
|
|
604
|
+
-- Correct tail remark
|
|
605
|
+
|
|
606
|
+
(* Incorrect - missing closing *)
|
|
607
|
+
-- This extends to end of line automatically ✓
|
|
608
|
+
----
|
|
609
|
+
|
|
610
|
+
==== Nested Remarks
|
|
611
|
+
|
|
612
|
+
**Problem**: Validation doesn't handle nested remarks correctly
|
|
613
|
+
|
|
614
|
+
**Solution**: The validator handles nested embedded remarks:
|
|
615
|
+
[source,express]
|
|
616
|
+
----
|
|
617
|
+
(* Outer (* Inner 中文 *) remark *) (* ✓ Both excluded *)
|
|
618
|
+
----
|
|
619
|
+
|
|
620
|
+
==== Binary File Issues
|
|
621
|
+
|
|
622
|
+
**Problem**: Validation fails on binary files
|
|
623
|
+
|
|
624
|
+
**Cause**: File is not a text file
|
|
625
|
+
|
|
626
|
+
**Solution**: Ensure files are text-encoded EXPRESS files:
|
|
627
|
+
[source,bash]
|
|
628
|
+
----
|
|
629
|
+
file schema.exp # Should show "text" or "UTF-8"
|
|
630
|
+
----
|
|
631
|
+
|
|
632
|
+
=== Summary
|
|
633
|
+
|
|
634
|
+
The validate ascii command:
|
|
635
|
+
|
|
636
|
+
* ✅ Validates ASCII-only content in EXPRESS code
|
|
637
|
+
* ✅ Excludes tagged remarks from validation
|
|
638
|
+
* ✅ Supports both embedded and tail remarks
|
|
639
|
+
* ✅ Accepts Schema Manifest input
|
|
640
|
+
* ✅ Provides replacement suggestions
|
|
641
|
+
* ✅ Offers YAML output for automation
|
|
642
|
+
* ✅ Handles recursive directory scanning
|
|
643
|
+
* ✅ Shows detailed violation information
|
|
644
|
+
|
|
645
|
+
Use this command to ensure EXPRESS schemas are compatible with ASCII-only systems while maintaining readable Unicode documentation.
|