[Freeciv-Dev] Re: [RFC PATCH] init_techs
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Mon, Sep 24, 2001 at 08:26:09PM -0400, Justin Moore wrote:
>
> > > /set attribute nation.Greek.techs Alphabet,Iron Working
> > > ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >
> > An aside: a standard way to denote words with non-alphanumerics must
> > be picked. I don't care what it is, but adding the ability to interpret
> > the command line above leads to problems.
>
> Feel free to suggest a system. I just write the parsing code around
> here (and occasionally serve as village idiot).
(Are you asking me to move to the next village?)
Words on the command line are separated with whitespace.
Except in the /set option=value case.
Some identifiers can contain spaces: directory names, proper names,
but no identifier can begin or end with a space.
Proper names can contain [-'.], and possibly non-ASCII characters
("Valéry Giscard d'Estaing", "Dr. Jekyll-Hyde"), but never =.
Some other words can contain other kinds of characters. Unix directory
names, for instance, can contain every character except / and \0.
One approach to have a system in which all strings can be represented
as words on the command line. One way to do it is to use " as a
special quote character:
/set attribute nation.Burgundians.techs Bouillabaisse,"Hors d'Oeuvre"
Then some way has to be found to denote the empty string, and
the " character itself. One way is to let "" mean
- the " character, after an odd number of "s
- the empty string, after an even number of "s
An alternative is to use an escape character, eg. \ as in Unix shells.
Another problem is special metanotation. For example, it must be
possible to denote "all players". "ALL" and "*" are obvious choices.
Whatever the choice, it must be possible to distinguish this notation
from a player name "*" or "ALL". The way it which this is done must be
general (not specific to player names). Furthermore, the system must
be extensible: new metanotations may be introduced later on. I think
the simplest way to deal with it is to keep within the Freeciv code a
list of the special metanotations and the version of the language in
which they appeared, and write the language version number to each file
in which the language is used (just like it is already done with rulesets).
So my proposal is to use whitespace as a word separator, to always allow
any identifier to be quoted with " (which, when used on metanotation, will
escape its special meaning), and to denote the literal " character within
an identifier as "".
I think this is good enough, but I'm not sure. There is no convention
for continuing a command line or even an identifier on the next line.
Using the full C syntax for strings may be a better idea.
[...]
> > > The first part in each of these is the command. The second part is the
> > > "char *arg" that gets passed to the function. These callbacks should be
> > > content-oblivious, and it should be up to the specific functions to
> > > interpret the data correctly.
> >
> > Don't you think all commands should be parsed with standard functions that
> > perform typechecking?
>
> I do, but I think they should be in the cmd_* functions, not in the
> parsing code. See my previous e-mails/rants as to why.
I think syntactic feedback ("argument %d of command %s cannot be an %s")
is more informative than semantic feedback (an error message that takes
advantage of the actual meaning of the command, but omits syntactic detail).
The reader wants to debug the command. So if the messages are passed to
the cmd_* functions the syntactic information should at least be
passed along. It isn't at the moment.
> -jdm
--
Reinier
- [Freeciv-Dev] Re: commandline syntax and semantics (was: Server/ruleset unification), (continued)
- [Freeciv-Dev] Re: Server/ruleset unification [Was [RFC PATCH] init_techs], Raimar Falke, 2001/09/30
- [Freeciv-Dev] Re: Server/ruleset unification [Was [RFC PATCH] init_techs], Daniel L Speyer, 2001/09/25
- [Freeciv-Dev] Re: Server/ruleset unification [Was [RFC PATCH] init_techs], Reinier Post, 2001/09/27
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Justin Moore, 2001/09/24
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Reinier Post, 2001/09/24
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Reinier Post, 2001/09/24
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Reinier Post, 2001/09/24
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Justin Moore, 2001/09/24
- [Freeciv-Dev] Re: [RFC PATCH] init_techs,
Reinier Post <=
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Justin Moore, 2001/09/26
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Reinier Post, 2001/09/23
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Arien Malec, 2001/09/20
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Daniel L Speyer, 2001/09/22
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Justin Moore, 2001/09/22
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Arien Malec, 2001/09/22
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Reinier Post, 2001/09/23
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Raimar Falke, 2001/09/23
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Reinier Post, 2001/09/23
- [Freeciv-Dev] Re: [RFC PATCH] init_techs, Reinier Post, 2001/09/23
|
|