[fpc-pascal] Interactive command recognition & mapping to program functions & other 'cli' features as a unit

Lukasz Sokol el.es.cr at gmail.com
Mon Aug 3 10:22:08 CEST 2015

On 31/07/15 16:41, Mark Morgan Lloyd wrote:
> Lukasz Sokol wrote:
>> On 31/07/15 14:46, Mark Morgan Lloyd wrote:
>>> Lukasz Sokol wrote:
>>>> Hi,
>>>> I tried piecing something like in $topic together,
>>>> intended as an 'interactive' command interpreter for my program. (which will in time grow an 'embedded' web server and intended to
>>>> run as a (windows) service, but it's too early for that at the
>>>> moment)

> Looking at your question another way, I suppose that you also have
> the issue of parsing a command as well as handling the data entry. I
> think that there's various possibilities here depending on what
> you're trying to handle:
> * A simple sequence of names/numbers.
Supposedly this would do, parameters mostly are numbers (but when parsing
through a TStringList everything is a string first anyway, so I can define
some rules as to which parameter is what type)

> * A unix-style command line, with leading options.

Would be nice, however I don't need 'if' or explicitly defined looping instructions...

> * A sequence of email/HTTP headers.
> * XML.
> * Any of the above but with macro and/or numeric evaluation.

This would be nice to have, some commands could 'substitute' a variable 
prefixed with a '$' that they find in the rest of cmdline, for their own output
(like, running other commands in a sequence, but without explicit conditional commands)

> I note in particular that PostgreSQL uses Flex and Bison, and if
> they'll parse (a fairly comprehensively extended) SQL I guess they'll
> parse about anything. Apart from that I've hacked something together
> for my own use based on Smalltalk (as an outer parser) with various
> evaluation possibilities (as an inner parser), this was intended as a
> way for programs to talk to each other and has its good points.

Hmm seems way too complicated for my purpose(s) ;) But we'll see,

> I'm not sure whether getopts from the RTL provides a facility for you
> to feed it an arbitrary string for processing, but it would probably
> be a good place to start. 

I'll have a look.

Thank you,

Kind Regards,
 el es

More information about the fpc-pascal mailing list