Property definitions

sexp $ SExp :: defaultinit
# A full S-Expression, delimited by `(` and `)`
class SExp
	super SExpEntity

	# Children of a SExp
	var content = new Array[SExpEntity]

	redef fun to_s do return "({content.join(" ")})"

	# Returns a pretty-printable version of self
	#
	#     assert "( ( sp 12.3 ) \"DQString\")".to_sexp.as(SExp).pretty_to_s == "(\n\t(\n\t\tsp\n\t\t12.30\n\t)\n\t\"DQString\"\n)"
	fun pretty_to_s: String do return recurse_to_s(0)

	private fun recurse_to_s(depth: Int): String do
		var s = "{"\t" * depth}(\n"
		for i in content do
			if i isa SExp then
				s += i.recurse_to_s(depth + 1)
				s += "\n"
				continue
			end
			s += "\t" * (depth + 1)
			s += i.to_s
			s += "\n"
		end
		return s + "{"\t" * depth})"
	end
end
lib/sexp/sexp.nit:23,1--51,3