1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
|
# File 'lib/nendo.rb', line 1146
def __write( sexp, readable )
getQuoteKeyword = lambda { |x|
case x
when :quote
"'"
when :quasiquote
"`"
when :unquote
","
when :unquote_splicing
",@"
when :dot_operator
"."
else
false
end
}
case sexp
when Cell
arr = sexp.map { |x| __write( x.car, readable ) }
lastAtom = sexp.lastAtom
lastAtom = __write( lastAtom, readable ) if lastAtom
keyword = getQuoteKeyword.call( sexp.car )
if keyword
keyword + arr[1..-1].join( " " ) + (lastAtom ? " . " + lastAtom : "")
else
"(" + arr.join( " " ) + (lastAtom ? " . " + lastAtom : "") + ")"
end
when Symbol
keyword = getQuoteKeyword.call( sexp )
if keyword
keyword
else
sprintf( "%s", sexp.to_s )
end
when String
if readable
sprintf( "\"%s\"", sexp.to_s )
else
sexp.to_s
end
when Nil
"()"
when nil
"nil"
else
sprintf( "%s", sexp )
end
end
|