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
@@ -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
@@ -209,7 +247,13 @@ module Expressir
209
247
  (generalRef >> qualifier.repeat.as(:qualifier) >> op_decl >> expression >> op_delim).as(:assignmentStmt)
210
248
  end
211
249
  rule(:attributeDecl) do
212
- (attributeId | redeclaredAttribute).as(:attributeDecl)
250
+ # redeclaredAttribute first: it anchors on SELF, so plain
251
+ # attribute names fail it instantly; the reverse order lets
252
+ # the unguarded fallback match a bare "SELF" and packrat
253
+ # memoization then blocks the retry (issue #581). The
254
+ # unguarded fallback rides only the definition site (the
255
+ # colon anchors it); references keep the guarded simpleId.
256
+ (redeclaredAttribute | (simpleId | unguardedId).as(:attributeId)).as(:attributeDecl)
213
257
  end
214
258
  rule(:attributeId) { simpleId.as(:attributeId) }
215
259
  rule(:attributeQualifier) do
@@ -648,6 +692,16 @@ module Expressir
648
692
  # whole identifier in a single step — parsanol GH-69.
649
693
  anyKeyword.absent? >> cts(match("[a-zA-Z_][a-zA-Z0-9_]*").as(:str)).as(:simpleId)
650
694
  end
695
+ rule(:unguardedId) do
696
+ # issue #581: keyword-named attributes ("value : INTEGER")
697
+ # are real-world EXPRESS and the core lane has always
698
+ # accepted them. Only the COLON-ANCHORED attribute-definition
699
+ # position takes this fallback — there the ":" stops the
700
+ # match before a closing keyword; guarded simpleId stays
701
+ # everywhere else (a keyword swallowed as an identifier
702
+ # expression would break "WHERE TRUE; END_TYPE").
703
+ cts(match("[a-zA-Z_][a-zA-Z0-9_]*").as(:str)).as(:simpleId)
704
+ end
651
705
  rule(:simpleStringLiteral) do
652
706
  cts((str("'") >> (str("'").absent? >> any).repeat >> str("'")).as(:str)).as(:simpleStringLiteral)
653
707
  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
@@ -633,6 +633,9 @@ rules:
633
633
  - rule: simpleId
634
634
  production: simple_id
635
635
  status: aligned
636
+ - rule: unguardedId
637
+ production: simple_id
638
+ status: aligned
636
639
  - rule: simpleStringLiteral
637
640
  production: simple_string_literal
638
641
  status: aligned
@@ -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.49".freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-02 00:00:00.000000000 Z
11
+ date: 2026-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys
@@ -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