Commit 89b6d3b9 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

expr: added function print()

parent fc8b5056
......@@ -1334,6 +1334,18 @@ nodeType *expr_run(nodeType *p, parse_param_t *parse_arg)
params[varID].remove = true;
}
}
else
{
if ( strcmp(cname, "print") == 0 )
{
size_t ngp = params[varID].ngp;
size_t nlev = params[varID].nlev;
const double *data = params[varID].data;
for ( size_t k = 0; k < nlev; ++k )
for ( size_t i = 0; i < ngp; ++i )
fprintf(stdout, " %s[lev=%zu:gp=%zu] = %g\n", vname, k+1, i+1, data[k*ngp+i]);
}
}
break;
}
......
This diff is collapsed.
......@@ -58,6 +58,8 @@ M_E {
"remove(" { return REMOVE; }
"print(" { return PRINT; }
{LPH}{LPHDGT}*/[ ]*\( {
yylval->fname = strdup(yytext);
return FUNCTION;
......
This diff is collapsed.
......@@ -49,16 +49,17 @@ extern int yydebug;
VARIABLE = 259,
FUNCTION = 260,
REMOVE = 261,
AND = 262,
OR = 263,
LEG = 264,
GE = 265,
LE = 266,
EQ = 267,
NE = 268,
GT = 269,
LT = 270,
UMINUS = 271
PRINT = 262,
AND = 263,
OR = 264,
LEG = 265,
GE = 266,
LE = 267,
EQ = 268,
NE = 269,
GT = 270,
LT = 271,
UMINUS = 272
};
#endif
/* Tokens. */
......@@ -66,16 +67,17 @@ extern int yydebug;
#define VARIABLE 259
#define FUNCTION 260
#define REMOVE 261
#define AND 262
#define OR 263
#define LEG 264
#define GE 265
#define LE 266
#define EQ 267
#define NE 268
#define GT 269
#define LT 270
#define UMINUS 271
#define PRINT 262
#define AND 263
#define OR 264
#define LEG 265
#define GE 266
#define LE 267
#define EQ 268
#define NE 269
#define GT 270
#define LT 271
#define UMINUS 272
/* Value type. */
......
......@@ -40,6 +40,7 @@ void freeNode(nodeType *p);
%token <varnm> VARIABLE
%token <fname> FUNCTION
%token REMOVE
%token PRINT
%left AND OR
%left LEG GE LE EQ NE GT LT
......@@ -68,6 +69,7 @@ stmt:
| VARIABLE '=' expr ';' { $$ = expr_opr('=', 2, expr_var($1), $3); }
| VARIABLE ';' { $$ = expr_opr('=', 2, expr_var($1), expr_var($1)); } /* conflicts: 1 shift/reduce */
| REMOVE VARIABLE ')' ';' { $$ = expr_com("remove", $2); }
| PRINT VARIABLE ')' ';' { $$ = expr_com("print", $2); }
| '{' stmt_list '}' { $$ = $2; }
;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment