~singpolyma/dhall-ruby

5d3460ef692e1531bb4e9cc815b6a49763055456 — Stephen Paul Weber 3 years ago be0eee1
Remove hardcoded list of builtin names
2 files changed, 3 insertions(+), 43 deletions(-)

M lib/dhall/util.rb
M scripts/generate_citrus_parser.rb
M lib/dhall/util.rb => lib/dhall/util.rb +0 -42
@@ 61,48 61,6 @@ module Dhall
			end
		end

		module BuiltinName
			NAMES = [
				"Natural/build",
				"Natural/fold",
				"Natural/isZero",
				"Natural/even",
				"Natural/odd",
				"Natural/toInteger",
				"Natural/show",
				"Integer/toDouble",
				"Integer/show",
				"Double/show",
				"List/build",
				"List/fold",
				"List/length",
				"List/head",
				"List/last",
				"List/indexed",
				"List/reverse",
				"Optional/fold",
				"Optional/build",
				"Text/show",
				"Bool",
				"Optional",
				"Natural",
				"Integer",
				"Double",
				"Text",
				"List",
				"True",
				"False",
				"None",
				"Type",
				"Kind",
				"Sort"
			].freeze

			def self.===(other)
				NAMES.include?(other)
			end
		end

		def self.match_results(xs=nil, ys=nil)
			Array(xs).each_with_index.map do |r, idx|
				yield r, ys[idx]

M scripts/generate_citrus_parser.rb => scripts/generate_citrus_parser.rb +3 -1
@@ 179,7 179,9 @@ end

puts "rule reserved_identifier"
print "\t"
puts Dhall::Util::BuiltinName::NAMES.map { |name| "\"#{name}\"" }.join(" |\n\t")
puts Dhall::Builtins.constants.map { |name|
	"\"#{name.to_s.tr("_", "/")}\""
}.join(" |\n\t")
puts "end"

puts "end"