expressir 2.4.47 → 2.4.49

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,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Splices the fragments into express.parg. Idempotent: rebuilds from the
4
+ # head (everything before the keyword block). Order: keywords, literals,
5
+ # operators, entries (the closing brace rides the entries fragment).
6
+ FRAGMENTS = %w[
7
+ keywords.parg.frag
8
+ literals.parg.frag
9
+ operators.parg.frag
10
+ entries.parg.frag
11
+ ].freeze
12
+
13
+ g = File.read("express.parg")
14
+ head = g.split("# --- keyword terminals")[0]
15
+ File.write("express.parg", head + FRAGMENTS.map { |f| File.read(f) }.join)
16
+ puts "spliced"
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Tree-diff the DSL lane against the artifact lane for a fixture:
4
+ # reports the first path where the two named trees diverge.
5
+ #
6
+ # ruby -I <parsanol-lib> tree_diff.rb <file.exp>
7
+
8
+ $LOAD_PATH.unshift(ARGV[0]) if ARGV[0]
9
+
10
+ require "bundler/setup"
11
+ require "expressir"
12
+ require "parsanol"
13
+
14
+ src = File.read(ARGV[-1])
15
+ dsl = Expressir::Express::Grammar::Parser.cached_parser.parse(src)
16
+ art = Expressir::Express::Grammar::Parser.parse_artifact(src)
17
+
18
+ diffs = []
19
+ walk = lambda do |a, b, path|
20
+ return if diffs.size >= 8
21
+
22
+ if a.is_a?(Parsanol::Slice) || b.is_a?(Parsanol::Slice)
23
+ diffs << "#{path}: #{a.inspect} vs #{b.inspect}" if a.inspect != b.inspect
24
+ return
25
+ end
26
+ return unless a.is_a?(Hash) && b.is_a?(Hash)
27
+
28
+ ka = a.keys - [:comments]
29
+ kb = b.keys - [:comments]
30
+ # :comments = the trivia-recording channel (DSL source-preserving
31
+ # mode records whitespace units; the artifact lane does not). The
32
+ # builder never reads it (find_slice skips :spaces; remarks ride the
33
+ # RemarkScanner over source), so it is out of tree-parity scope.
34
+ if ka != kb
35
+ diffs << "#{path}: keys #{ka.inspect} vs #{kb.inspect}"
36
+ return
37
+ end
38
+
39
+ a.each_key do |k|
40
+ # Trivia channels, proven builder-inert (no builder reads them;
41
+ # find_slice skips :spaces; remarks ride the RemarkScanner): the
42
+ # DSL records whitespace units, the artifact lane does not.
43
+ next if %i[comments spaces].include?(k)
44
+
45
+ va = a[k]
46
+ vb = b[k]
47
+ if va.is_a?(Array) && vb.is_a?(Array)
48
+ if va.size != vb.size
49
+ diffs << "#{path}/#{k}: array size #{va.size} vs #{vb.size}"
50
+ next
51
+ end
52
+ va.each_with_index { |el, i| walk.call(el, vb[i], "#{path}/#{k}[#{i}]") }
53
+ elsif va.is_a?(Hash) && vb.is_a?(Hash)
54
+ walk.call(va, vb, "#{path}/#{k}")
55
+ elsif va.class != vb.class || (va.respond_to?(:to_s) && va.to_s != vb.to_s)
56
+ diffs << "#{path}/#{k}: #{va.inspect[0, 80]} vs #{vb.inspect[0, 80]}"
57
+ end
58
+ end
59
+ end
60
+ walk.call(dsl, art, "root")
61
+
62
+ puts diffs.empty? ? "TREES IDENTICAL" : diffs.first(8)