class Rley::Syntax::MatchClosest
A constraint that indicates that a given rhs member must match the closest given terminal symbol in that rhs
Attributes
@return [String] name of closest preceding symbol to pair
@return [NilClass, Array<Parser::ParseEntry>] set of entries with closest symbol
@return [Integer] index of constrained symbol to match
Public Class Methods
Source
# File lib/rley/syntax/match_closest.rb, line 20 def initialize(aSymbolSeq, idxSymbol, nameClosest) @idx_symbol = valid_idx_symbol(idxSymbol, aSymbolSeq) @closest_symb = valid_name_closest(nameClosest) end
@param aSymbolSeq [Rley::Syntax::SymbolSeq] a sequence of grammar symbols @param idxSymbol [Integer] index of symbol @param nameClosest [String] Terminal
symbol name
Private Instance Methods
Source
# File lib/rley/syntax/match_closest.rb, line 28 def valid_idx_symbol(idxSymbol, aSymbolSeq) bounds = 0..aSymbolSeq.size - 1 err_msg_outbound = 'Index of symbol out of bound' raise StandardError, err_msg_outbound unless bounds.include? idxSymbol idxSymbol end
Check that the provided index is within plausible bounds
Source
# File lib/rley/syntax/match_closest.rb, line 36 def valid_name_closest(nameClosest) nameClosest end