expressir 2.4.47 → 2.4.48

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/expressir.gemspec +1 -1
  3. data/grammar-parg/CONVENTIONS.md +90 -0
  4. data/grammar-parg/RULE-INVENTORY.txt +252 -0
  5. data/grammar-parg/atoms_to_parg.rb +232 -0
  6. data/grammar-parg/bisect.sh +37 -0
  7. data/grammar-parg/ddmin.sh +39 -0
  8. data/grammar-parg/dsl-dump.json +1 -0
  9. data/grammar-parg/entries.parg.frag +12 -0
  10. data/grammar-parg/express-grammar.artifact.json +1 -0
  11. data/grammar-parg/express-grammar.parg +380 -0
  12. data/grammar-parg/express.json +1 -0
  13. data/grammar-parg/express.parg +57 -0
  14. data/grammar-parg/express_keywords.parg +132 -0
  15. data/grammar-parg/express_literals.parg +14 -0
  16. data/grammar-parg/express_operators.parg +34 -0
  17. data/grammar-parg/express_remarks.parg +19 -0
  18. data/grammar-parg/express_structure.parg +11 -0
  19. data/grammar-parg/generate-terminals.rb +55 -0
  20. data/grammar-parg/keywords.parg.frag +130 -0
  21. data/grammar-parg/literals.parg.frag +9 -0
  22. data/grammar-parg/operators.parg.frag +34 -0
  23. data/grammar-parg/parity-model.rb +68 -0
  24. data/grammar-parg/parity-vm.rb +60 -0
  25. data/grammar-parg/parity.sh +66 -0
  26. data/grammar-parg/parser-dsl-reference.rb.txt +757 -0
  27. data/grammar-parg/splice.rb +16 -0
  28. data/grammar-parg/tree_diff.rb +62 -0
  29. data/lib/expressir/express/grammar/express-grammar.artifact.json +1 -0
  30. data/lib/expressir/express/grammar/parser.rb +38 -0
  31. data/lib/expressir/express/parser.rb +3 -3
  32. data/lib/expressir/express/remark_attacher.rb +4 -2
  33. data/lib/expressir/model/model_element.rb +3 -0
  34. data/lib/expressir/version.rb +1 -1
  35. metadata +30 -9
@@ -126,6 +126,44 @@ module Expressir
126
126
  end
127
127
  end
128
128
 
129
+ # The compiled edition-2 PARG artifact: the DSL grammar's
130
+ # serialized twin (grammar-parg/express-grammar.parg, built by
131
+ # grammar-parg/atoms_to_parg.rb from the live atom tree). The
132
+ # artifact lane parses through parsanol's artifact VM and
133
+ # yields the same named trees the DSL path produces.
134
+ ARTIFACT_PATH = File.join(__dir__, "express-grammar.artifact.json")
135
+
136
+ def self.artifact_available?
137
+ return @artifact_available unless @artifact_available.nil?
138
+
139
+ @artifact_available = begin
140
+ require "parsanol/parg/artifact"
141
+ Parsanol::PARG::Artifact.respond_to?(:from_json) && File.exist?(ARTIFACT_PATH)
142
+ rescue LoadError
143
+ false
144
+ end
145
+ end
146
+
147
+ def self.parse_artifact(source)
148
+ raise LoadError, "Edition-2 artifact not available" unless artifact_available?
149
+
150
+ @parser_mutex.synchronize do
151
+ @artifact ||= Parsanol::PARG::Artifact.from_json(File.read(ARTIFACT_PATH))
152
+ end
153
+ # mode: :native rides the rs VM when the parsanol native ext
154
+ # is present and falls back to the ruby atom evaluation
155
+ # otherwise (Artifact#parse's own lane logic).
156
+ @artifact.parse("syntax", source)
157
+ end
158
+
159
+ # The Ruby-lane parse: the edition-2 artifact first, the DSL
160
+ # parser as fallback (issue #578 STEP 4).
161
+ def self.parse_ruby(source)
162
+ parse_artifact(source)
163
+ rescue StandardError, NotImplementedError
164
+ cached_parser.parse(source)
165
+ end
166
+
129
167
  def cts(atom)
130
168
  spaces >> atom
131
169
  end
@@ -79,10 +79,10 @@ module Expressir
79
79
  begin
80
80
  Grammar::Parser.parse_native(source)
81
81
  rescue StandardError
82
- Grammar::Parser.cached_parser.parse source
82
+ Grammar::Parser.parse_ruby(source)
83
83
  end
84
84
  else
85
- Grammar::Parser.cached_parser.parse source
85
+ Grammar::Parser.parse_ruby(source)
86
86
  end
87
87
  rescue Parsanol::ParseFailed => e
88
88
  raise Error::SchemaParseFailure.new(schema_file, e)
@@ -483,7 +483,7 @@ include_source: nil, root_path: nil, use_native: nil, &block)
483
483
  ast = if use_native && Grammar::Parser.native_available?
484
484
  Grammar::Parser.parse_native(content)
485
485
  else
486
- Grammar::Parser.cached_parser.parse(content)
486
+ Grammar::Parser.parse_ruby(content)
487
487
  end
488
488
  rescue Parsanol::ParseFailed, StandardError => e
489
489
  raise Error::SchemaParseFailure.new("(from string)", e)
@@ -930,6 +930,9 @@ module Expressir
930
930
 
931
931
  def normalize_path(path)
932
932
  return path unless path.include?(":")
933
+ # `__note:two` is one item id (a referable note/example), not a
934
+ # prefix:name pair to split into two path segments.
935
+ return path if path.split(".").last.start_with?("__")
933
936
 
934
937
  path_part, _, item_suffix = path.rpartition(":")
935
938
  "#{path_part}.#{item_suffix}"
@@ -1126,8 +1129,7 @@ module Expressir
1126
1129
  end
1127
1130
 
1128
1131
  def safe_reset_children_by_id(obj)
1129
- return unless obj
1130
- return unless obj.is_a?(Model::ScopeContainer)
1132
+ return unless obj.respond_to?(:reset_children_by_id)
1131
1133
 
1132
1134
  obj.reset_children_by_id
1133
1135
  end
@@ -210,6 +210,9 @@ module Expressir
210
210
  return self if path.nil? || path.empty?
211
211
 
212
212
  path_parts = path.safe_downcase.split(".").map do |current_path|
213
+ # `__note:two` is a remark item id, not a prefixed name
214
+ next current_path if current_path.start_with?("__")
215
+
213
216
  _, _, current_path = current_path.rpartition(":") # ignore prefix
214
217
  current_path
215
218
  end
@@ -3,6 +3,6 @@ module Expressir
3
3
  # autoload it (Ruby autoload only works for module/class constants, not
4
4
  # for string constants like `Expressir::VERSION`).
5
5
  module Version
6
- VERSION = "2.4.47".freeze
6
+ VERSION = "2.4.48".freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expressir
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.47
4
+ version: 2.4.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -142,20 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.3.9
146
- - - ">="
147
- - !ruby/object:Gem::Version
148
- version: 1.3.89
145
+ version: 1.3.123
149
146
  type: :runtime
150
147
  prerelease: false
151
148
  version_requirements: !ruby/object:Gem::Requirement
152
149
  requirements:
153
150
  - - "~>"
154
151
  - !ruby/object:Gem::Version
155
- version: 1.3.9
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- version: 1.3.89
152
+ version: 1.3.123
159
153
  - !ruby/object:Gem::Dependency
160
154
  name: ruby-progressbar
161
155
  requirement: !ruby/object:Gem::Requirement
@@ -474,6 +468,32 @@ files:
474
468
  - ext/expressir_core/Cargo.toml
475
469
  - ext/expressir_core/extconf.rb
476
470
  - ext/expressir_core/src/lib.rs
471
+ - grammar-parg/CONVENTIONS.md
472
+ - grammar-parg/RULE-INVENTORY.txt
473
+ - grammar-parg/atoms_to_parg.rb
474
+ - grammar-parg/bisect.sh
475
+ - grammar-parg/ddmin.sh
476
+ - grammar-parg/dsl-dump.json
477
+ - grammar-parg/entries.parg.frag
478
+ - grammar-parg/express-grammar.artifact.json
479
+ - grammar-parg/express-grammar.parg
480
+ - grammar-parg/express.json
481
+ - grammar-parg/express.parg
482
+ - grammar-parg/express_keywords.parg
483
+ - grammar-parg/express_literals.parg
484
+ - grammar-parg/express_operators.parg
485
+ - grammar-parg/express_remarks.parg
486
+ - grammar-parg/express_structure.parg
487
+ - grammar-parg/generate-terminals.rb
488
+ - grammar-parg/keywords.parg.frag
489
+ - grammar-parg/literals.parg.frag
490
+ - grammar-parg/operators.parg.frag
491
+ - grammar-parg/parity-model.rb
492
+ - grammar-parg/parity-vm.rb
493
+ - grammar-parg/parity.sh
494
+ - grammar-parg/parser-dsl-reference.rb.txt
495
+ - grammar-parg/splice.rb
496
+ - grammar-parg/tree_diff.rb
477
497
  - lib/expressir.rb
478
498
  - lib/expressir/benchmark.rb
479
499
  - lib/expressir/changes.rb
@@ -595,6 +615,7 @@ files:
595
615
  - lib/expressir/express/formatters/statements_formatter.rb
596
616
  - lib/expressir/express/formatters/supertype_expressions_formatter.rb
597
617
  - lib/expressir/express/grammar.rb
618
+ - lib/expressir/express/grammar/express-grammar.artifact.json
598
619
  - lib/expressir/express/grammar/parser.rb
599
620
  - lib/expressir/express/hyperlink_formatter.rb
600
621
  - lib/expressir/express/interface_dot.rb