Hello,
I am working on a socket based client to concept base. I am receiving responses from the server as strings such as so:
‘ipcanswer(“CBserver_s79114368_1”,error,“no”).’
How can i easily parse this text (received as a list of chars) into its component terms?
I guess, i could define a DCG with terminals as individual characters and then build this up, somehow …
is this the way to go …
Dan
EricGT
February 21, 2020, 1:21pm
2
There is library(optparse): command line parsing which is not a direct fit, but if it works will do a lot of the heavy lifting for you.
EDIT
The more I look at what you want to do and compare that with the abilities of library(optparse) the more I think your idea is correct.
is the way I would go at first. But I do spend a large amount of my time writing DCGs so for the most part I find them easy going; your mileage may vary .
Boris
February 21, 2020, 5:51pm
3
I must be missing something here. This looks like a proper Prolog term and you just need to read it.
?- read_term_from_atom('ipcanswer("CBserver_s79114368_1",error,"no")', X, []).
X = ipcanswer("CBserver_s79114368_1", error, "no").
What am I missing?
1 Like
Hi Boris,
Thank you.
You aren’t missing anything – i am …
Thanks for noticing this …
Dan