Skip to content

Commit 75167b6

Browse files
authored
Parse all translated unicode specs (#142)
Signed-off-by: Andrew Helwer <[email protected]>
1 parent 7c8ceab commit 75167b6

File tree

5 files changed

+10
-29
lines changed

5 files changed

+10
-29
lines changed

.github/scripts/check_manifest_features.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,13 @@ def get_community_imports(examples_root, tree, text, dir, has_proof, queries):
146146
"""
147147
imports = set(
148148
[
149-
text[node.start_byte:node.end_byte].decode('utf-8')
149+
tla_utils.node_to_string(text, node)
150150
for node, _ in queries.imports.captures(tree.root_node)
151151
]
152152
)
153153
modules_in_file = set(
154154
[
155-
text[node.start_byte:node.end_byte].decode('utf-8')
155+
tla_utils.node_to_string(text, node)
156156
for node, _ in queries.module_names.captures(tree.root_node)
157157
]
158158
)

.github/scripts/check_markdown_table.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ def from_json(spec):
180180
for path, json, md in different_tlc_flag:
181181
print(f'Spec {path} ' + ('incorrectly has' if md else 'is missing') + ' a TLC Model flag in README.md table')
182182

183-
'''
184183
# Ensure Apalache flag is correct
185184
different_apalache_flag = [
186185
(manifest_spec.path, manifest_spec.apalache, table_spec.apalache)
@@ -192,7 +191,6 @@ def from_json(spec):
192191
print('ERROR: Apalache Model flags in README.md table differ from model records in manifest.json:')
193192
for path, json, md in different_tlc_flag:
194193
print(f'Spec {path} ' + ('incorrectly has' if md else 'is missing') + ' an Apalache Model flag in README.md table')
195-
'''
196194

197195
if success:
198196
print('SUCCESS: manifest.json concords with README.md table')

.github/scripts/tla_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ def parse_module(examples_root, parser, path):
6262
tree = parser.parse(module_text)
6363
return (tree, module_text, tree.root_node.has_error)
6464

65+
def node_to_string(module_bytes, node):
66+
"""
67+
Gets the string covered by the given tree-sitter parse tree node.
68+
"""
69+
return module_bytes[node.start_byte:node.end_byte].decode('utf-8')
70+
6571
def parse_timespan(unparsed):
6672
"""
6773
Parses the timespan format used in the manifest.json format.

.github/scripts/unicode_number_set_shim.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ def build_imports_query(language):
7575
]
7676
return language.query(' '.join(queries))
7777

78-
def node_to_string(module_bytes, node):
79-
"""
80-
Gets the string covered by the given parse tree node.
81-
"""
82-
return module_bytes[node.byte_range[0]:node.byte_range[1]].decode('utf-8')
83-
8478
def replace_with_shim(module_bytes, node, byte_offset, shim):
8579
"""
8680
Replace the text covered by the given parse tree node with a reference to
@@ -100,7 +94,7 @@ def replace_imports(module_bytes, tree, query):
10094
imported_modules = [
10195
(imported_module, shim_modules[module_name])
10296
for imported_module, _ in query.captures(tree.root_node)
103-
if (module_name := node_to_string(module_bytes, imported_module)) in shim_modules
97+
if (module_name := tla_utils.node_to_string(module_bytes, imported_module)) in shim_modules
10498
]
10599
byte_offset = 0
106100
for imported_module, shim in imported_modules:

.github/workflows/CI.yml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,34 +94,17 @@ jobs:
9494
fi
9595
- name: Parse all modules
9696
run: |
97-
# Need to have a nonempty list to pass as a skip parameter
98-
SKIP=("does/not/exist")
99-
if [ ${{ matrix.unicode }} ]; then
100-
# These redefine Nat, Int, or Real so cannot be shimmed
101-
SKIP+=(
102-
"specifications/SpecifyingSystems/Standard/Naturals.tla"
103-
"specifications/SpecifyingSystems/Standard/Peano.tla"
104-
"specifications/SpecifyingSystems/Standard/Integers.tla"
105-
"specifications/SpecifyingSystems/Standard/Reals.tla"
106-
"specifications/SpecifyingSystems/Standard/ProtoReals.tla"
107-
"specifications/SpecifyingSystems/RealTime/MCRealTime.tla"
108-
"specifications/SpecifyingSystems/RealTime/MCRealTimeHourClock.tla"
109-
)
110-
fi
11197
python $SCRIPT_DIR/parse_modules.py \
11298
--tools_jar_path $DEPS_DIR/tools/tla2tools.jar \
11399
--apalache_path $DEPS_DIR/apalache \
114100
--tlapm_lib_path $DEPS_DIR/tlapm/library \
115101
--community_modules_jar_path $DEPS_DIR/community/modules.jar \
116-
--manifest_path manifest.json \
117-
--skip "${SKIP[@]}"
102+
--manifest_path manifest.json
118103
- name: Check small models
119104
run: |
120105
# Need to have a nonempty list to pass as a skip parameter
121106
SKIP=("does/not/exist")
122107
if [ ${{ matrix.unicode }} ]; then
123-
# This redefines Real so cannot be shimmed
124-
SKIP+=("specifications/SpecifyingSystems/RealTime/MCRealTimeHourClock.cfg")
125108
# Apalache does not yet support Unicode
126109
SKIP+=("specifications/EinsteinRiddle/Einstein.cfg")
127110
fi

0 commit comments

Comments
 (0)