%{
/* $Id: CLTRANS.L 2.4 1995/07/20 11:24:33 leon Exp $
 * Interpreter sekvenc za Cutter Location
 * -*-Mode:C-*-
 */
#include <stdlib.h>

#include <stdio.h>

#include <string.h>


#ifdef __MSDOS__

#  include "cltrans.h"

#  include "cltrans_.h"

#else

#  include "cltrans.h"

#  include "cltrans.tab.h"

#endif

int cllineno = 1;
char cllinebuff[200];
void  clerror(char *s);
int clparse(void);

%}

floatnumber -?(([0-9]+)|([0-9]*\.[0-9]+)([eE][+-]?[0-9]+)?)

%%

\n.*           { 
                   strcpy(cllinebuff, cltext+1);
                   cllineno++; 
                   yyless(1);
               }

\'[^\'\n]*[\'\n] {return STRING; }

[\t ,\n] ;     /* ignore spaces */


                   
\$[\t ]*\n   { cllineno++; } /* join line */
AAXIS        { return AAXIS; }
BAXIS        { return BAXIS; }
CAXIS        { return CAXIS; }
ATANGL       { return ATANGL; }
AUXFUN       { return AUXFUN; }
BORE         { return BORE; }
BOTH         { return BOTH; }
BRKCHP       { return BRKCHP; }
CCLW         { return CCLW; }
CIRCLE       { return MOVARC; } /* synonim */
CLW          { return CLW; }
COOLNT       { return COOLNT; }
CUTCOM       { return CUTCOM; }
CYCLE        { return CYCLE; }
DEEP         { return DEEP; }
DELAY        { return DELAY; }
DRILL        { return DRILL; }
DWELL        { return DWELL; }
END          { return END; }
FACE         { return FACE; }
FEDRAT       { return FEDRAT; }
FINI         { return FINI; }
FLOOD        { return FLOOD; }
FROM         { return FROM; }
GOHOME       { return GOHOME; }
GOTO         { return GOTO; }
HEAD         { return HEAD; }
IN           { return IN; }
INCHES       { return INCHES; }
INCR         { return INCR; }
INSERT       { return INSERT; }
IPM          { return IPM; }
IPR          { return IPR; }
LEFT         { return LEFT; }
LENGTH       { return LENGTH; }
LINTOL       { return LINTOL; }
LOADTL       { return LOADTL; }
MACHIN       { return MACHIN; }
MAIN         { return MAIN; }
MAXRPM       { return MAXRPM; }
MILL         { return MILL; }
MIST         { return MIST; }
MM           { return MM; }
MMPM         { return MMPM; }
MMPR         { return MMPR; }
MODE         { return MODE; }
MOVARC       { return MOVARC; }
MULTAX       { return MULTAX; }
NEXT         { return NEXT; }
OFF          { return OFF; }
OFSTNO       { return OFSTNO; }
ON           { return ON; }
OPSKIP       { return OPSKIP; }
OPSTOP       { return OPSTOP; }
ORIENT       { return ORIENT; }
ORIGIN       { return ORIGIN; }
OSETNO       { return OSETNO; }
PARTNO       { return PARTNO; }
PITCH        { return PITCH; }
PPFUN        { return PPFUN; }
PPRINT       { return PPRINT; }
RANGE        { return RANGE; }
RAPID        { return RAPID; }
RAPTO        { return RAPTO; }
REAM         { return REAM; }
RETURN       { return RETURN; }
REV          { return REV; }
RIGHT        { return RIGHT; }
ROTABL       { return ROTABL; }
RPM          { return RPM; }
SETANG       { return SETANG; }
SETOOL       { return SETOOL; }
SFM          { return SFM; }
SIDE         { return SIDE; }
SMM          { return SMM; }
SPINDL       { return SPINDL; }
STOP         { return STOP; }
TAP          { return TAP; }
THREAD       { return THREAD; }
TRANS        { return TRANS; }
TURN         { return TURN; }
TURRET       { return TURRET; }
UNITS        { return UNITS; } 
XAXIS        { return XAXIS; }
XYPLAN       { return XYPLAN; }
YZPLAN       { return YZPLAN; }
YAXIS        { return YAXIS; }
ZAXIS        { return ZAXIS; }
ZXPLAN       { return ZXPLAN; }
"\'"         { return APOSTROPHE; }
[XYZIJKABR][ \t]*{floatnumber} { 
	switch (yytext[0]) {
	  case 'X': return XCOOR; break;
          case 'Y': return YCOOR; break;
          case 'Z': return ZCOOR; break;
          case 'I': return ICOOR; break;
          case 'J': return JCOOR; break;
          case 'K': return KCOOR; break;
          case 'A': return ACOOR; break;
          case 'B': return BCOOR; break;
          case 'R': return RCOOR; break;
	}
     }
\/           {return SLASH; }

{floatnumber} { return NUM; }

[A-Za-z][A-Za-z0-9_]* { return NAME; }
%%

yywrap()
{ 
  return 1; 
}

#ifdef CMDLINE


FILE *outf;

main(int argc, char *argv[])
{
    if (argc > 1 && (yyin = fopen(argv[1], "r")) == NULL) 
      {
         perror(argv[1]);
         return 1;
      }

    outf = stdout;
    if (!clparse())
	{
	  extern float MinP[3], MaxP[3];
          fprintf(stderr, "CL data OK\n");
	  fprintf(stderr, "Minimalne  koordinate: X%.2f Y%.2f Z%.2f\n"
			  "Maksimalne koordinate: X%.2f Y%.2f Z%.2f\n",
			MinP[0], MinP[1], MinP[2],
			MaxP[0], MaxP[1], MaxP[2]);
	}
    else
          fprintf(stderr, "CL data NOT OK\n");
    
    return 0;
}

#endif /* CMDLINE */




syntax highlighted by Code2HTML, v. 0.9.1