I am implementing client agent for Robocup Soccer simulator in Erlang. Simulator sends sensory information to client in form of S-expressions. Like this
(see 15 ((f c) 2 0 0 0) ((f r t) 64.1 -32) ((f r b) 64.1 32) ((f g r b) 55.1 7)
((g r) 54.6 0) ((b) 2 0 -0 0) ((l r) 54.6 90))
(see 16 ((f r t) 72.2 -44) ((f r b) 54.1 20) ((f g r b) 52.5 -10) ((g r) 54.1 -17)
((l r) 51.4 -89))
Simulator sends such type of sensor informatio in each cycle(100-200 msec). The main format of the information is:
(see Time ObjInfo ObjInfo . . . )
The ObjInfos are of the format below:
(ObjName Distance Direction [DistChange DirChange [BodyFac- ingDir HeadFacingDir]])
where the objects are like: (b) Ball, (g r) Right goal, (f ...) represents various flags.
What I want is to parse this information and store/update in some database(record) to use for analysis. The main difficulty I am facing is to Parse this information. Please suggest me some way of doing this? (does Erlang contain any library for such work)
Yecc and Leex are your friends: http://erlang.org/doc/apps/parsetools/index.html
Leex is a lexical analyzer generator for Erlang which will tokenize your data. Yecc is LALR-1 parser generator that can parse your tokens into meaningful structures.
There's a good blog post by Relops, Leex And Yecc, detailing some of the basics.