Sha256: 69a85e8e5933c7d02d35ab39b01669eddfd0ce0c9c31095e4df3c8c984f95cd0

Contents?: true

Size: 1004 Bytes

Versions: 3

Compression:

Stored size: 1004 Bytes

Contents

# File: sequitur.rb
# This file acts as a jumping-off point for loading dependencies expected
# for a Sequitur client.

require_relative './sequitur/constants'
require_relative './sequitur/sequitur_grammar'
require_relative './sequitur/formatter/debug'
require_relative './sequitur/formatter/base_text'


module Sequitur
  # Build a Sequitur-generated grammar based on the sequence of input tokens.
  #
  # @param tokens [StringOrEnumerator] The input sequence of input tokens.
  #   Can be a sequence of characters (i.e. a String) or an Enumerator.
  #   Tokens returned by enumerator should respond to the :hash message.
  # @return [SequiturGrammar] a grammar that encodes the input.
  def self.build_from(tokens)
    input_sequence = case tokens
                       when String then tokens.chars
                       when Enumerator then tokens
                       else tokens.to_enum
                     end

    return SequiturGrammar.new(input_sequence)
  end
end # module

# End of file

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sequitur-0.1.20 lib/sequitur.rb
sequitur-0.1.19 lib/sequitur.rb
sequitur-0.1.18 lib/sequitur.rb