Class: Stockade::Parser

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/stockade/parser.rb

Overview

Parser

Takes a raw list (a set really) of lexemes returned by Lexer and further processes them. Currently this means:

  1. Deduping - >1 ambiguous lexemes matching exactly same fragment are deduped according to their priority. Only the highest priority lexeme kept.

  2. Removing covered lexems - lexeme that matches a string that is a

substring of another matched string is removed.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lexemes) ⇒ Parser

Returns a new instance of Parser.



19
20
21
# File 'lib/stockade/parser.rb', line 19

def initialize(lexemes)
  @lexemes = lexemes
end

Instance Attribute Details

#lexemesObject (readonly)

Returns the value of attribute lexemes.



17
18
19
# File 'lib/stockade/parser.rb', line 17

def lexemes
  @lexemes
end

Class Method Details

.call(lexemes) ⇒ Object



23
24
25
# File 'lib/stockade/parser.rb', line 23

def self.call(lexemes)
  new(lexemes).call
end

Instance Method Details

#callObject



27
28
29
# File 'lib/stockade/parser.rb', line 27

def call
  non_covered_lexemes
end