mirror of
git://projects.qi-hardware.com/fped.git
synced 2025-04-21 12:27:27 +03:00
Columns and loops can now be entered in one step as var = val, val, ...
- moved definition of expr_result from expr.c to fpd.y - new header file fpd.h with all the things fpd.l and fpd.y export - edit_var already calls edit_nothing, so there's no need to call it before - added rapid entry option for loops, variables, and columns: var = val, ... git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5459 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
48
expr.c
48
expr.c
@@ -18,6 +18,7 @@
|
||||
#include "error.h"
|
||||
#include "obj.h"
|
||||
#include "unparse.h"
|
||||
#include "fpd.h"
|
||||
#include "expr.h"
|
||||
|
||||
|
||||
@@ -449,13 +450,6 @@ struct expr *new_num(struct num num)
|
||||
/* ----- expression-only parser -------------------------------------------- */
|
||||
|
||||
|
||||
void scan_expr(const char *s);
|
||||
int yyparse(void);
|
||||
|
||||
|
||||
struct expr *expr_result;
|
||||
|
||||
|
||||
struct expr *parse_expr(const char *s)
|
||||
{
|
||||
scan_expr(s);
|
||||
@@ -487,3 +481,43 @@ void free_expr(struct expr *expr)
|
||||
vacate_op(expr);
|
||||
free(expr);
|
||||
}
|
||||
|
||||
|
||||
/* ----- var = value, ... shortcut ----------------------------------------- */
|
||||
|
||||
|
||||
int parse_var(const char *s, const char **id, struct value **values,
|
||||
int max_values)
|
||||
{
|
||||
const struct value *value;
|
||||
int n;
|
||||
|
||||
scan_var(s);
|
||||
if (yyparse())
|
||||
return -1;
|
||||
if (id)
|
||||
*id = var_id;
|
||||
if (values)
|
||||
*values = var_value_list;
|
||||
n = 0;
|
||||
for (value = var_value_list; value; value = value->next)
|
||||
n++;
|
||||
if (max_values == -1 || n <= max_values)
|
||||
return n;
|
||||
free_values(var_value_list, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void free_values(struct value *values, int keep_expr)
|
||||
{
|
||||
struct value *next;
|
||||
|
||||
while (values) {
|
||||
next = values->next;
|
||||
if (!keep_expr)
|
||||
free_expr(values->expr);
|
||||
free(values);
|
||||
values = next;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user