diff --git a/cameo/README b/cameo/README index 638f33c..73b41db 100644 --- a/cameo/README +++ b/cameo/README @@ -73,7 +73,7 @@ Horizontal adjustments: Vertical adjustment: - z [] + z [] Tool compensation: diff --git a/cameo/lang.l b/cameo/lang.l index 0a1b665..7c0cd78 100644 --- a/cameo/lang.l +++ b/cameo/lang.l @@ -22,6 +22,8 @@ void yyerror(const char *s); static int lineno = 1; static int metric = 1; +static int file_name_follows = 0; + #define MIL2MM(mil) ((mil)/1000*25.4) @@ -34,7 +36,7 @@ static int metric = 1; conversion */ %s DIGIT -NUM [0-9]+\.?[0-9]* +NUM -?[0-9]+\.?[0-9]* %% @@ -48,9 +50,9 @@ NUM [0-9]+\.?[0-9]* translate return TOK_TRANSLATE; z return TOK_Z; -gerber { BEGIN(FILENAME); +gerber { file_name_follows = 1; return TOK_GERBER; } -gnuplot { BEGIN(FILENAME); +gnuplot { file_name_follows = 1; return TOK_GNUPLOT; } write { BEGIN(FILENAME); return TOK_WRITE; } @@ -60,30 +62,39 @@ NUM [0-9]+\.?[0-9]* mm metric = 1; mil metric = 0; -{NUM}mm { yylval.num = strtod(yytext, NULL); +[1-9] { BEGIN(INITIAL); + yylval.num = strtod(yytext, NULL); + return REF; } + +{NUM}mm { yylval.num = strtod(yytext, NULL); + if (file_name_follows) + BEGIN(FILENAME); return NUMBER; } -{NUM}mil { yylval.num = MIL2MM(strtod(yytext, NULL)); +{NUM}mil { yylval.num = MIL2MM(strtod(yytext, NULL)); + if (file_name_follows) + BEGIN(FILENAME); return NUMBER; } -{NUM} { yylval.num = strtod(yytext, NULL); +{NUM} { yylval.num = strtod(yytext, NULL); if (!metric) yylval.num = MIL2MM(yylval.num); + if (file_name_follows) + BEGIN(FILENAME); return NUMBER; } [^ \t\n]+([^\t\n]*[^ \t\n]+)? { BEGIN(INITIAL); + file_name_follows = 0; yylval.str = yytext; return STRING; } -[1-9] { BEGIN(INITIAL); - yylval.num = strtod(yytext, NULL); - return NUMBER; } - [ \t] ; \n lineno++; ^#\ [0-9]+\ \"[^"]*\"(\ [0-9]+)*\n { lineno = strtol(yytext+2, NULL, 0); } +#.*\n lineno++; + . return *yytext; %% diff --git a/cameo/lang.y b/cameo/lang.y index ca834e5..0158c2e 100644 --- a/cameo/lang.y +++ b/cameo/lang.y @@ -118,7 +118,7 @@ static void align(int ref, double x, double y) %token TOK_GERBER TOK_GNUPLOT TOK_WRITE %token TOK_DOG -%token NUMBER +%token NUMBER REF %token STRING %type opt_filename @@ -130,11 +130,11 @@ all: ; command: - TOK_ALIGN NUMBER NUMBER NUMBER + TOK_ALIGN REF NUMBER NUMBER { align((int) $2, $3, $4); } - | TOK_ALIGN NUMBER NUMBER NUMBER NUMBER NUMBER + | TOK_ALIGN REF NUMBER NUMBER NUMBER NUMBER { int ref = $2; double x, y; @@ -179,11 +179,11 @@ command: } | TOK_Z NUMBER { - zo -= $2; + zo += $2; } | TOK_Z NUMBER NUMBER { - zo -= $2+$3; + zo += $3-$2; } | TOK_GERBER NUMBER opt_filename {