Skip to content
Snippets Groups Projects
Commit fdedff43 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

added support for empty lists (aa[] = {};) and concatenation of lists
(aa[] += {1,2,3};)
parent 117f9f48
No related branches found
No related tags found
No related merge requests found
Source diff could not be displayed: it is too large. Options to address this: view the blob.
%{
// $Id: Gmsh.y,v 1.219 2006-01-29 19:06:36 geuzaine Exp $
// $Id: Gmsh.y,v 1.220 2006-02-17 14:35:06 geuzaine Exp $
//
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
//
......@@ -689,6 +689,24 @@ Affectation :
}
List_Delete($5);
}
| tSTRING '[' ']' tAFFECTPLUS ListOfDouble tEND
{
// appends to the list
Symbol TheSymbol;
TheSymbol.Name = $1;
Symbol *pSymbol;
if(!(pSymbol = (Symbol*)Tree_PQuery(Symbol_T, &TheSymbol))){
TheSymbol.val = List_Create(5, 5, sizeof(double));
List_Copy($5, TheSymbol.val);
Tree_Add(Symbol_T, &TheSymbol);
}
else{
for(int i = 0; i < List_Nbr($5); i++)
List_Add(pSymbol->val, List_Pointer($5, i));
Free($1);
}
List_Delete($5);
}
| tSTRING NumericIncrement tEND
{
Symbol TheSymbol;
......@@ -2890,6 +2908,11 @@ ListOfDouble :
{
$$ = $1;
}
| '{' '}'
{
// creates an empty list
$$ = List_Create(2, 1, sizeof(double));
}
| '{' RecursiveListOfDouble '}'
{
$$ = $2;
......
......@@ -2,7 +2,7 @@
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
* $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.254 2006-02-15 15:06:27 geuzaine Exp $
* $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.255 2006-02-17 14:35:06 geuzaine Exp $
*/
#define FLEX_SCANNER
......@@ -727,7 +727,7 @@ char *yytext;
#line 1 "Gmsh.l"
#define INITIAL 0
#line 2 "Gmsh.l"
// $Id: Gmsh.yy.cpp,v 1.254 2006-02-15 15:06:27 geuzaine Exp $
// $Id: Gmsh.yy.cpp,v 1.255 2006-02-17 14:35:06 geuzaine Exp $
//
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
//
......
// this is optional: you can actually append to a non-existent list:
// it will create a new list
aa[] = {}; Printf("aa size = %g", #aa[]);
aa[] += 0; Printf("aa size = %g", #aa[]);
aa[] += {1,2,3}; Printf("aa size = %g", #aa[]);
// this does not append: it adds the items in aa[] to the items
// indexed by aa[]!
aa[{aa[]}] += aa[]; Printf("aa size = %g", #aa[]);
// this appends aa[] to itself
aa[] += aa[]; Printf("aa size = %g", #aa[]);
For i In {1 : #aa[]}
Printf("aa[%g] = %g", i-1, aa[i-1]);
EndFor
\input texinfo.tex @c -*-texinfo-*-
@c $Id: gmsh.texi,v 1.199 2006-02-15 15:06:27 geuzaine Exp $
@c $Id: gmsh.texi,v 1.200 2006-02-17 14:35:07 geuzaine Exp $
@c
@c Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
@c
......@@ -1140,7 +1140,7 @@ The following commands can be used anywhere in a Gmsh ASCII text input file:
@ftable @code
@item @var{string} = @var{expression};
Defines a new expression identifier @var{string}, or affects
Creates a new expression identifier @var{string}, or affects
@var{expression} to an existing expression identifier. Eleven expression
identifiers are predefined (hardcoded in Gmsh's parser):
......@@ -1196,17 +1196,23 @@ of @code{newl}, @code{news}, @code{newv} and @code{newreg} can be modified
with the @code{Geometry.OldNewReg} option (@pxref{Geometry options}).}.
@end ftable
@item @var{string} [ ] = @{ @};
Creates a new expression list identifier @code{@var{string}[]} with an
empty list.
@item @var{string} [ ] = @{ @var{expression-list} @};
Defines a new expression list identifier @code{@var{string}[]}, or affects
@var{expression-list} to an existing expression list identifier.
Creates a new expression list identifier @code{@var{string}[]} with the
list @var{expression-list}, or affects @var{expression-list} to an
existing expression list identifier. (Remember the remark we made when
we defined @w{@var{expression-list}s}: the braces enclosing an
@var{expression-list} are optional if the list only contains a single
item.)
@item @var{string} [ @{ @var{expression-list} @} ] = @{ @var{expression-list} @};
Affects each item in the right hand side @var{expression-list} to the
elements (indexed by the left hand side @var{expression-list}) of an
existing expression list identifier. The two @w{@var{expression-list}s} must
contain the same number of items. Remember the remark made when defining
@w{@var{expression-list}s}: the braces enclosing an @var{expression-list}
are optional if the list only contains a single item.
contain the same number of items.
@item @var{real-option} = @var{expression};
Affects @var{expression} to a real option.
......@@ -1233,6 +1239,10 @@ or to a real option.
Divides and affects @var{expression} to an existing expression identifier
or to a real option.
@item @var{string} [ ] += @{ @var{expression-list} @};
Appends @var{expression-list} to an existing expression list or creates
a new expression list with @var{expression-list}).
@item @var{string} [ @{ @var{expression-list} @} ] += @{ @var{expression-list} @};
Adds and affects, item per item, the right hand side @var{expression-list}
to an existing expression list identifier.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment