[GRASS5] r.mapcalc problem
Glynn Clements
glynn.clements at virgin.net
Thu Apr 22 08:27:26 EDT 2004
Hamish wrote:
> I'm trying to use r.mapcalc from the command line, with a map name which
> contains a dash ("-"). I'm getting this error:
>
> GRASS5.3> r.mapcalc \"a-b\"=1
> invalid map: a-b
> syntax error, unexpected '=', expecting $end
> Parse error
>
> The "invalid map" above doesn't exist yet, if I make something called
> 'a-b', the invalid map error disappears but the syntax/parse errors
> remain.
>
> does anyone know where I'm going wrong, or is this a r.mapcalc bug?
It's a mapcalc limitation. The documentation isn't clear on whether
this is meant to work.
> If I understand correctly, quoted map names containing operators should
> be ok on both sides of the equation..
I don't know whether they "should" be OK, but they aren't.
Currently, the LHS of an assignment has to be a NAME or VARNAME, both
of which are defined by the regexp:
[^ ^#@,"'\000-\037()\[\]+\-*/%><!=&|?:;]+
[The difference is that a VARNAME has already occurred as the LHS of a
previous assignment, whereas a NAME hasn't.]
The syntax for map names where they occur as values (i.e. other than
on the LHS of an assignment) is more general:
map : STRING
| NAME
| NAME '@' NAME { $$ = composite($1,$3); }
;
[STRING is an arbitrary quoted string.]
The attached patch will allow quoted strings to occur on the LHS of an
assigmnent (at least from the perspective of the parser; there may be
other factors which I've overlooked).
More generally, I think that we should reconsider the behaviour of
assignment. Currently, the semantics are far from clear.
At a minimum, we should probably refactor the grammar, so that
top-level assignments (i.e. map creation) are handled separately to
variable assignments.
--
Glynn Clements <glynn.clements at virgin.net>
-------------- next part --------------
--- src/raster/r.mapcalc3/mapcalc.y~ Thu Apr 22 12:59:37 2004
+++ src/raster/r.mapcalc3/mapcalc.y Thu Apr 22 13:12:54 2004
@@ -171,6 +171,7 @@
define_variable($$); }
| VARNAME '=' exp_let { $$ = binding($1,$3);
define_variable($$); }
+ | STRING '=' exp_let { $$ = binding($1,$3); }
;
exp : exp_let
More information about the grass-dev
mailing list