Class: Pubid::Nist::Parser
- Inherits:
-
Parslet::Parser
- Object
- Parslet::Parser
- Pubid::Nist::Parser
- Defined in:
- lib/pubid/nist/parser.rb
Overview
Parser class for NIST identifiers Single Responsibility: Parsing NIST identifier syntax
Class Method Summary collapse
-
.class_parse_with_preprocessing(input) ⇒ Object
Class-level parse method with preprocessing.
Class Method Details
.class_parse_with_preprocessing(input) ⇒ Object
Class-level parse method with preprocessing. Delegates all string normalization to Nist::Preprocessor, then feeds the cleaned string to the Parslet grammar and stamps the detected format onto the parse tree.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pubid/nist/parser.rb', line 15 def self.class_parse_with_preprocessing(input) result = Preprocessor.new(input).call parsed = new.parse(result.cleaned) if parsed.is_a?(Hash) parsed.merge(parsed_format: result.format) elsif parsed.is_a?(Array) merged = parsed.each_with_object({}) do |hash, acc| next acc unless hash.is_a?(Hash) acc.merge!(hash) end merged.merge(parsed_format: result.format) else parsed end end |