expressir 2.4.47-arm-linux → 2.4.49-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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/docs/_guides/reference/grammar-crosswalk.adoc +1 -0
  3. data/expressir.gemspec +1 -1
  4. data/grammar-parg/CONVENTIONS.md +90 -0
  5. data/grammar-parg/RULE-INVENTORY.txt +252 -0
  6. data/grammar-parg/atoms_to_parg.rb +232 -0
  7. data/grammar-parg/bisect.sh +37 -0
  8. data/grammar-parg/ddmin.sh +39 -0
  9. data/grammar-parg/dsl-dump.json +1 -0
  10. data/grammar-parg/entries.parg.frag +12 -0
  11. data/grammar-parg/express-grammar.artifact.json +1 -0
  12. data/grammar-parg/express-grammar.parg +381 -0
  13. data/grammar-parg/express.json +1 -0
  14. data/grammar-parg/express.parg +57 -0
  15. data/grammar-parg/express_keywords.parg +132 -0
  16. data/grammar-parg/express_literals.parg +14 -0
  17. data/grammar-parg/express_operators.parg +34 -0
  18. data/grammar-parg/express_remarks.parg +19 -0
  19. data/grammar-parg/express_structure.parg +11 -0
  20. data/grammar-parg/generate-terminals.rb +55 -0
  21. data/grammar-parg/keywords.parg.frag +130 -0
  22. data/grammar-parg/literals.parg.frag +9 -0
  23. data/grammar-parg/operators.parg.frag +34 -0
  24. data/grammar-parg/parity-model.rb +68 -0
  25. data/grammar-parg/parity-vm.rb +60 -0
  26. data/grammar-parg/parity.sh +66 -0
  27. data/grammar-parg/parser-dsl-reference.rb.txt +757 -0
  28. data/grammar-parg/splice.rb +16 -0
  29. data/grammar-parg/tree_diff.rb +62 -0
  30. data/lib/expressir/express/grammar/express-grammar.artifact.json +1 -0
  31. data/lib/expressir/express/grammar/parser.rb +55 -1
  32. data/lib/expressir/express/parser.rb +3 -3
  33. data/lib/expressir/express/remark_attacher.rb +4 -2
  34. data/lib/expressir/model/model_element.rb +3 -0
  35. data/lib/expressir/reference/grammar_crosswalk.yml +3 -0
  36. data/lib/expressir/version.rb +1 -1
  37. metadata +31 -10
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ # STEP 3 gate (issue #578): the builder must produce identical models
4
+ # from the lane the artifact REPLACES (the DSL-wrapped fallback) and
5
+ # the artifact lane. Fixtures where the DSL lane itself fails count as
6
+ # out of scope: the runtime flip falls back to the DSL lane there, so
7
+ # behavior is identical either way.
8
+ #
9
+ # Usage: ruby parity-model.rb
10
+
11
+ require "bundler/setup"
12
+ require "expressir"
13
+ require "parsanol"
14
+ require "json"
15
+
16
+ artifact_path = File.join(__dir__, "express-grammar.artifact.json")
17
+ artifact = Parsanol::PARG::Artifact.from_json(File.read(artifact_path))
18
+
19
+ pass = 0
20
+ fail = 0
21
+ skipped = 0
22
+ failures = []
23
+
24
+ fixtures = Dir.glob(File.expand_path("../spec/**/*.exp", __dir__))
25
+
26
+ fixtures.each do |f|
27
+ src = File.read(f)
28
+
29
+ dsl_ast = nil
30
+ begin
31
+ dsl_ast = Expressir::Express::Grammar::Parser.cached_parser.parse(src)
32
+ dsl_model = Expressir::Express::Builder.build_with_remarks(dsl_ast, source: src, include_source: false)
33
+ rescue StandardError, NotImplementedError
34
+ dsl_ast = nil
35
+ end
36
+
37
+ begin
38
+ art_ast = artifact.parse("syntax", src, mode: :ruby)
39
+ art_model = Expressir::Express::Builder.build_with_remarks(art_ast, source: src, include_source: false)
40
+ rescue StandardError, NotImplementedError => e
41
+ if dsl_ast.nil?
42
+ skipped += 1
43
+ else
44
+ fail += 1
45
+ failures << [f, "artifact lane: #{e.class}: #{e.message[0, 120]}"]
46
+ end
47
+ next
48
+ end
49
+
50
+ if dsl_ast.nil?
51
+ skipped += 1
52
+ next
53
+ end
54
+
55
+ dsl_h = dsl_model.to_hash
56
+ art_h = art_model.to_hash
57
+ if dsl_h == art_h
58
+ pass += 1
59
+ else
60
+ fail += 1
61
+ diff = dsl_h.keys == art_h.keys ? "content" : "top keys #{dsl_h.keys.inspect} vs #{art_h.keys.inspect}"
62
+ failures << [f, "model diverge (#{diff})"]
63
+ end
64
+ end
65
+
66
+ puts "model parity: #{pass} agree, #{fail} diverge, #{skipped} out-of-scope (#{fixtures.size} fixtures)"
67
+ failures.first(15).each { |f, why| puts " MODEL GAP: #{File.basename(f)} — #{why}" }
68
+ exit(fail.zero? ? 0 : 1)
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # STEP 5 gate (issue #578): the rs VM (mode: :native) and the ruby
4
+ # atom evaluation (mode: :ruby) must produce identical trees from the
5
+ # edition-2 artifact. Slices normalize to their content for the
6
+ # comparison, matching parsanol's repetition-flatten-parity spec.
7
+ #
8
+ # Usage: ruby parity-vm.rb
9
+
10
+ require "bundler/setup"
11
+ require "expressir"
12
+ require "parsanol"
13
+ require "json"
14
+
15
+ artifact = Parsanol::PARG::Artifact.from_json(
16
+ File.read(File.join(__dir__, "express-grammar.artifact.json")),
17
+ )
18
+
19
+ NORMALIZE = lambda do |value|
20
+ case value
21
+ when Hash then value.to_h { |key, item| [key, NORMALIZE.call(item)] }
22
+ when Array then value.map { |item| NORMALIZE.call(item) }
23
+ else value.to_s
24
+ end
25
+ end
26
+
27
+ pass = 0
28
+ fail = 0
29
+ skipped = 0
30
+ failures = []
31
+
32
+ Dir.glob(File.expand_path("../spec/**/*.exp", __dir__)).each do |f|
33
+ src = File.read(f)
34
+
35
+ begin
36
+ ruby_tree = artifact.parse("syntax", src, mode: :ruby)
37
+ rescue StandardError
38
+ skipped += 1
39
+ next
40
+ end
41
+
42
+ begin
43
+ native_tree = artifact.parse("syntax", src, mode: :native)
44
+ rescue StandardError, NotImplementedError => e
45
+ fail += 1
46
+ failures << [f, "native lane: #{e.class}: #{e.message[0, 120]}"]
47
+ next
48
+ end
49
+
50
+ if NORMALIZE.call(ruby_tree) == NORMALIZE.call(native_tree)
51
+ pass += 1
52
+ else
53
+ fail += 1
54
+ failures << [f, "trees diverge between native and ruby"]
55
+ end
56
+ end
57
+
58
+ puts "vm parity: #{pass} agree, #{fail} diverge, #{skipped} skipped (ruby lane fails)"
59
+ failures.first(10).each { |f, why| puts " VM GAP: #{File.basename(f)} — #{why}" }
60
+ exit(fail.zero? ? 0 : 1)
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env bash
2
+ # Corpus parity (issue #578 STEP 1 gate): every .exp fixture must parse
3
+ # identically through the DSL and the edition-2 artifact.
4
+ # PARITY_LIB: a parsanol checkout whose lib/ carries the compiler fix —
5
+ # PARITY_LIB=~/src/lutaml/parsanol-capfix/lib ./parity.sh
6
+ set -uo pipefail
7
+ cd "$(dirname "$0")"
8
+ EXE=/Users/mulgogi/.local/share/mise/installs/ruby/3.4.8/lib/ruby/gems/3.4.0/gems/parsanol-1.3.121-arm64-darwin/exe/parsanol
9
+ LIB="${PARITY_LIB:-}"
10
+
11
+ # Oversized fixtures bypass the CLI argv limit: parse through the
12
+ # artifact API directly, in-process.
13
+ big_parity() {
14
+ ruby ${LIB:+-I "$LIB"} -e '
15
+ require "parsanol"
16
+ require "json"
17
+ artifact = Parsanol::PARG::Artifact.from_json(File.read("/tmp/serialized.json"))
18
+ begin
19
+ artifact.parse("syntax", File.read(ARGV[0]), mode: :ruby)
20
+ exit 0
21
+ rescue StandardError
22
+ exit 1
23
+ end' "$1" > /dev/null 2>&1
24
+ }
25
+
26
+ pass=0; fail=0; skipped=0
27
+ for f in $(find /Users/mulgogi/src/lutaml/expressir/spec -name "*.exp" | sort); do
28
+ if [ "$(wc -c < "$f")" -gt 200000 ]; then
29
+ if big_parity "$f"; then art=ok; else art=fail; fi
30
+ if bundle exec ruby -e '
31
+ require "bundler/setup"
32
+ require "expressir"
33
+ begin
34
+ Expressir::Express::Parser.from_exp(File.read(ARGV[0]))
35
+ exit 0
36
+ rescue StandardError, NotImplementedError
37
+ exit 1
38
+ end' "$f" > /dev/null 2>&1; then dsl=ok; else dsl=fail; fi
39
+ if [ "$art" = "$dsl" ]; then pass=$((pass+1)); else
40
+ fail=$((fail+1)); echo "PARITY GAP (big): $f dsl=$dsl artifact=$art"
41
+ fi
42
+ continue
43
+ fi
44
+ src="$(cat "$f")"
45
+ # artifact accept?
46
+ if ruby "$EXE" parg parse /tmp/serialized.json --entry syntax "$src" \
47
+ > /tmp/par-artifact.log 2>&1; then art=ok; else art=fail; fi
48
+ # DSL accept?
49
+ if bundle exec ruby -e '
50
+ require "bundler/setup"
51
+ require "expressir"
52
+ begin
53
+ Expressir::Express::Parser.from_exp(File.read(ARGV[0]))
54
+ exit 0
55
+ rescue StandardError, NotImplementedError
56
+ exit 1
57
+ end' "$f" > /dev/null 2>&1; then dsl=ok; else dsl=fail; fi
58
+
59
+ if [ "$art" = "$dsl" ]; then
60
+ pass=$((pass+1))
61
+ else
62
+ fail=$((fail+1))
63
+ echo "PARITY GAP: $f dsl=$dsl artifact=$art"
64
+ fi
65
+ done
66
+ echo "parity: $pass agree, $fail gaps, $skipped skipped"