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:
13
cameo/lang.l
13
cameo/lang.l
@@ -24,9 +24,6 @@ static int lineno = 1;
|
||||
static int metric = 1;
|
||||
static int file_name_follows = 0;
|
||||
|
||||
|
||||
#define MIL2MM(mil) ((mil)/1000*25.4)
|
||||
|
||||
%}
|
||||
|
||||
/* file name can contain any characters */
|
||||
@@ -69,17 +66,15 @@ NUM -?[0-9]+\.?[0-9]*
|
||||
{NUM}mm { yylval.num = strtod(yytext, NULL);
|
||||
if (file_name_follows)
|
||||
BEGIN(FILENAME);
|
||||
return NUMBER; }
|
||||
{NUM}mil { yylval.num = MIL2MM(strtod(yytext, NULL));
|
||||
return NUM_EXP_MM; }
|
||||
{NUM}mil { yylval.num = strtod(yytext, NULL);
|
||||
if (file_name_follows)
|
||||
BEGIN(FILENAME);
|
||||
return NUMBER; }
|
||||
return NUM_EXP_MIL; }
|
||||
{NUM} { yylval.num = strtod(yytext, NULL);
|
||||
if (!metric)
|
||||
yylval.num = MIL2MM(yylval.num);
|
||||
if (file_name_follows)
|
||||
BEGIN(FILENAME);
|
||||
return NUMBER; }
|
||||
return metric ? NUM_IMP_MM : NUM_IMP_MIL; }
|
||||
|
||||
<FILENAME>[^ \t\n]+([^\t\n]*[^ \t\n]+)? {
|
||||
BEGIN(INITIAL);
|
||||
|
||||
Reference in New Issue
Block a user