[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
DCG, lists and custom operators...
From: |
Sean Charles |
Subject: |
DCG, lists and custom operators... |
Date: |
Wed, 30 Apr 2014 18:33:27 +0100 |
A while ago I started writing an HTTP library and I have been trying to decide
how to write it. Let me explain…
If I wanted to use DCG notation then, as far as I understand the mechanics of
gprolog, I would need the complete list in its entirety to begin with which
means that I would need to keep on reading bytes from the socket connection
until …. when? I couldn’t assume that a socket close would indicate the end of
the request in case ‘keep-alive’ had been sent in the header!
The implication is that I would therefore have to write a parser that fetched
one character at a time and using the usual methods (FSM-s etc) gradually work
its way through the stream examining each part of the request as it was
received and then taking the appropriate action. That is also not a problem, I
have already written such a parser for a computer language I developed a while
back which parses S-expression syntax into a list of terms so that is not a
problem either should I choose to go down that route.
Is there scope within the “[]” operator to extend it to consume data from a
stream ?
Tonight I will do some research on this but is it even possible withing GNU
Prolog, I don’t know yet?!?!?!
What I would like to try to achieve is some sort of system whereby a modified
DCG translation system would “fault” on having the empty list and before
continuing, attempt to read another character from the stream, and only truly
“be” the empty list of the EOF has been reached. I think that this also raises
issues though because this would have to be buried from the actual point of
trying to unify the DCG head if you see what I mean.
Sometimes being igorant is hard work!
Thanks in advanc elist for any useful feedback.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- DCG, lists and custom operators...,
Sean Charles <=