mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2025-04-21 12:27:27 +03:00
cameo: split numbers into dimensions and "bare" numbers
- lang.l, lang.y (MIL2MM): moved unit conversion from lang.l to lang.y - lang.l, lang.y: instead of returning dimensions and numbers as NUMBER, return as NUM_EXP_<unit> for numbers with an explicit unit, and as NUM_IMP_<unit> if the unit is implied - lang.y (dimen): perform unit conversion as needed - lang.y (number): never convert and only accept implicit dimensions - lang.y: change all uses of NUMBER to "dimen", except for the multipliers in "array", where we can now use "number" - lang.y: removed comment about "array" only working in metric mode
This commit is contained in:
53
cameo/lang.y
53
cameo/lang.y
@@ -26,6 +26,9 @@ static double xo = 0, yo = 0, zo = 0;
|
||||
static struct path *paths = NULL;
|
||||
|
||||
|
||||
#define MIL2MM(mil) ((mil)/1000*25.4)
|
||||
|
||||
|
||||
static void add_paths(struct path *new)
|
||||
{
|
||||
struct path **anchor = &paths;
|
||||
@@ -118,10 +121,11 @@ static void align(int ref, double x, double y)
|
||||
%token TOK_GERBER TOK_GNUPLOT TOK_WRITE
|
||||
%token TOK_DOG
|
||||
|
||||
%token <num> NUMBER REF
|
||||
%token <num> NUM_EXP_MIL NUM_EXP_MM NUM_IMP_MIL NUM_IMP_MM REF
|
||||
%token <str> STRING
|
||||
|
||||
%type <str> opt_filename
|
||||
%type <num> dimen number
|
||||
|
||||
%%
|
||||
|
||||
@@ -130,11 +134,11 @@ all:
|
||||
;
|
||||
|
||||
command:
|
||||
TOK_ALIGN REF NUMBER NUMBER
|
||||
TOK_ALIGN REF dimen dimen
|
||||
{
|
||||
align((int) $2, $3, $4);
|
||||
}
|
||||
| TOK_ALIGN REF NUMBER NUMBER NUMBER NUMBER
|
||||
| TOK_ALIGN REF dimen dimen dimen dimen
|
||||
{
|
||||
int ref = $2;
|
||||
double x, y;
|
||||
@@ -147,12 +151,11 @@ command:
|
||||
ref_pick_xy(ref, $3, $4, $5, $6, &x, &y);
|
||||
align(ref, x, y);
|
||||
}
|
||||
| TOK_ARRAY NUMBER NUMBER NUMBER NUMBER
|
||||
| TOK_ARRAY dimen dimen number number
|
||||
{
|
||||
double x = $2*$4;
|
||||
double y = $3*$5;
|
||||
|
||||
/* @@@ known bug: doesn't work if not in metric mode */
|
||||
translate(x, y, 0);
|
||||
}
|
||||
| TOK_CLEAR
|
||||
@@ -177,26 +180,26 @@ command:
|
||||
{
|
||||
tool_comp_paths(paths, 1);
|
||||
}
|
||||
| TOK_TRANSLATE NUMBER NUMBER
|
||||
| TOK_TRANSLATE dimen dimen
|
||||
{
|
||||
translate($2, $3, 0);
|
||||
xo += $2;
|
||||
yo += $3;
|
||||
}
|
||||
| TOK_Z NUMBER
|
||||
| TOK_Z dimen
|
||||
{
|
||||
zo += $2;
|
||||
}
|
||||
| TOK_Z NUMBER NUMBER
|
||||
| TOK_Z dimen dimen
|
||||
{
|
||||
zo += $3-$2;
|
||||
}
|
||||
| TOK_GERBER NUMBER opt_filename
|
||||
| TOK_GERBER dimen opt_filename
|
||||
{
|
||||
add_paths(gerber_read($3, $2/2));
|
||||
translate(xo, yo, 0);
|
||||
}
|
||||
| TOK_GNUPLOT NUMBER opt_filename
|
||||
| TOK_GNUPLOT dimen opt_filename
|
||||
{
|
||||
add_paths(gnuplot_read($3, $2/2));
|
||||
translate(xo, yo, 0);
|
||||
@@ -218,3 +221,33 @@ opt_filename:
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
dimen:
|
||||
NUM_EXP_MM
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
| NUM_IMP_MM
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
| NUM_EXP_MIL
|
||||
{
|
||||
$$ = MIL2MM($1);
|
||||
}
|
||||
| NUM_IMP_MIL
|
||||
{
|
||||
$$ = MIL2MM($1);
|
||||
}
|
||||
;
|
||||
|
||||
number:
|
||||
NUM_IMP_MIL
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
| NUM_IMP_MM
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user