Sha256: 89fe6796536f26dbfac58c635e1277cb54c142506f5c4106a3e5f89c78ffcc7d
Contents?: true
Size: 829 Bytes
Versions: 3
Compression:
Stored size: 829 Bytes
Contents
# Load the builder class require_relative '../../../lib/rley/parser/token' # Mixin module implementing helper methods. module GrammarHelper # Create a sequence of tokens, one for each grammar symbol name. # Synopsis: # build_token_sequence(%w(a a b c c), grm1) def build_token_sequence(literals, aGrammar) tokens = literals.map do |lexeme| case lexeme when String terminal = aGrammar.name2symbol[lexeme] Rley::Parser::Token.new(lexeme, terminal) when Hash # lexeme is reality a Hash: literal => terminal name sub_array = lexeme.to_a sub_array.map do |(literal, name)| terminal = aGrammar.name2symbol[name] Rley::Parser::Token.new(literal, terminal) end end end return tokens.flatten end end # module
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rley-0.3.04 | spec/rley/support/grammar_helper.rb |
rley-0.3.01 | spec/rley/support/grammar_helper.rb |
rley-0.3.00 | spec/rley/support/grammar_helper.rb |