interscript 2.4.5 → 3.0.0
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 +15 -0
- data/docs/demo/20191118-interscript-demo-cast.gif +0 -0
- data/exe/codemod-imp-to-isc +5 -0
- data/exe/diagnose_parse_failures +47 -0
- data/exe/interscript +2 -1
- data/exe/verify_isc_deep +211 -0
- data/exe/verify_isc_equivalence +128 -0
- data/interscript.gemspec +27 -20
- data/lib/interscript/command.rb +21 -12
- data/lib/interscript/compiler/javascript.rb +34 -35
- data/lib/interscript/compiler/json_ir.rb +214 -0
- data/lib/interscript/compiler/python.rb +354 -0
- data/lib/interscript/compiler/ruby.rb +23 -22
- data/lib/interscript/compiler.rb +20 -3
- data/lib/interscript/detector.rb +14 -7
- data/lib/interscript/dsl/aliases.rb +1 -1
- data/lib/interscript/dsl/document.rb +6 -3
- data/lib/interscript/dsl/group/parallel.rb +1 -1
- data/lib/interscript/dsl/group.rb +18 -9
- data/lib/interscript/dsl/items.rb +28 -16
- data/lib/interscript/dsl/metadata.rb +19 -18
- data/lib/interscript/dsl/stage.rb +1 -1
- data/lib/interscript/dsl/symbol_mm.rb +4 -2
- data/lib/interscript/dsl/tests.rb +1 -1
- data/lib/interscript/dsl.rb +21 -13
- data/lib/interscript/interpreter.rb +32 -21
- data/lib/interscript/isc/codemod.rb +791 -0
- data/lib/interscript/isc/document_builder.rb +354 -0
- data/lib/interscript/isc/generator.rb +191 -0
- data/lib/interscript/isc/grammar/concerns/aliases.rb +29 -0
- data/lib/interscript/isc/grammar/concerns/dependencies.rb +23 -0
- data/lib/interscript/isc/grammar/concerns/items.rb +176 -0
- data/lib/interscript/isc/grammar/concerns/metadata.rb +142 -0
- data/lib/interscript/isc/grammar/concerns/primitives.rb +112 -0
- data/lib/interscript/isc/grammar/concerns/stages.rb +129 -0
- data/lib/interscript/isc/grammar/concerns/system.rb +37 -0
- data/lib/interscript/isc/grammar/concerns/tests.rb +31 -0
- data/lib/interscript/isc/grammar/concerns.rb +18 -0
- data/lib/interscript/isc/grammar/core.rb +23 -0
- data/lib/interscript/isc/grammar/isc.artifact.json +1 -0
- data/lib/interscript/isc/grammar/isc.parg +196 -0
- data/lib/interscript/isc/grammar.rb +12 -0
- data/lib/interscript/isc/items.rb +185 -0
- data/lib/interscript/isc/model/alias.rb +20 -0
- data/lib/interscript/isc/model/constraint.rb +20 -0
- data/lib/interscript/isc/model/dependency.rb +19 -0
- data/lib/interscript/isc/model/document.rb +31 -0
- data/lib/interscript/isc/model/item.rb +50 -0
- data/lib/interscript/isc/model/rule.rb +23 -0
- data/lib/interscript/isc/model/stage.rb +20 -0
- data/lib/interscript/isc/model/stage_item.rb +33 -0
- data/lib/interscript/isc/model/test.rb +21 -0
- data/lib/interscript/isc/model.rb +19 -0
- data/lib/interscript/isc/node_adapter.rb +310 -0
- data/lib/interscript/isc/normalizer.rb +127 -0
- data/lib/interscript/isc/parser.rb +78 -0
- data/lib/interscript/isc/serializer.rb +248 -0
- data/lib/interscript/isc/transform.rb +138 -0
- data/lib/interscript/isc/yaml_bridge.rb +236 -0
- data/lib/interscript/isc.rb +30 -0
- data/lib/interscript/ml/byt5_onnx.rb +102 -0
- data/lib/interscript/ml/imf.rb +182 -0
- data/lib/interscript/ml/model.rb +52 -0
- data/lib/interscript/ml/provisioning.rb +189 -0
- data/lib/interscript/ml/translator.rb +38 -0
- data/lib/interscript/ml/vocab.rb +48 -0
- data/lib/interscript/ml.rb +25 -0
- data/lib/interscript/node/alias_def.rb +5 -5
- data/lib/interscript/node/dependency.rb +7 -7
- data/lib/interscript/node/document.rb +10 -10
- data/lib/interscript/node/group.rb +11 -9
- data/lib/interscript/node/item/alias.rb +14 -10
- data/lib/interscript/node/item/any.rb +14 -7
- data/lib/interscript/node/item/capture.rb +14 -9
- data/lib/interscript/node/item/group.rb +22 -17
- data/lib/interscript/node/item/repeat.rb +3 -3
- data/lib/interscript/node/item/stage.rb +4 -5
- data/lib/interscript/node/item/string.rb +18 -13
- data/lib/interscript/node/item.rb +27 -17
- data/lib/interscript/node/metadata.rb +6 -5
- data/lib/interscript/node/rule/funcall.rb +4 -5
- data/lib/interscript/node/rule/run.rb +4 -5
- data/lib/interscript/node/rule/sub.rb +55 -55
- data/lib/interscript/node/rule.rb +6 -5
- data/lib/interscript/node/stage.rb +11 -14
- data/lib/interscript/node/tests.rb +6 -6
- data/lib/interscript/node.rb +14 -17
- data/lib/interscript/stdlib/functions/rababa_adapter.rb +56 -0
- data/lib/interscript/stdlib/functions/secryst_adapter.rb +37 -0
- data/lib/interscript/stdlib/functions.rb +49 -0
- data/lib/interscript/stdlib.rb +25 -95
- data/lib/interscript/utils/helpers.rb +8 -5
- data/lib/interscript/utils/regexp_converter.rb +143 -144
- data/lib/interscript/version.rb +1 -1
- data/lib/interscript/visualize/json.rb +12 -13
- data/lib/interscript/visualize/nodes.rb +13 -13
- data/lib/interscript/visualize.rb +18 -18
- data/lib/interscript.rb +59 -45
- metadata +88 -31
- data/.github/workflows/assets.yml +0 -91
- data/.github/workflows/rake.yml +0 -52
- data/.github/workflows/release.yml +0 -68
- data/.gitignore +0 -79
- data/.rspec +0 -3
- data/Gemfile +0 -38
- data/Rakefile +0 -139
- data/bin/console +0 -10
- data/bin/interscript +0 -5
- data/bin/maps_analyze_staging +0 -168
- data/bin/maps_debug_compilers +0 -58
- data/bin/maps_debug_ordering +0 -88
- data/bin/maps_debug_ruby_compile +0 -24
- data/bin/maps_debug_step_by_step +0 -44
- data/bin/maps_optimize_order +0 -112
- data/bin/maps_v1_analyze_regexps +0 -45
- data/bin/maps_v1_to_v2 +0 -426
- data/bin/set_version +0 -16
- data/bin/setup +0 -8
- data/requirements.txt +0 -1
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
name: release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
tags:
|
|
6
|
-
- 'v*'
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
release:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- name: Checkout repository
|
|
13
|
-
uses: actions/checkout@v2
|
|
14
|
-
with:
|
|
15
|
-
repository: interscript/interscript
|
|
16
|
-
|
|
17
|
-
- name: Run bootstrap script
|
|
18
|
-
run: ruby bootstrap.rb
|
|
19
|
-
|
|
20
|
-
- uses: ruby/setup-ruby@v1
|
|
21
|
-
with:
|
|
22
|
-
ruby-version: '3.0'
|
|
23
|
-
|
|
24
|
-
- uses: actions/setup-node@v1
|
|
25
|
-
with:
|
|
26
|
-
node-version: 14.x
|
|
27
|
-
|
|
28
|
-
# For now let's install without secryst, as we don't necessarily need it.
|
|
29
|
-
# We may need to change it once we start to depend on secryst maps.
|
|
30
|
-
- name: Install bundle
|
|
31
|
-
working-directory: ./ruby
|
|
32
|
-
run: bundle install --jobs 4 --retry 3 --with jsexec --without secryst
|
|
33
|
-
|
|
34
|
-
- name: Test Ruby package
|
|
35
|
-
working-directory: ./ruby
|
|
36
|
-
run: bundle exec rake
|
|
37
|
-
|
|
38
|
-
- name: Test JS package
|
|
39
|
-
working-directory: ./js
|
|
40
|
-
run: npm install && npm run prepareMaps && npm test
|
|
41
|
-
|
|
42
|
-
- name: Publish to rubygems.org
|
|
43
|
-
env:
|
|
44
|
-
RUBYGEMS_API_KEY: ${{secrets.INTERSCRIPT_RUBYGEMS_API_KEY}}
|
|
45
|
-
run: |
|
|
46
|
-
gem install gem-release
|
|
47
|
-
mkdir -p ~/.gem
|
|
48
|
-
touch ~/.gem/credentials
|
|
49
|
-
cat > ~/.gem/credentials << EOF
|
|
50
|
-
---
|
|
51
|
-
:rubygems_api_key: ${RUBYGEMS_API_KEY}
|
|
52
|
-
EOF
|
|
53
|
-
chmod 0600 ~/.gem/credentials
|
|
54
|
-
pushd ruby
|
|
55
|
-
git status
|
|
56
|
-
gem release
|
|
57
|
-
popd
|
|
58
|
-
|
|
59
|
-
# Let's keep it commented out for now. Please uncomment it once you are ready with
|
|
60
|
-
# interscript-api to support Interscript v2.
|
|
61
|
-
#
|
|
62
|
-
#- name: Trigger interscript-api
|
|
63
|
-
# uses: peter-evans/repository-dispatch@v1
|
|
64
|
-
# with:
|
|
65
|
-
# token: ${{ secrets.INTERSCRIPT_CI_PAT_TOKEN }}
|
|
66
|
-
# repository: interscript/interscript-api
|
|
67
|
-
# event-type: ${{ github.repository }}
|
|
68
|
-
# client-payload: '{ "ref": "${{ github.ref }}" }'
|
data/.gitignore
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
*.gem
|
|
2
|
-
*.rbc
|
|
3
|
-
/.config
|
|
4
|
-
/coverage/
|
|
5
|
-
/InstalledFiles
|
|
6
|
-
/pkg/
|
|
7
|
-
/spec/reports/
|
|
8
|
-
/spec/examples.txt
|
|
9
|
-
/test/tmp/
|
|
10
|
-
/test/version_tmp/
|
|
11
|
-
/tmp/
|
|
12
|
-
/Gemfile.lock
|
|
13
|
-
|
|
14
|
-
# Used by dotenv library to load environment variables.
|
|
15
|
-
# .env
|
|
16
|
-
|
|
17
|
-
# Ignore Byebug command history file.
|
|
18
|
-
.byebug_history
|
|
19
|
-
|
|
20
|
-
## Specific to RubyMotion:
|
|
21
|
-
.dat*
|
|
22
|
-
.repl_history
|
|
23
|
-
/build/
|
|
24
|
-
*.bridgesupport
|
|
25
|
-
/build-iPhoneOS/
|
|
26
|
-
/build-iPhoneSimulator/
|
|
27
|
-
|
|
28
|
-
## Specific to RubyMotion (use of CocoaPods):
|
|
29
|
-
#
|
|
30
|
-
# We recommend against adding the Pods directory to your .gitignore. However
|
|
31
|
-
# you should judge for yourself, the pros and cons are mentioned at:
|
|
32
|
-
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
|
33
|
-
#
|
|
34
|
-
# vendor/Pods/
|
|
35
|
-
|
|
36
|
-
## Documentation cache and generated files:
|
|
37
|
-
/.yardoc/
|
|
38
|
-
/_yardoc/
|
|
39
|
-
/doc/
|
|
40
|
-
/rdoc/
|
|
41
|
-
|
|
42
|
-
## Environment normalization:
|
|
43
|
-
/.bundle/
|
|
44
|
-
/vendor/bundle
|
|
45
|
-
/lib/bundler/man/
|
|
46
|
-
|
|
47
|
-
# for a library or gem, you might want to ignore these files since the code is
|
|
48
|
-
# intended to run in multiple environments; otherwise, check them in:
|
|
49
|
-
# Gemfile.lock
|
|
50
|
-
# .ruby-version
|
|
51
|
-
# .ruby-gemset
|
|
52
|
-
|
|
53
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
54
|
-
/.rvmrc
|
|
55
|
-
|
|
56
|
-
# Don't bundle generated files
|
|
57
|
-
/visualizations
|
|
58
|
-
/json
|
|
59
|
-
/vis_json
|
|
60
|
-
/auth_json
|
|
61
|
-
/metadata.json
|
|
62
|
-
/compiled
|
|
63
|
-
|
|
64
|
-
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
|
65
|
-
# .rubocop-https?--*
|
|
66
|
-
|
|
67
|
-
#misic
|
|
68
|
-
.idea
|
|
69
|
-
.bundle/.bundle/
|
|
70
|
-
/.yardoc
|
|
71
|
-
/_yardoc/
|
|
72
|
-
/coverage/
|
|
73
|
-
/doc/
|
|
74
|
-
/pkg/
|
|
75
|
-
/spec/reports/
|
|
76
|
-
/tmp/
|
|
77
|
-
|
|
78
|
-
# rspec failure tracking
|
|
79
|
-
.rspec_status
|
data/.rspec
DELETED
data/Gemfile
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
source "https://rubygems.org"
|
|
2
|
-
|
|
3
|
-
# Specify your gem's dependencies in interscript.gemspec
|
|
4
|
-
gemspec
|
|
5
|
-
|
|
6
|
-
gem "rake", "~> 12.0"
|
|
7
|
-
gem "rspec", "~> 3.0"
|
|
8
|
-
|
|
9
|
-
gem "interscript-maps", path: "../maps"
|
|
10
|
-
|
|
11
|
-
unless Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.7")
|
|
12
|
-
group :secryst do
|
|
13
|
-
if File.exist? "../../secryst"
|
|
14
|
-
gem "secryst", path: "../../secryst"
|
|
15
|
-
else
|
|
16
|
-
gem "secryst"
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
gem 'regexp_parser'
|
|
22
|
-
|
|
23
|
-
unless ENV["SKIP_JS"]
|
|
24
|
-
group :jsexec do
|
|
25
|
-
gem 'mini_racer'
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
group :rababa do
|
|
30
|
-
gem 'rababa', "~> 0.1.1"
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
gem 'pry'
|
|
34
|
-
|
|
35
|
-
gem 'iso-639-data'
|
|
36
|
-
gem 'iso-15924'
|
|
37
|
-
|
|
38
|
-
gem 'simplecov', require: false, group: :test
|
data/Rakefile
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
require "bundler/setup"
|
|
2
|
-
require "bundler/gem_tasks"
|
|
3
|
-
require "rspec/core/rake_task"
|
|
4
|
-
|
|
5
|
-
RSpec::Core::RakeTask.new(:spec)
|
|
6
|
-
|
|
7
|
-
task :compile, [:compiler, :target] do |t, args|
|
|
8
|
-
require "interscript"
|
|
9
|
-
|
|
10
|
-
compiler, ext = case args[:compiler]
|
|
11
|
-
when "ruby"
|
|
12
|
-
require "interscript/compiler/ruby"
|
|
13
|
-
[Interscript::Compiler::Ruby, "rb"]
|
|
14
|
-
when "javascript"
|
|
15
|
-
require "interscript/compiler/javascript"
|
|
16
|
-
[Interscript::Compiler::Javascript, "js"]
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
FileUtils.mkdir_p(args[:target])
|
|
20
|
-
|
|
21
|
-
maplist = {}
|
|
22
|
-
|
|
23
|
-
maps = Interscript.maps
|
|
24
|
-
maps = Interscript.exclude_maps(maps, compiler: compiler, platform: false)
|
|
25
|
-
|
|
26
|
-
maps.each do |map|
|
|
27
|
-
code = compiler.(map).code
|
|
28
|
-
File.write(args[:target] + "/" + map + "." + ext, code)
|
|
29
|
-
maplist[map] = nil
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
Interscript.maps(libraries: true).each do |map|
|
|
33
|
-
code = compiler.(map).code
|
|
34
|
-
File.write(args[:target] + "/" + map + "." + ext, code)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
File.write(args[:target] + "/index.json", maplist.to_json)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
task :generate_visualization_html do
|
|
41
|
-
require "fileutils"
|
|
42
|
-
require "interscript"
|
|
43
|
-
require "interscript/visualize"
|
|
44
|
-
|
|
45
|
-
FileUtils.rm_rf(dir = __dir__+"/visualizations/")
|
|
46
|
-
FileUtils.mkdir_p(dir)
|
|
47
|
-
|
|
48
|
-
Interscript.maps.each do |map|
|
|
49
|
-
html = Interscript::Visualize.(map)
|
|
50
|
-
File.write(dir+map+".html", html)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
task :generate_metadata_json do
|
|
55
|
-
require "fileutils"
|
|
56
|
-
require "json"
|
|
57
|
-
require "interscript"
|
|
58
|
-
require "interscript/compiler/javascript"
|
|
59
|
-
|
|
60
|
-
FileUtils.rm_rf(file = __dir__+"/metadata.json")
|
|
61
|
-
|
|
62
|
-
hash = Interscript.maps.map do |map|
|
|
63
|
-
parsed_map = Interscript.parse(map)
|
|
64
|
-
md = parsed_map.metadata.to_hash
|
|
65
|
-
md["test"] = parsed_map.tests&.data&.first
|
|
66
|
-
md["skip_js"] = Interscript.exclude_maps([map],
|
|
67
|
-
compiler: Interscript::Compiler::Javascript,
|
|
68
|
-
platform: false,
|
|
69
|
-
).empty?
|
|
70
|
-
[map, md]
|
|
71
|
-
end.to_h
|
|
72
|
-
|
|
73
|
-
File.write(file, JSON.pretty_generate(hash))
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
task :generate_json do
|
|
77
|
-
require "fileutils"
|
|
78
|
-
require "json"
|
|
79
|
-
require "interscript"
|
|
80
|
-
|
|
81
|
-
FileUtils.rm_rf(dir = __dir__+"/json/")
|
|
82
|
-
FileUtils.mkdir_p(dir)
|
|
83
|
-
|
|
84
|
-
(Interscript.maps + Interscript.maps(libraries: true)).each do |map|
|
|
85
|
-
json = JSON.pretty_generate(Interscript.parse(map).to_hash)
|
|
86
|
-
File.write(dir+map+".json", json)
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
task :generate_visualization_json do
|
|
91
|
-
require "fileutils"
|
|
92
|
-
require "interscript"
|
|
93
|
-
require "json"
|
|
94
|
-
require "interscript/visualize"
|
|
95
|
-
|
|
96
|
-
FileUtils.rm_rf(dir = __dir__+"/vis_json/")
|
|
97
|
-
FileUtils.mkdir_p(dir)
|
|
98
|
-
|
|
99
|
-
(Interscript.maps + Interscript.maps(libraries: true)).each do |map_name|
|
|
100
|
-
map = Interscript.parse(map_name)
|
|
101
|
-
map.stages.each do |stage_name, stage|
|
|
102
|
-
json = JSON.pretty_generate(stage.to_visualization_array(map))
|
|
103
|
-
File.write(dir+map_name+"_#{stage_name}.json", json)
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
task :generate_authority_json do
|
|
109
|
-
require "interscript"
|
|
110
|
-
require "json"
|
|
111
|
-
require "iso-639-data"
|
|
112
|
-
|
|
113
|
-
FileUtils.rm_rf(dir = __dir__+"/auth_json/")
|
|
114
|
-
FileUtils.mkdir_p(dir)
|
|
115
|
-
|
|
116
|
-
%w[iso icao din].each do |auth|
|
|
117
|
-
out = Interscript.maps.select do |map_name|
|
|
118
|
-
map_name.start_with? "#{auth}-"
|
|
119
|
-
end.sort.map do |map_name|
|
|
120
|
-
map = Interscript.parse(map_name)
|
|
121
|
-
tests = map.tests&.data&.first(2)&.transpose || []
|
|
122
|
-
std, lang = map.metadata.data[:language].split(':')
|
|
123
|
-
|
|
124
|
-
{
|
|
125
|
-
lang: std.end_with?("-3") ? Iso639Data.iso_639_3[lang]['Ref_Name'] : Iso639Data.iso_639_2[lang]['eng'],
|
|
126
|
-
isoName: map.metadata.data[:name],
|
|
127
|
-
systemName: map_name,
|
|
128
|
-
samples: tests[0] || [],
|
|
129
|
-
english: [],
|
|
130
|
-
result: []
|
|
131
|
-
}
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
json = JSON.pretty_generate(out)
|
|
135
|
-
File.write(dir+auth+".json", json)
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
task :default => :spec
|
data/bin/console
DELETED
data/bin/interscript
DELETED
data/bin/maps_analyze_staging
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
ENV["INTERSCRIPT_STAGING"] = "1"
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "interscript"
|
|
5
|
-
require "interscript/compiler/ruby"
|
|
6
|
-
|
|
7
|
-
$map_name = ARGV[0]
|
|
8
|
-
|
|
9
|
-
# surpress warnings
|
|
10
|
-
def warn(*)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def debug_single_map(from, expected, result, result2)
|
|
15
|
-
puts ""
|
|
16
|
-
# puts $subs_array.inspect
|
|
17
|
-
# puts $subs_matches.inspect
|
|
18
|
-
puts from.inspect
|
|
19
|
-
puts from.chars.inspect
|
|
20
|
-
puts from.codepoints.map{|cp| '\\u%04x' % cp}.join(' ')
|
|
21
|
-
puts expected
|
|
22
|
-
puts result
|
|
23
|
-
puts result2
|
|
24
|
-
return nil unless $subs_matches
|
|
25
|
-
first_mismatch = $subs_matches.select{|match_data|
|
|
26
|
-
exp = expected[match_data[:begin]...match_data[:end]]
|
|
27
|
-
res = result[match_data[:begin]...match_data[:end]]
|
|
28
|
-
exp != res
|
|
29
|
-
}.first
|
|
30
|
-
|
|
31
|
-
# puts $subs_matches.inspect
|
|
32
|
-
# puts first_mismatch.inspect
|
|
33
|
-
output_string = ''
|
|
34
|
-
last_end = 0
|
|
35
|
-
$subs_matches.each do |match_data|
|
|
36
|
-
substr = from[match_data[:begin]...match_data[:end]]
|
|
37
|
-
if match_data[:begin] != last_end
|
|
38
|
-
output_string << '_' * (match_data[:begin] - last_end)
|
|
39
|
-
end
|
|
40
|
-
output_string << match_data[:result]
|
|
41
|
-
|
|
42
|
-
puts ''
|
|
43
|
-
puts "ERROR " if match_data == first_mismatch
|
|
44
|
-
indent = ' ' * match_data[:begin]
|
|
45
|
-
# puts indent + substr
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
matched_rule = $subs_array[match_data[:idx]]
|
|
50
|
-
|
|
51
|
-
if match_data == first_mismatch
|
|
52
|
-
puts indent + matched_rule.inspect + " (#{matched_rule[0].codepoints.map{|cp| '\\u%04x' % cp}.join(' ')})"
|
|
53
|
-
else
|
|
54
|
-
puts indent + matched_rule.inspect + " (#{matched_rule[0].codepoints.map{|cp| '\\u%04x' % cp}.join(' ')})"
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
puts from[0,match_data[:end]]
|
|
58
|
-
|
|
59
|
-
puts expected[0,output_string.size]
|
|
60
|
-
puts output_string
|
|
61
|
-
last_end = match_data[:end]
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
#return if match_data == first_mismatch
|
|
65
|
-
end
|
|
66
|
-
puts ''
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def analyze_maps( filelist )
|
|
70
|
-
cache = {}
|
|
71
|
-
|
|
72
|
-
good_total = 0
|
|
73
|
-
almost_total = 0
|
|
74
|
-
bad_total = 0
|
|
75
|
-
passed_total = 0
|
|
76
|
-
for i in filelist
|
|
77
|
-
# used at the bottom
|
|
78
|
-
raw_lines = File.open(i).read.split("\n")
|
|
79
|
-
rules_line = raw_lines.index " # RULES"
|
|
80
|
-
characters_line = raw_lines.index " # CHARACTERS"
|
|
81
|
-
postrules_line = raw_lines.index " # POSTRULES"
|
|
82
|
-
|
|
83
|
-
system_name = File.basename(i, ".imp")
|
|
84
|
-
|
|
85
|
-
print "#{system_name}: "
|
|
86
|
-
|
|
87
|
-
exceptions = []
|
|
88
|
-
|
|
89
|
-
# begin
|
|
90
|
-
system = Interscript.parse(system_name)
|
|
91
|
-
# rescue Exception => e
|
|
92
|
-
# exceptions << e
|
|
93
|
-
# end
|
|
94
|
-
# puts $using_tree.inspect
|
|
95
|
-
if exceptions.length == 0 && system.tests && system.tests.data && system.tests.data.length > 0
|
|
96
|
-
good = 0
|
|
97
|
-
bad = 0
|
|
98
|
-
almost = 0
|
|
99
|
-
|
|
100
|
-
system.tests.data.each do |from,expected|
|
|
101
|
-
testname = from[0...300].gsub("\n", " / ")
|
|
102
|
-
|
|
103
|
-
result = Interscript.transliterate(system_name, from, cache, compiler: Interscript::Interpreter)
|
|
104
|
-
result2 = Interscript.transliterate(system_name, from, cache, compiler: Interscript::Compiler::Ruby)
|
|
105
|
-
if result == nil or result2 == nil
|
|
106
|
-
print '0'
|
|
107
|
-
bad += 1
|
|
108
|
-
elsif result != result2
|
|
109
|
-
# Compiler / Interpreter bug!
|
|
110
|
-
print "!"
|
|
111
|
-
bad += 1
|
|
112
|
-
elsif result == expected
|
|
113
|
-
print "."
|
|
114
|
-
good += 1
|
|
115
|
-
elsif result.unicode_normalize == expected.unicode_normalize
|
|
116
|
-
print ","
|
|
117
|
-
almost += 1
|
|
118
|
-
elsif result.unicode_normalize.chomp == expected.unicode_normalize.chomp
|
|
119
|
-
print ";"
|
|
120
|
-
almost += 1
|
|
121
|
-
else
|
|
122
|
-
print "#"
|
|
123
|
-
debug_single_map(from, expected, result, result2) if $map_name
|
|
124
|
-
bad += 1
|
|
125
|
-
end
|
|
126
|
-
rescue Exception => e
|
|
127
|
-
print "%"
|
|
128
|
-
bad += 1
|
|
129
|
-
exceptions << e
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
if bad == 0
|
|
133
|
-
passed_total += 1
|
|
134
|
-
puts " all tests passed!"
|
|
135
|
-
`git mv #{i} #{i.sub("-staging", "")}` if i.include? '-staging'
|
|
136
|
-
else
|
|
137
|
-
puts " (#{good}/#{good+almost+bad})"
|
|
138
|
-
end
|
|
139
|
-
good_total += good
|
|
140
|
-
almost_total += almost
|
|
141
|
-
bad_total += bad
|
|
142
|
-
elsif exceptions.length != 0
|
|
143
|
-
else
|
|
144
|
-
puts "no tests!"
|
|
145
|
-
end
|
|
146
|
-
puts "warning: postrules before rules\n\n" if (postrules_line||10000000) < (rules_line||0)
|
|
147
|
-
puts "warning: postrules before characters\n\n" if (postrules_line||10000000) < (characters_line||0)
|
|
148
|
-
|
|
149
|
-
Array(exceptions.first).compact.each do |e|
|
|
150
|
-
puts e.full_message
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
puts " #{good_total} (#{good_total+almost_total})/#{good_total+almost_total+bad_total}"
|
|
154
|
-
puts " #{passed_total} passed!"
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
#analyze_maps Dir[__dir__+"/../../maps/maps/*.imp"].sort
|
|
158
|
-
if $map_name
|
|
159
|
-
$DEBUG_RE = true
|
|
160
|
-
analyze_maps Dir[__dir__+"/../../maps/maps/#{$map_name}.imp"].sort
|
|
161
|
-
analyze_maps Dir[__dir__+"/../../maps/maps-staging/#{$map_name}.imp"].sort
|
|
162
|
-
else
|
|
163
|
-
analyze_maps Dir[__dir__+"/../../maps/maps-staging/*.imp"].sort
|
|
164
|
-
if ENV['NONSTAGING']
|
|
165
|
-
puts "\n" * 5
|
|
166
|
-
analyze_maps Dir[__dir__+"/../../maps/maps/*.imp"].sort
|
|
167
|
-
end
|
|
168
|
-
end
|
data/bin/maps_debug_compilers
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
require "bundler/setup"
|
|
3
|
-
require "interscript"
|
|
4
|
-
require "interscript/compiler/ruby"
|
|
5
|
-
require "interscript/compiler/javascript"
|
|
6
|
-
|
|
7
|
-
# Differing maps as of writing this code:
|
|
8
|
-
# - alalc-ara-Arab-Latn-1997
|
|
9
|
-
# - alalc-aze-Arab-Latn-1997
|
|
10
|
-
# - alalc-ell-Grek-Latn-2010
|
|
11
|
-
# - bgnpcgn-bal-Arab-Latn-2008
|
|
12
|
-
# - bgnpcgn-per-Arab-Latn-1958
|
|
13
|
-
# - bgnpcgn-prs-Arab-Latn-2007
|
|
14
|
-
# - bgnpcgn-pus-Arab-Latn-1968
|
|
15
|
-
# - bgnpcgn-ukr-Cyrl-Latn-1965
|
|
16
|
-
# - bgnpcgn-urd-Arab-Latn-2007
|
|
17
|
-
# - odni-ara-Arab-Latn-2004
|
|
18
|
-
# - odni-ara-Arab-Latn-2015
|
|
19
|
-
# - stategeocadastre-ukr-Cyrl-Latn-1993
|
|
20
|
-
# - ua-ukr-Cyrl-Latn-1996
|
|
21
|
-
# - un-ara-Arab-Latn-2017
|
|
22
|
-
# - un-ell-Grek-Latn-1987-phonetic
|
|
23
|
-
# - un-prs-Arab-Latn-1967
|
|
24
|
-
# - un-urd-Arab-Latn-1972
|
|
25
|
-
|
|
26
|
-
map = ARGV[0]
|
|
27
|
-
|
|
28
|
-
m = Interscript.parse(map)
|
|
29
|
-
|
|
30
|
-
cr = Interscript::Compiler::Ruby
|
|
31
|
-
mr = cr.(map, debug: true)
|
|
32
|
-
cj = Interscript::Compiler::Javascript
|
|
33
|
-
mj = cj.(map, debug: true)
|
|
34
|
-
|
|
35
|
-
m.tests.data.each do |from, expected|
|
|
36
|
-
r = mr.(from)
|
|
37
|
-
j = mj.(from)
|
|
38
|
-
|
|
39
|
-
next if r == j
|
|
40
|
-
|
|
41
|
-
dr = cr.read_debug_data
|
|
42
|
-
dj = cj.read_debug_data
|
|
43
|
-
|
|
44
|
-
dr.zip(dj).each do |er, ej|
|
|
45
|
-
if er[0] != ej[0]
|
|
46
|
-
puts "First differing rule in map: #{er[1]}, stage #{er[2]}"
|
|
47
|
-
puts "Ruby: #{er[0]}, Javascript: #{ej[0]}"
|
|
48
|
-
puts "Rule:\n#{er[3].gsub(/^/, " ")}"
|
|
49
|
-
puts "Generated Ruby code:\n#{er[4].gsub(/^/, " ")}"
|
|
50
|
-
puts "Generated Javascript code:\n#{ej[4].gsub(/^/, " ")}"
|
|
51
|
-
puts
|
|
52
|
-
break
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
cr.reset_debug_data
|
|
57
|
-
cj.reset_debug_data
|
|
58
|
-
end
|
data/bin/maps_debug_ordering
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
ENV["INTERSCRIPT_STAGING"] = "1"
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "interscript"
|
|
5
|
-
require "interscript/compiler/ruby"
|
|
6
|
-
|
|
7
|
-
$map_name = ARGV[0]
|
|
8
|
-
|
|
9
|
-
if $map_name
|
|
10
|
-
filelist = [ __dir__+"/../../maps/maps-staging/#{$map_name}.imp" ]
|
|
11
|
-
else
|
|
12
|
-
filelist = Dir[__dir__+"/../../maps/maps-staging/*.imp"].sort
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# levenshtein distance algorithm for comparing string similarity
|
|
17
|
-
def ld(s, t)
|
|
18
|
-
v0 = (0..t.length).to_a
|
|
19
|
-
v1 = []
|
|
20
|
-
#p v0
|
|
21
|
-
|
|
22
|
-
s.chars.each_with_index do |s_ch, i|
|
|
23
|
-
v1[0] = i + 1
|
|
24
|
-
|
|
25
|
-
t.chars.each_with_index do |t_ch, j|
|
|
26
|
-
cost = s_ch == t_ch ? 0 : 1
|
|
27
|
-
v1[j + 1] = [v1[j] + 1, v0[j + 1] + 1, v0[j] + cost].min
|
|
28
|
-
end
|
|
29
|
-
v0 = v1.dup
|
|
30
|
-
#p v1
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
v0[t.length]
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def score_reordering( system, source, target )
|
|
38
|
-
interpreter = Marshal.load( Marshal.dump( $interpreter ))
|
|
39
|
-
parallel = interpreter.map.stages[:main].children.select{|x| Interscript::Node::Group::Parallel === x}[0]
|
|
40
|
-
parallel.reorder_children(source,target)
|
|
41
|
-
interpreter.map.stages[:main].children[$parallel_idx].children = parallel.children.compact #.reorder_children(source,target)
|
|
42
|
-
delta_sum = 0
|
|
43
|
-
system.tests.data.each do |from, expected|
|
|
44
|
-
result = interpreter.(from)
|
|
45
|
-
delta = ld(expected, result)
|
|
46
|
-
delta_sum += delta
|
|
47
|
-
end;
|
|
48
|
-
delta_sum
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
for i in filelist
|
|
53
|
-
|
|
54
|
-
begin
|
|
55
|
-
system_name = File.basename(i, ".imp")
|
|
56
|
-
puts "\ndebugging #{system_name}"
|
|
57
|
-
|
|
58
|
-
system = Interscript.parse(system_name);
|
|
59
|
-
if system.tests && system.tests.data && system.tests.data.length > 0
|
|
60
|
-
|
|
61
|
-
$interpreter = Interscript::Interpreter.new.compile(system);
|
|
62
|
-
$orig_parallel = $interpreter.map.stages[:main].children.select{|x| Interscript::Node::Group::Parallel === x}[0].dup;
|
|
63
|
-
$parallel_idx = $interpreter.map.stages[:main].children.each_with_index.select{|x,i| Interscript::Node::Group::Parallel === x}.map{|x,i| i}[0]
|
|
64
|
-
next if !$parallel_idx
|
|
65
|
-
starting_score = score_reordering(system, 0,0)
|
|
66
|
-
parallel_size = $interpreter.map.stages[:main].children.select{|x| Interscript::Node::Group::Parallel === x}[0].children.size
|
|
67
|
-
|
|
68
|
-
puts "starting_score = #{starting_score}"
|
|
69
|
-
source = parallel_size
|
|
70
|
-
while true
|
|
71
|
-
break if source ==0
|
|
72
|
-
target = 0
|
|
73
|
-
curr_score = score_reordering(system, source, target)
|
|
74
|
-
print "#{source} <-> #{target} = #{curr_score}; "
|
|
75
|
-
|
|
76
|
-
if curr_score < starting_score
|
|
77
|
-
puts ''
|
|
78
|
-
puts "#{source} <-> #{target} changes score from #{starting_score} to #{curr_score}"
|
|
79
|
-
pp system.stages[:main].children[$parallel_idx].children[source]
|
|
80
|
-
end
|
|
81
|
-
source = source - 1
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
rescue Exception => e
|
|
85
|
-
puts e
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
end
|
data/bin/maps_debug_ruby_compile
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
ENV["INTERSCRIPT_STAGING"] = "1"
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "interscript"
|
|
5
|
-
require "interscript/compiler/ruby"
|
|
6
|
-
|
|
7
|
-
# Compile a given map with the Ruby compiler for debugging purposes
|
|
8
|
-
|
|
9
|
-
if ARGV[0] == '-b'
|
|
10
|
-
require 'base64'
|
|
11
|
-
$b64 = true
|
|
12
|
-
ARGV.shift
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
map = ARGV[0]
|
|
16
|
-
m = Interscript.parse(map)
|
|
17
|
-
cr = Interscript::Compiler::Ruby
|
|
18
|
-
mr = cr.(map)
|
|
19
|
-
|
|
20
|
-
if $b64
|
|
21
|
-
puts Base64.encode64(mr.code)
|
|
22
|
-
else
|
|
23
|
-
puts mr.code
|
|
24
|
-
end
|