Talk:S-expressions: Difference between revisions

Content added Content deleted
(→‎lisp solutions: new section)
Line 174: Line 174:
:::huh? the only thing ever removed was: "must, in addition, recognise integers and floating point literals (that are distinguished as digits followed by a decimal point, followed by digits)." replacing it with "should, in addition, recognize numbers if the language has appropriate datatypes." i have also moved that paragraph in the process. this was the last edit on the description [http://rosettacode.org/mw/index.php?title=S-Expressions&diff=next&oldid=123268 (see diff)]
:::huh? the only thing ever removed was: "must, in addition, recognise integers and floating point literals (that are distinguished as digits followed by a decimal point, followed by digits)." replacing it with "should, in addition, recognize numbers if the language has appropriate datatypes." i have also moved that paragraph in the process. this was the last edit on the description [http://rosettacode.org/mw/index.php?title=S-Expressions&diff=next&oldid=123268 (see diff)]
:::i have checked the complete history to make sure i didn't delete something by accident.--[[User:EMBee|eMBee]] 09:06, 20 October 2011 (UTC)
:::i have checked the complete history to make sure i didn't delete something by accident.--[[User:EMBee|eMBee]] 09:06, 20 October 2011 (UTC)

== lisp solutions ==

the lisp solutions demonstrate the steps needed to actually read s-expressions from string, but for those interested in learning how to write a simple parser in lisp it would also be nice if we could have solutions that re-implement a parser with basic lisp tools. assume for example the s-expressions are written with [] instead of ().

how would a parser look like that turns
<lang lisp>(setq input "[[data \"quoted data\" 123 4.5]
[data [!@# [4.5] \"[more\" \"data]\"]]]")</lang>
into
<lang lisp>((data "quoted data" 123 4.5)
(data (|!@#| (4.5) "[more" "data]")))</lang>
and back?--[[User:EMBee|eMBee]] 09:49, 20 October 2011 (UTC)