Sha256: d25c88f90efc6352072a9654f187ae84a69951e567130957750b0efcee7a3446
Contents?: true
Size: 989 Bytes
Versions: 27
Compression:
Stored size: 989 Bytes
Contents
require 'syntax/common' module Syntax # A default tokenizer for handling syntaxes that are not explicitly handled # elsewhere. It simply yields the given text as a single token. class Default # Yield the given text as a single token. def tokenize( text ) yield Token.new( text, :normal ) end end # A hash for registering syntax implementations. SYNTAX = Hash.new( Default ) # Load the implementation of the requested syntax. If the syntax cannot be # found, or if it cannot be loaded for whatever reason, the Default syntax # handler will be returned. def load( syntax ) begin require "syntax/lang/#{syntax}" rescue LoadError end SYNTAX[ syntax ].new end module_function :load # Return an array of the names of supported syntaxes. def all lang_dir = File.join(File.dirname(__FILE__), "syntax", "lang") Dir["#{lang_dir}/*.rb"].map { |path| File.basename(path, ".rb") } end module_function :all end
Version data entries
27 entries across 27 versions & 3 rubygems