interscript 0.1.7 → 2.1.0b1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/Gemfile +29 -0
- data/LICENSE.adoc +31 -0
- data/README.md +3 -0
- data/Rakefile +116 -0
- data/bin/console +14 -0
- data/bin/interscript +5 -0
- data/bin/maps_analyze_staging +168 -0
- data/bin/maps_debug_compilers +58 -0
- data/bin/maps_debug_ordering +88 -0
- data/bin/maps_debug_ruby_compile +24 -0
- data/bin/maps_debug_step_by_step +44 -0
- data/bin/maps_optimize_order +112 -0
- data/bin/maps_v1_analyze_regexps +45 -0
- data/bin/maps_v1_to_v2 +426 -0
- data/bin/setup +8 -0
- data/exe/interscript +6 -0
- data/interscript.gemspec +31 -0
- data/lib/interscript.rb +83 -133
- data/lib/interscript/command.rb +5 -5
- data/lib/interscript/compiler.rb +22 -0
- data/lib/interscript/compiler/javascript.rb +292 -0
- data/lib/interscript/compiler/ruby.rb +262 -0
- data/lib/interscript/dsl.rb +68 -0
- data/lib/interscript/dsl/aliases.rb +23 -0
- data/lib/interscript/dsl/document.rb +46 -0
- data/lib/interscript/dsl/group.rb +45 -0
- data/lib/interscript/dsl/group/parallel.rb +6 -0
- data/lib/interscript/dsl/items.rb +89 -0
- data/lib/interscript/dsl/metadata.rb +68 -0
- data/lib/interscript/dsl/stage.rb +6 -0
- data/lib/interscript/dsl/symbol_mm.rb +11 -0
- data/lib/interscript/dsl/tests.rb +12 -0
- data/lib/interscript/interpreter.rb +251 -0
- data/lib/interscript/node.rb +25 -0
- data/lib/interscript/node/alias_def.rb +15 -0
- data/lib/interscript/node/dependency.rb +13 -0
- data/lib/interscript/node/document.rb +45 -0
- data/lib/interscript/node/group.rb +34 -0
- data/lib/interscript/node/group/parallel.rb +9 -0
- data/lib/interscript/node/group/sequential.rb +2 -0
- data/lib/interscript/node/item.rb +52 -0
- data/lib/interscript/node/item/alias.rb +42 -0
- data/lib/interscript/node/item/any.rb +76 -0
- data/lib/interscript/node/item/capture.rb +50 -0
- data/lib/interscript/node/item/group.rb +51 -0
- data/lib/interscript/node/item/repeat.rb +40 -0
- data/lib/interscript/node/item/stage.rb +23 -0
- data/lib/interscript/node/item/string.rb +51 -0
- data/lib/interscript/node/metadata.rb +18 -0
- data/lib/interscript/node/rule.rb +6 -0
- data/lib/interscript/node/rule/funcall.rb +18 -0
- data/lib/interscript/node/rule/run.rb +15 -0
- data/lib/interscript/node/rule/sub.rb +68 -0
- data/lib/interscript/node/stage.rb +19 -0
- data/lib/interscript/node/tests.rb +15 -0
- data/lib/interscript/stdlib.rb +211 -0
- data/lib/interscript/utils/regexp_converter.rb +283 -0
- data/lib/interscript/version.rb +1 -1
- data/lib/interscript/visualize.rb +61 -0
- data/lib/interscript/visualize/group.html.erb +59 -0
- data/lib/interscript/visualize/json.rb +57 -0
- data/lib/interscript/visualize/map.html.erb +46 -0
- data/lib/interscript/visualize/nodes.rb +89 -0
- data/requirements.txt +1 -0
- metadata +78 -416
- data/README.adoc +0 -298
- data/lib/g2pwrapper.py +0 -34
- data/lib/interscript/fs.rb +0 -69
- data/lib/interscript/mapping.rb +0 -142
- data/lib/interscript/opal.rb +0 -57
- data/lib/interscript/opal/entrypoint.rb +0 -12
- data/lib/interscript/opal/map_translate.rb +0 -7
- data/lib/interscript/opal/maps.js.erb +0 -10
- data/lib/model-7 +0 -0
- data/lib/tha-pt-b-7 +0 -0
- data/maps/acadsin-zho-Hani-Latn-2002.yaml +0 -38916
- data/maps/alalc-amh-Ethi-Latn-1997.yaml +0 -513
- data/maps/alalc-amh-Ethi-Latn-2011.yaml +0 -138
- data/maps/alalc-ara-Arab-Latn-1997.yaml +0 -1287
- data/maps/alalc-asm-Deva-Latn-1997.yaml +0 -165
- data/maps/alalc-asm-Deva-Latn-2012.yaml +0 -40
- data/maps/alalc-aze-Cyrl-Latn-1997.yaml +0 -145
- data/maps/alalc-bel-Cyrl-Latn-1997.yaml +0 -129
- data/maps/alalc-ben-Beng-Latn-2017.yaml +0 -130
- data/maps/alalc-bul-Cyrl-Latn-1997.yaml +0 -98
- data/maps/alalc-ell-Grek-Latn-1997.yaml +0 -628
- data/maps/alalc-ell-Grek-Latn-2010.yaml +0 -626
- data/maps/alalc-guj-Gujr-Latn-1997.yaml +0 -266
- data/maps/alalc-guj-Gujr-Latn-2011.yaml +0 -64
- data/maps/alalc-hin-Deva-Latn-1997.yaml +0 -211
- data/maps/alalc-hin-Deva-Latn-2011.yaml +0 -47
- data/maps/alalc-kat-Geok-Latn-1997.yaml +0 -111
- data/maps/alalc-kat-Geor-Latn-1997.yaml +0 -150
- data/maps/alalc-kor-Hang-Latn-1997.yaml +0 -98
- data/maps/alalc-mal-Mlym-Latn-1997.yaml +0 -303
- data/maps/alalc-mal-Mlym-Latn-2012.yaml +0 -73
- data/maps/alalc-mar-Deva-Latn-1997.yaml +0 -189
- data/maps/alalc-mar-Deva-Latn-2011.yaml +0 -45
- data/maps/alalc-mkd-Cyrl-Latn-1997.yaml +0 -114
- data/maps/alalc-mkd-Cyrl-Latn-2013.yaml +0 -103
- data/maps/alalc-mon-Cyrl-Latn-1997.yaml +0 -220
- data/maps/alalc-pan-Guru-Latn-1997.yaml +0 -256
- data/maps/alalc-pan-Guru-Latn-2011.yaml +0 -78
- data/maps/alalc-per-Arab-Latn-1997.yaml +0 -375
- data/maps/alalc-pli-Deva-Latn-2012.yaml +0 -144
- data/maps/alalc-pra-Deva-Latn-2012.yaml +0 -47
- data/maps/alalc-rus-Cyrl-Latn-1997.yaml +0 -225
- data/maps/alalc-rus-Cyrl-Latn-2012.yaml +0 -162
- data/maps/alalc-san-Deva-Latn-2012.yaml +0 -172
- data/maps/alalc-sin-Sinh-Latn-1997.yaml +0 -292
- data/maps/alalc-sin-Sinh-Latn-2011.yaml +0 -71
- data/maps/alalc-srp-Cyrl-Latn-1997.yaml +0 -118
- data/maps/alalc-srp-Cyrl-Latn-2013.yaml +0 -135
- data/maps/alalc-tam-Taml-Latn-1997.yaml +0 -62
- data/maps/alalc-tam-Taml-Latn-2011.yaml +0 -58
- data/maps/alalc-ukr-Cyrl-Latn-1997.yaml +0 -145
- data/maps/alalc-ukr-Cyrl-Latn-2011.yaml +0 -16
- data/maps/apcbg-bul-Cyrl-Latn-1995.yaml +0 -283
- data/maps/bas-rus-Cyrl-Latn-2017-bss.yaml +0 -174
- data/maps/bas-rus-Cyrl-Latn-2017-oss.yaml +0 -169
- data/maps/bgn-jpn-Hrkt-Latn-1962.yaml +0 -292
- data/maps/bgn-kor-Hang-Latn-1943.yaml +0 -35
- data/maps/bgn-kor-Kore-Latn-1943.yaml +0 -31
- data/maps/bgna-bul-Cyrl-Latn-2006.yaml +0 -208
- data/maps/bgna-bul-Cyrl-Latn-2009.yaml +0 -208
- data/maps/bgnpcgn-amh-Ethi-Latn-1967.yaml +0 -532
- data/maps/bgnpcgn-ara-Arab-Latn-1956.yaml +0 -596
- data/maps/bgnpcgn-arm-Armn-Latn-1981.yaml +0 -108
- data/maps/bgnpcgn-aze-Cyrl-Latn-1993.yaml +0 -104
- data/maps/bgnpcgn-bak-Cyrl-Latn-2007.yaml +0 -188
- data/maps/bgnpcgn-bel-Cyrl-Latn-1979.yaml +0 -289
- data/maps/bgnpcgn-bul-Cyrl-Latn-1952.yaml +0 -119
- data/maps/bgnpcgn-bul-Cyrl-Latn-2013.yaml +0 -42
- data/maps/bgnpcgn-che-Cyrl-Latn-2008.yaml +0 -184
- data/maps/bgnpcgn-ell-Grek-Latn-1962.yaml +0 -705
- data/maps/bgnpcgn-ell-Grek-Latn-1996.yaml +0 -23
- data/maps/bgnpcgn-fas-Arab-Latn-1956.yaml +0 -96
- data/maps/bgnpcgn-jpn-Hrkt-Latn-1976.yaml +0 -257
- data/maps/bgnpcgn-kat-Geor-Latn-1981.yaml +0 -131
- data/maps/bgnpcgn-kat-Geor-Latn-2009.yaml +0 -42
- data/maps/bgnpcgn-kor-Hang-Latn-kn-1945.yaml +0 -253
- data/maps/bgnpcgn-kor-Hang-Latn-rok-2011.yaml +0 -48
- data/maps/bgnpcgn-kor-Kore-Latn-rok-2011.yaml +0 -48
- data/maps/bgnpcgn-mkd-Cyrl-Latn-1981.yaml +0 -163
- data/maps/bgnpcgn-mkd-Cyrl-Latn-2013.yaml +0 -190
- data/maps/bgnpcgn-mon-Cyrl-Latn-1964.yaml +0 -223
- data/maps/bgnpcgn-nep-Deva-Latn-2011.yaml +0 -230
- data/maps/bgnpcgn-per-Arab-Latn-1958.yaml +0 -336
- data/maps/bgnpcgn-prs-Arab-Latn-2007.yaml +0 -639
- data/maps/bgnpcgn-prs-Arab-Latn-yaghoubi.yaml +0 -459
- data/maps/bgnpcgn-rue-Cyrl-Latn-2016.yaml +0 -168
- data/maps/bgnpcgn-rus-Cyrl-Latn-1947.yaml +0 -318
- data/maps/bgnpcgn-srp-Cyrl-Latn-2005.yaml +0 -170
- data/maps/bgnpcgn-tat-Cyrl-Latn-2007.yaml +0 -220
- data/maps/bgnpcgn-tgk-Cyrl-Latn-1994.yaml +0 -240
- data/maps/bgnpcgn-ukr-Cyrl-Latn-1965.yaml +0 -166
- data/maps/bgnpcgn-ukr-Cyrl-Latn-2019.yaml +0 -119
- data/maps/bgnpcgn-uzb-Cyrl-Latn-1979.yaml +0 -127
- data/maps/bgnpcgn-uzb-Cyrl-Latn-2000.yaml +0 -82
- data/maps/bgnpcgn-zho-Hans-Latn-1979.yaml +0 -7456
- data/maps/bis-asm-Beng-Latn-13194-1991.yaml +0 -159
- data/maps/bis-ben-Beng-Latn-13194-1991.yaml +0 -156
- data/maps/bis-dev-Deva-Latn-13194-1991.yaml +0 -184
- data/maps/bis-guj-Gujr-Latn-13194-1991.yaml +0 -181
- data/maps/bis-knd-Knda-Latn-13194-1991.yaml +0 -173
- data/maps/bis-mlm-Mlym-Latn-13194-1991.yaml +0 -176
- data/maps/bis-ori-Orya-Latn-13194-1991.yaml +0 -160
- data/maps/bis-pnj-Guru-Latn-13194-1991.yaml +0 -175
- data/maps/bis-tel-Telu-Latn-13194-1991.yaml +0 -170
- data/maps/bis-tml-Taml-Latn-13194-1991.yaml +0 -155
- data/maps/by-bel-Cyrl-Latn-1998.yaml +0 -172
- data/maps/by-bel-Cyrl-Latn-2007.yaml +0 -115
- data/maps/din-grc-Grek-Latn-31634-2011-t1.yaml +0 -899
- data/maps/din-hin-Deva-Latn-33904-2018.yaml +0 -100
- data/maps/din-kat-Geor-Latn-32707-2010.yaml +0 -145
- data/maps/din-mar-Deva-Latn-33904-2018.yaml +0 -84
- data/maps/din-nep-Deva-Latn-33904-2018.yaml +0 -119
- data/maps/din-pli-Deva-Latn-33904-2018.yaml +0 -75
- data/maps/din-pra-Deva-Latn-33904-2018.yaml +0 -63
- data/maps/din-san-Deva-Latn-33904-2018.yaml +0 -338
- data/maps/din-tam-Taml-Latn-33903-2016.yaml +0 -213
- data/maps/dos-nep-Deva-Latn-1997.yaml +0 -47
- data/maps/elot-ell-Grek-Latn-743-1982-tl.yaml +0 -684
- data/maps/elot-ell-Grek-Latn-743-1982-ts.yaml +0 -680
- data/maps/elot-ell-Grek-Latn-743-2001-tl.yaml +0 -19
- data/maps/elot-ell-Grek-Latn-743-2001-ts.yaml +0 -31
- data/maps/ggg-kat-Geor-Latn-2002.yaml +0 -92
- data/maps/gki-bel-Cyrl-Latn-1992.yaml +0 -33
- data/maps/gki-bel-Cyrl-Latn-2000.yaml +0 -201
- data/maps/gost-rus-Cyrl-Latn-16876-71-1983.yaml +0 -190
- data/maps/gost-rus-Cyrl-Latn-7.79-2000-2002.yaml +0 -157
- data/maps/hk-yue-Hani-Latn-1888.yaml +0 -38497
- data/maps/icao-bel-Cyrl-Latn-9303.yaml +0 -136
- data/maps/icao-bul-Cyrl-Latn-9303.yaml +0 -118
- data/maps/icao-fas-Arab-Latn-9303.yaml +0 -103
- data/maps/icao-heb-Hebr-Latn-9303.yaml +0 -151
- data/maps/icao-mkd-Cyrl-Latn-9303.yaml +0 -117
- data/maps/icao-rus-Cyrl-Latn-9303.yaml +0 -117
- data/maps/icao-srp-Cyrl-Latn-9303.yaml +0 -117
- data/maps/icao-ukr-Cyrl-Latn-9303.yaml +0 -119
- data/maps/iso-ara-Arab-Latn-233-1984.yaml +0 -323
- data/maps/iso-asm-Beng-Latn-15919-2001.yaml +0 -75
- data/maps/iso-ben-Beng-Latn-15919-2001.yaml +0 -175
- data/maps/iso-ell-Grek-Latn-843-1997-t1.yaml +0 -613
- data/maps/iso-ell-Grek-Latn-843-1997-t2.yaml +0 -44
- data/maps/iso-guj-Gujr-Latn-15919-2001.yaml +0 -220
- data/maps/iso-hin-Deva-Latn-15919-2001.yaml +0 -87
- data/maps/iso-inc-Deva-Latn-15919-2001.yaml +0 -61
- data/maps/iso-jpn-Hrkt-Latn-3602-1989.yaml +0 -66
- data/maps/iso-kan-Knda-Latn-15919-2001.yaml +0 -220
- data/maps/iso-kat-Geor-Latn-9984-1996.yaml +0 -145
- data/maps/iso-kor-Hang-Latn-1996-method1.yaml +0 -240
- data/maps/iso-kor-Hang-Latn-1996-method2.yaml +0 -226
- data/maps/iso-mal-Mlym-Latn-15919-2001.yaml +0 -281
- data/maps/iso-mar-Deva-Latn-15919-2001.yaml +0 -75
- data/maps/iso-nep-Deva-Latn-15919-2001.yaml +0 -87
- data/maps/iso-ori-Orya-Latn-15919-2001.yaml +0 -193
- data/maps/iso-pan-Guru-Latn-15919-2001.yaml +0 -222
- data/maps/iso-pli-Beng-Latn-15919-2001.yaml +0 -73
- data/maps/iso-pli-Deva-Latn-15919-2001.yaml +0 -74
- data/maps/iso-pli-Sinh-Latn-15919-2001.yaml +0 -219
- data/maps/iso-pli-Thai-Latn-15919-2001.yaml +0 -55
- data/maps/iso-pra-Deva-Latn-15919-2001.yaml +0 -59
- data/maps/iso-prs-Arab-Latn-233-3-1999.yaml +0 -366
- data/maps/iso-rus-Cyrl-Latn-9-1995.yaml +0 -271
- data/maps/iso-san-Deva-Latn-15919-2001.yaml +0 -220
- data/maps/iso-tam-Taml-Latn-15919-2001.yaml +0 -159
- data/maps/iso-tel-Telu-Latn-15919-2001.yaml +0 -220
- data/maps/iso-tha-Thai-Latn-11940-1998.yaml +0 -109
- data/maps/kp-kor-Hang-Latn-2002.yaml +0 -909
- data/maps/lshk-yue-Hani-Latn-jyutping-1993.yaml +0 -44820
- data/maps/mext-jpn-Hrkt-Latn-1954.yaml +0 -411
- data/maps/mns-mon-Cyrl-Latn-5217-2012.yaml +0 -163
- data/maps/mns-mon-Latn-Cyrl-5217-2012.yaml +0 -200
- data/maps/moct-kor-Hang-Latn-2000.yaml +0 -807
- data/maps/mofa-jpn-Hrkt-Latn-1989.yaml +0 -541
- data/maps/mvd-bel-Cyrl-Latn-2008.yaml +0 -225
- data/maps/mvd-bel-Cyrl-Latn-2010.yaml +0 -63
- data/maps/mvd-rus-Cyrl-Latn-2008.yaml +0 -109
- data/maps/mvd-rus-Cyrl-Latn-2010.yaml +0 -37
- data/maps/odni-ara-Arab-Latn-2015.yaml +0 -425
- data/maps/odni-aze-Cyrl-Latn-2015.yaml +0 -144
- data/maps/odni-bel-Cyrl-Latn-2015.yaml +0 -148
- data/maps/odni-bul-Cyrl-Latn-2015.yaml +0 -96
- data/maps/odni-che-Cyrl-Latn-2015.yaml +0 -169
- data/maps/odni-fas-Arab-Latn-2015.yaml +0 -406
- data/maps/odni-hin-Deva-Latn-2015.yaml +0 -258
- data/maps/odni-kat-Geor-Latn-2015.yaml +0 -87
- data/maps/odni-kaz-Cyrl-Latn-2015.yaml +0 -148
- data/maps/odni-kir-Cyrl-Latn-2015.yaml +0 -136
- data/maps/odni-kor-Hang-Latn-2015.yaml +0 -375
- data/maps/odni-mkd-Cyrl-Latn-2015.yaml +0 -122
- data/maps/odni-per-Arab-Latn-2015.yaml +0 -228
- data/maps/odni-rus-Cyrl-Latn-2015.yaml +0 -77
- data/maps/odni-srp-Cyrl-Latn-2015.yaml +0 -129
- data/maps/odni-tat-Cyrl-Latn-2015.yaml +0 -142
- data/maps/odni-tgk-Cyrl-Latn-2015.yaml +0 -148
- data/maps/odni-uig-Cyrl-Latn-2015.yaml +0 -138
- data/maps/odni-ukr-Cyrl-Latn-2015.yaml +0 -157
- data/maps/odni-urd-Arab-Latn-2015.yaml +0 -221
- data/maps/odni-uzb-Cyrl-Latn-2015.yaml +0 -166
- data/maps/royin-tha-Thai-Latn-1939-generic.yaml +0 -90
- data/maps/royin-tha-Thai-Latn-1968.yaml +0 -183
- data/maps/royin-tha-Thai-Latn-1999-chained.yaml +0 -180
- data/maps/royin-tha-Thai-Latn-1999.yaml +0 -80
- data/maps/sac-zho-Hans-Latn-1979.yaml +0 -24763
- data/maps/sasm-mon-Mong-Latn-general-1978.yaml +0 -389
- data/maps/sasm-mon-Mong-Latn-phonetic-1978.yaml +0 -354
- data/maps/ses-ara-Arab-Latn-1930.yaml +0 -283
- data/maps/stategeocadastre-ukr-Cyrl-Latn-1993.yaml +0 -222
- data/maps/ua-ukr-Cyrl-Latn-1996.yaml +0 -197
- data/maps/ua-ukr-Cyrl-Latn-2007.yaml +0 -75
- data/maps/ua-ukr-Cyrl-Latn-2010.yaml +0 -192
- data/maps/un-amh-Ethi-Latn-2016.yaml +0 -602
- data/maps/un-ara-Arab-Latn-1971.yaml +0 -139
- data/maps/un-ara-Arab-Latn-1972.yaml +0 -159
- data/maps/un-ara-Arab-Latn-2017.yaml +0 -420
- data/maps/un-bel-Cyrl-Latn-2007.yaml +0 -114
- data/maps/un-ben-Beng-Latn-2016.yaml +0 -534
- data/maps/un-ell-Grek-Latn-1987-phonetic.yaml +0 -780
- data/maps/un-ell-Grek-Latn-1987-tl.yaml +0 -31
- data/maps/un-ell-Grek-Latn-1987-ts.yaml +0 -19
- data/maps/un-hin-Deva-Latn-2016.yaml +0 -222
- data/maps/un-mar-Deva-Latn-2016.yaml +0 -91
- data/maps/un-mon-Mong-Latn-general-2013.yaml +0 -264
- data/maps/un-mon-Mong-Latn-phonetic-2013.yaml +0 -264
- data/maps/un-nep-Deva-Latn-1972.yaml +0 -350
- data/maps/un-nep-Deva-Latn-2013.yaml +0 -74
- data/maps/un-rus-Cyrl-Latn-1987.yaml +0 -166
- data/maps/un-ukr-Cyrl-Latn-1998.yaml +0 -53
- data/maps/un-ukr-Cyrl-Latn-2012.yaml +0 -162
- data/maps/var-hin-Deva-Latn-hunterian-1872.yaml +0 -221
- data/maps/var-jpn-Hrkt-Latn-hepburn-1886.yaml +0 -406
- data/maps/var-jpn-Hrkt-Latn-hepburn-1954.yaml +0 -386
- data/maps/var-kor-Hang-Hang-jamo.yaml +0 -11193
- data/maps/var-kor-Hang-Latn-mr-1939.yaml +0 -1054
- data/maps/var-kor-Kore-Hang-2013.yaml +0 -59754
- data/maps/var-kor-Kore-Latn-mr-1939.yaml +0 -36
- data/maps/var-mar-Deva-Latn-hunterian-1872.yaml +0 -43
- data/maps/var-mon-Mong-Latn-1930.yaml +0 -102
- data/maps/var-mon-Mong-Latn-lessing.yaml +0 -272
- data/maps/var-mon-Mong-Latn-vpmc.yaml +0 -274
- data/maps/var-pra-Deva-Latn-iast-1912.yaml +0 -30
- data/maps/var-san-Deva-Latn-iast-1912.yaml +0 -149
- data/maps/var-tha-Thai-Thai-phonemic.yaml +0 -59
- data/maps/var-tha-Thai-Zsym-ipa.yaml +0 -301
- data/maps/var-zho-Hani-Latn-wd-1979.yaml +0 -38912
- data/spec/interscript/filenames_spec.rb +0 -384
- data/spec/interscript/mapping_spec.rb +0 -42
- data/spec/interscript_spec.rb +0 -29
- data/spec/spec_helper.rb +0 -3
@@ -0,0 +1,23 @@
|
|
1
|
+
class Interscript::Node::Item::Stage < Interscript::Node::Item
|
2
|
+
attr_accessor :name
|
3
|
+
attr_accessor :map
|
4
|
+
def initialize(name, map: nil)
|
5
|
+
self.name = name
|
6
|
+
self.map = map
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_hash
|
10
|
+
{ :class => self.class.to_s,
|
11
|
+
:name => name,
|
12
|
+
:map => map,
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def inspect
|
17
|
+
if map
|
18
|
+
"map.#{@map}.stage.#{@name}"
|
19
|
+
else
|
20
|
+
"stage.#{@name}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class Interscript::Node::Item::String < Interscript::Node::Item
|
2
|
+
attr_accessor :data
|
3
|
+
def initialize data
|
4
|
+
self.data = data
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_hash
|
8
|
+
{ :class => self.class.to_s,
|
9
|
+
:data => self.data }
|
10
|
+
end
|
11
|
+
|
12
|
+
def max_length
|
13
|
+
self.data.length
|
14
|
+
end
|
15
|
+
|
16
|
+
def first_string
|
17
|
+
self.data
|
18
|
+
end
|
19
|
+
|
20
|
+
alias nth_string first_string
|
21
|
+
|
22
|
+
def + other
|
23
|
+
if self.data == ""
|
24
|
+
Interscript::Node::Item.try_convert(other)
|
25
|
+
elsif Interscript::Node::Item::String === self &&
|
26
|
+
(Interscript::Node::Item::String === other || ::String === other)
|
27
|
+
|
28
|
+
other = Interscript::Node::Item.try_convert(other)
|
29
|
+
|
30
|
+
Interscript::Node::Item::String.new(self.data + other.data)
|
31
|
+
else
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def inspect
|
37
|
+
@data.inspect
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# stdext
|
42
|
+
class String
|
43
|
+
alias plus_before_interscript +
|
44
|
+
def + other
|
45
|
+
if Interscript::Node === other
|
46
|
+
Interscript::Node::Item.try_convert(self) + other
|
47
|
+
else
|
48
|
+
self.plus_before_interscript(other)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Interscript::Node::MetaData < Interscript::Node
|
2
|
+
attr_accessor :data
|
3
|
+
def initialize data={}
|
4
|
+
@data = data
|
5
|
+
end
|
6
|
+
|
7
|
+
def []=(k,v)
|
8
|
+
@data[k] = v
|
9
|
+
end
|
10
|
+
def [](k)
|
11
|
+
@data[k]
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_hash
|
15
|
+
{:class => self.class.to_s,
|
16
|
+
:data => @data}
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Interscript::Node::Rule::Funcall < Interscript::Node::Rule
|
2
|
+
attr_accessor :name, :kwargs
|
3
|
+
def initialize name, **kwargs
|
4
|
+
@name = name
|
5
|
+
@kwargs = kwargs
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_hash
|
9
|
+
{ :class => self.class.to_s,
|
10
|
+
:name => self.name,
|
11
|
+
:kwargs => self.kwargs
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def inspect
|
16
|
+
"#{@name} #{kwargs.inspect[1..-2]}"
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Interscript::Node::Rule::Run < Interscript::Node::Rule
|
2
|
+
attr_accessor :stage
|
3
|
+
def initialize stage
|
4
|
+
@stage = stage
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_hash
|
8
|
+
{ :class => self.class.to_s,
|
9
|
+
:stage => self.stage.to_hash }
|
10
|
+
end
|
11
|
+
|
12
|
+
def inspect
|
13
|
+
"run #{@stage.inspect}"
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class Interscript::Node::Rule::Sub < Interscript::Node::Rule
|
2
|
+
attr_accessor :from, :to
|
3
|
+
attr_accessor :before, :not_before, :after, :not_after
|
4
|
+
attr_accessor :priority
|
5
|
+
|
6
|
+
def initialize from, to, before: nil, not_before: nil, after: nil, not_after: nil, priority: nil
|
7
|
+
self.from = Interscript::Node::Item.try_convert from
|
8
|
+
if to == :upcase
|
9
|
+
self.to = :upcase
|
10
|
+
else
|
11
|
+
self.to = Interscript::Node::Item.try_convert to
|
12
|
+
end
|
13
|
+
|
14
|
+
self.priority = priority
|
15
|
+
|
16
|
+
#raise TypeError, "Can't supply both before and not_before" if before && not_before
|
17
|
+
#raise TypeError, "Can't supply both after and not_after" if after && not_after
|
18
|
+
|
19
|
+
self.before = Interscript::Node::Item.try_convert(before) if before
|
20
|
+
self.after = Interscript::Node::Item.try_convert(after) if after
|
21
|
+
self.not_before = Interscript::Node::Item.try_convert(not_before) if not_before
|
22
|
+
self.not_after = Interscript::Node::Item.try_convert(not_after) if not_after
|
23
|
+
end
|
24
|
+
|
25
|
+
def max_length
|
26
|
+
len = self.from.max_length
|
27
|
+
len += self.before.max_length if self.before
|
28
|
+
len += self.after.max_length if self.after
|
29
|
+
len += self.not_before.max_length if self.not_before
|
30
|
+
len += self.not_after.max_length if self.not_after
|
31
|
+
len += self.priority if self.priority
|
32
|
+
len
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_hash
|
36
|
+
puts self.from.inspect if $DEBUG
|
37
|
+
puts params.inspect if $DEBUG
|
38
|
+
hash = { :class => self.class.to_s,
|
39
|
+
:from => self.from.to_hash,
|
40
|
+
:to => Symbol === self.to ? self.to : self.to.to_hash
|
41
|
+
}
|
42
|
+
|
43
|
+
hash[:before] = self.before&.to_hash if self.before
|
44
|
+
hash[:not_before] = self.not_before&.to_hash if self.not_before
|
45
|
+
hash[:after] = self.after&.to_hash if self.after
|
46
|
+
hash[:not_after] = self.not_after&.to_hash if self.not_after
|
47
|
+
hash[:priority] = self.priority if self.priority
|
48
|
+
|
49
|
+
hash
|
50
|
+
end
|
51
|
+
|
52
|
+
def inspect
|
53
|
+
out = "sub "
|
54
|
+
params = []
|
55
|
+
params << @from.inspect
|
56
|
+
if @to == :upcase
|
57
|
+
params << "upcase"
|
58
|
+
else
|
59
|
+
params << @to.inspect
|
60
|
+
end
|
61
|
+
params << "before: #{@before.inspect}" if @before
|
62
|
+
params << "after: #{@after.inspect}" if @after
|
63
|
+
params << "not_before: #{@not_before.inspect}" if @not_before
|
64
|
+
params << "not_after: #{@not_after.inspect}" if @not_after
|
65
|
+
params << "priority: #{@priority.inspect}" if @priority
|
66
|
+
out << params.join(", ")
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Interscript::Node::Stage < Interscript::Node::Group::Sequential
|
2
|
+
attr_accessor :name, :doc_name
|
3
|
+
|
4
|
+
def initialize name = :main
|
5
|
+
@name = name
|
6
|
+
super()
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_hash
|
10
|
+
{ :class => self.class.to_s,
|
11
|
+
:name => name,
|
12
|
+
:children => @children.map{|x| x.to_hash} }
|
13
|
+
end
|
14
|
+
|
15
|
+
def inspect
|
16
|
+
name = "(#{@name})" if @name != :main
|
17
|
+
"stage#{name} {\n#{super}\n}"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
class Interscript::Stdlib
|
2
|
+
ALIASES = {
|
3
|
+
any_character: '.',
|
4
|
+
none: "",
|
5
|
+
space: " ",
|
6
|
+
whitespace: "[\\b \\t\\0\\r\\n]",
|
7
|
+
boundary: "\\b",
|
8
|
+
non_word_boundary: "\\B",
|
9
|
+
word: "\\w",
|
10
|
+
not_word: "\\W",
|
11
|
+
alpha: "[a-zA-Z]",
|
12
|
+
not_alpha: "[^a-zA-Z]",
|
13
|
+
digit: "\\d",
|
14
|
+
not_digit: "\\D",
|
15
|
+
line_start: "^",
|
16
|
+
line_end: "$",
|
17
|
+
string_start: "\\A",
|
18
|
+
string_end: "\\z"
|
19
|
+
}
|
20
|
+
|
21
|
+
def self.re_only_alias?(a)
|
22
|
+
! %i[none space].include?(a)
|
23
|
+
end
|
24
|
+
|
25
|
+
@treecache = {}
|
26
|
+
|
27
|
+
def self.parallel_regexp_compile(subs_hash)
|
28
|
+
# puts subs_hash.inspect
|
29
|
+
regexp = subs_hash.each_with_index.map do |p,i|
|
30
|
+
"(?<_%d>%s)" % [i,p[0]]
|
31
|
+
end.join("|")
|
32
|
+
subs_regexp = Regexp.compile(regexp)
|
33
|
+
# puts subs_regexp.inspect
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.parallel_regexp_gsub(string, subs_regexp, subs_hash)
|
37
|
+
string.gsub(subs_regexp) do |match|
|
38
|
+
lm = Regexp.last_match
|
39
|
+
# Extract the match name
|
40
|
+
idx = lm.named_captures.compact.keys.first[1..-1].to_i
|
41
|
+
subs_hash[idx]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.parallel_regexp_gsub_debug(string, subs_regexp, subs_array)
|
46
|
+
# only gathering debug info, test data is available in maps_analyze_staging
|
47
|
+
$subs_matches = []
|
48
|
+
$subs_regexp = subs_regexp
|
49
|
+
#$subs_array = subs_array
|
50
|
+
string.gsub(subs_regexp) do |match|
|
51
|
+
lm = Regexp.last_match
|
52
|
+
# puts lm.inspect
|
53
|
+
# Extract the match name
|
54
|
+
matched = lm.named_captures.compact.keys.first
|
55
|
+
# puts matched.inspect
|
56
|
+
# puts [lm.begin(matched), lm.end(matched)].inspect
|
57
|
+
idx = matched[1..-1].to_i
|
58
|
+
debug_info = {begin: lm.begin(matched), end: lm.end(matched), idx: idx, result: subs_array[idx]}
|
59
|
+
$subs_matches << debug_info
|
60
|
+
subs_array[idx]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def self.parallel_replace_compile_hash(a)
|
66
|
+
h = {}
|
67
|
+
a.each do |from,to|
|
68
|
+
h[from] = to
|
69
|
+
end
|
70
|
+
h
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.parallel_replace_hash(str,h)
|
74
|
+
newstr = ""
|
75
|
+
len = str.length
|
76
|
+
max_key_len = h.keys.map(&:length).max
|
77
|
+
i = 0
|
78
|
+
while i < len
|
79
|
+
max_key_len.downto(1).each do |checked_len|
|
80
|
+
substr = str[i,checked_len]
|
81
|
+
if h[substr]
|
82
|
+
newstr << h[substr]
|
83
|
+
i += substr.length
|
84
|
+
elsif checked_len==1
|
85
|
+
newstr << str[i,1]
|
86
|
+
i += 1
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
newstr
|
91
|
+
end
|
92
|
+
|
93
|
+
# hash can be either a hash or a hash-like array
|
94
|
+
def self.parallel_replace_compile_tree(hash)
|
95
|
+
hh = hash.hash
|
96
|
+
if @treecache[hh]
|
97
|
+
tree = @treecache[hh]
|
98
|
+
else
|
99
|
+
tree = {}
|
100
|
+
hash.each do |from, to|
|
101
|
+
from = Array(from)
|
102
|
+
from.each do |f|
|
103
|
+
branch = tree
|
104
|
+
chars = f.split("")
|
105
|
+
chars[0..-2].each do |c|
|
106
|
+
branch[c.ord] ||= {}
|
107
|
+
branch = branch[c.ord]
|
108
|
+
end
|
109
|
+
branch[chars.last.ord] ||= {}
|
110
|
+
branch[chars.last.ord][nil] = to
|
111
|
+
end
|
112
|
+
end
|
113
|
+
@treecache[hh] = tree
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.parallel_replace_tree(str, tree)
|
118
|
+
newstr = ""
|
119
|
+
len = str.length
|
120
|
+
i = 0
|
121
|
+
while i < len
|
122
|
+
c = str[i]
|
123
|
+
|
124
|
+
sub = ""
|
125
|
+
branch = tree
|
126
|
+
match, repl = nil, nil
|
127
|
+
|
128
|
+
j = 0
|
129
|
+
while j < len-i
|
130
|
+
cc = str[i+j]
|
131
|
+
if branch.include? cc.ord
|
132
|
+
branch = branch[cc.ord]
|
133
|
+
sub << cc
|
134
|
+
if branch.include? nil
|
135
|
+
match = sub.dup
|
136
|
+
repl = branch[nil]
|
137
|
+
end
|
138
|
+
j += 1
|
139
|
+
else
|
140
|
+
break
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
if match
|
145
|
+
i += match.length
|
146
|
+
newstr << repl
|
147
|
+
else
|
148
|
+
newstr << c
|
149
|
+
i += 1
|
150
|
+
end
|
151
|
+
end
|
152
|
+
newstr
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.parallel_replace(str, hash)
|
156
|
+
tree = parallel_replace_compile_tree(hash)
|
157
|
+
parallel_replace_tree(str, tree)
|
158
|
+
end
|
159
|
+
|
160
|
+
# On Windows at least, sort_by is non-deterministic. Let's add some determinism
|
161
|
+
# to our efforts.
|
162
|
+
def self.deterministic_sort_by_max_length(ary)
|
163
|
+
# Deterministic on Linux:
|
164
|
+
# ary.sort_by{ |rule| -rule.max_length }
|
165
|
+
|
166
|
+
ary.each_with_index.sort_by{ |rule,idx| -rule.max_length*100000 + idx }.map(&:first)
|
167
|
+
end
|
168
|
+
|
169
|
+
def self.available_functions
|
170
|
+
%i[title_case downcase compose decompose separate secryst]
|
171
|
+
end
|
172
|
+
|
173
|
+
module Functions
|
174
|
+
def self.title_case(output, word_separator: " ")
|
175
|
+
output = output.gsub(/^(.)/, &:upcase)
|
176
|
+
output = output.gsub(/#{word_separator}(.)/, &:upcase) unless word_separator == ''
|
177
|
+
output
|
178
|
+
end
|
179
|
+
|
180
|
+
def self.downcase(output, _:nil)
|
181
|
+
output.downcase
|
182
|
+
end
|
183
|
+
|
184
|
+
def self.compose(output, _:nil)
|
185
|
+
output.unicode_normalize(:nfc)
|
186
|
+
end
|
187
|
+
|
188
|
+
def self.decompose(output, _:nil)
|
189
|
+
output.unicode_normalize(:nfd)
|
190
|
+
end
|
191
|
+
|
192
|
+
def self.separate(output, separator: " ")
|
193
|
+
output.split("").join(separator)
|
194
|
+
end
|
195
|
+
|
196
|
+
@secryst_models = {}
|
197
|
+
def self.secryst(output, model:)
|
198
|
+
require "secryst" rescue nil # Try to load secryst, but don't fail hard if not possible.
|
199
|
+
unless defined? Secryst
|
200
|
+
raise StandardError, "Secryst is not loaded. Please read docs/Usage_with_Secryst.adoc"
|
201
|
+
end
|
202
|
+
Interscript.secryst_index_locations.each do |remote|
|
203
|
+
Secryst::Provisioning.add_remote(remote)
|
204
|
+
end
|
205
|
+
@secryst_models[model] ||= Secryst::Translator.new(model_file: model)
|
206
|
+
output.split("\n").map(&:chomp).map do |i|
|
207
|
+
@secryst_models[model].translate(i)
|
208
|
+
end.join("\n")
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|