Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: Server/ruleset unification [Was [RFC PATCH] init_techs
Home

[Freeciv-Dev] Re: Server/ruleset unification [Was [RFC PATCH] init_techs

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx (Freeciv developers)
Subject: [Freeciv-Dev] Re: Server/ruleset unification [Was [RFC PATCH] init_techs]
From: Reinier Post <rp@xxxxxxxxxx>
Date: Thu, 27 Sep 2001 13:10:49 +0200

On Tue, Sep 25, 2001 at 10:33:52AM -0700, Arien Malec wrote:
> Attached is an EBNF description describing my proposal for part of the unified
> language. I've left off help & server control for now. I've also left off the
> spec for attribute_value (which is where all the excitement is at the moment).
> 
> Things to note:
> 
> 1) The normal way to terminate a command is with '\n', but a create or object
> set command is terminated with ';\n', since those sorts of commands are likely
> to span lines

I'd prefer the Unix shell way:  \ as the last token indicates 'command
continued on next line', and the ; token can always split commands on
lines.

> 2) Many of the commands either take a simple attribute or an object spec. An
> object spec can always be distingushed by the presence of the reserved word
> 'object'.

This is more verbose than required.  So is create/set distinction.
It adds clarity.

> Examples of this syntax:
> 
> set fubar 1

Can you introduce variables in this way?

> create object tech automobile; #Gets created with default characteristics
>
> create object tech automobile
>       name = _("Automobile")
>       req1 = "Combustion",
>       req2 "Steel",
>       flags = "Population_Pollution_Inc";

This could be:

  set game.techs.next.name = _("Automobile")
  set game.techs.last.req1 = "Combustion"
  set game.techs.last.req2 = "Steel"
  set game.techs.last.flags = "Population_Pollution_Inc"

The engine already knows that game.techs is a list of tech objects;
'next' is a special index number denoting one past the last; there is
no object there so the engine can infer that one must be created;
after which it sets its name.

So only a 'set' command is strictly necessary.  You allow symbolic
names such as 'automobile' by distinguishing between 'create object'
and 'set'; an alternative is to distinguish between copy and
hardlink, in Unix style:

  link automobile = game.techs.next        # ln     (reference)
  copy automobile.name = _("Automobile")   # cp     (copy of value)
  link automobile.name = _("Auto")         # invalid, unless strings
                                           # are treated as references

I think I prefer this: it is more powerful.

The "=" can be omitted and the arguments reversed, in Unix style, but
it seems more intuitive this way.

But it may be too general for Freeciv, where only objects (structs) can
be shared; besides, many users do not understand the difference between
ln and ln -s.

> syntax                        : simple_syntax | compound_syntax
> 
> simple_syntax         : simple_statement '\n'
> 
> compound_syntax               : compound_statement ';' '\n'
> 
> simple_statement      :
>                         simple_set_statement
>                       | show_statement
>                       | help_statement
>                       | control_statement
> 
> compound_statement    :
>                         object_set_statement
>                       | create_statement
> 
> 
> create_statement      : 'create' object_spec [attribute_setter_list]
> 
> set_statement         :
>                         simple_set_statement
>                       | object_set_statement
> 
> show_statement                : 'show' (attribute_name | object_spec)
> 
> simple_set_statement  : 'set' attribute_setter
> 
> object_set_statement  | 'set' object_spec [attribute_setter_list]
> 
> attribute_setter_list : attribute_setter [',' attribute_setter_list]
> 
> attribute_setter      : attribute_name ['='] attribute_value
> 
> object_spec           : 'object' object_type object_name
> 
> object_type           :
>                         'player'
>                       | 'tech'
>                       | 'unit'
>                       | 'nation'
>                       | 'terrain'
>                       | 'government'
>                       | 'citystyle'
>                       | 'building'

My proposal (only to specify tokenization into commands and arguments):

  commands : opt_command cmd_separation commands |

  cmd_separation: ";" | "\n" | "#" string_without_newline "\n"

  opt_command: command | whitespace |

  whitespace:  " " | "\t" | "\n" | "\r" | whitespace whitespace

  command: opt_whitespace command_name arguments

  command_name: identifier

  identifier: "a" | (...) | "z" | "_" | identifier identifier

  opt_whitespace: whitespace |

  arguments: opt_whitespace | whitespace argument arguments

  argument: metanotation | quoted_string

  metanotation: "*" | (...) | identifier

  quoted_string: '"' opt_string_without_quote '"' | quoted_string quoted_string

  opt_string_without_quote: string_without_quote |

  string_without_newline: "a" | (...) |
    string_without_newline string_without_newline
    # must not contain newline, either

  string_without_quote: "a" | (...)
    string_without_quote string_without_quote

-- 
Reinier


[Prev in Thread] Current Thread [Next in Thread]