home *** CD-ROM | disk | FTP | other *** search
Lex Description | 1989-07-16 | 3.2 KB | 114 lines |
- %{
- /*****************************************************************\
- * FILE: hpgl.l part of hpgl to X windows *
- * *
- * Written by Randy L. Yach aid by Jackie Harrison *
- * *
- * Description: *
- * this is the lexical analizer of HPGL syntax. All action *
- * tokens are covered first. *
- \*****************************************************************/
-
- #include <stdio.h>
- #include "y.tab.h"
- #include <X/Xlib.h>
-
- #ifdef ULTRIX
- # include <math.h>
- #endif
-
- /* need this because the sun 386i has a funny location of the atof
- definition */
-
- #ifdef UI38
- # include <floatingpoint.h>
- #endif
-
- /* need this to keep count of the input lines for error messages */
- int hline = 1;
- %}
- D [0-9]
- R [0-9\.]
- A [A-Z]
- LBL [a-z\-\, \.A-Z0-9\:\;\(\)\&\^\%\$\#\@\!\"\'\~\`|?\/\<\>\_]
- DOT [\.]
- COMMA [\,]
- ALT [A-Z\(\)\@]
- G [A-Z0-9\;]
- %%
- LT {
- return(LT);
- }
- LB{LBL}*\ {
- /* strip off the LB and the ending ^C
- from the input line and return it */
- strcpy(yylval.sb,&yytext[2]);
- yylval.sb[strlen(yylval.sb)-1] = '\0';
- return(LB);
- }
- SC {
- return(SC);
- }
- SP{D} {
- /* return the pen number */
- yylval.i = yytext[2] - '0';
- return(SP);
- }
- PA {
- return(PA);
- }
- PR {
- return(PR);
- }
- PU {
- return(PU);
- }
- PD {
- return(PD);
- }
- \-?{D}+ {
- /* integer digit routine */
- yylval.i = atoi(yytext);
- return(DIGIT);
- }
- \-?{R}+ {
- /* real digit routine */
- yylval.f = atof(yytext);
- return(NUMBER);
- }
- \; {
- return(SEMICOLON);
- }
- \, {
- return(COMMA);
- }
- IN\; return(RESET);
- DF\; return(RESET);
- [ \t]* ;
- [\n] {
- hline++;
- }
- \{DOT}{ALT}({G}+\:)? ;
- C{A}{D}*({COMMA}{D}*)?\; ;
- DI{D}*({COMMA}{D}*)?\; ;
- DR{D}*({COMMA}{D}*)?\; ;
- DT{A}\; ;
- DC\; ;
- DP\; ;
- O{A}\; ;
- IM{D}*({COMMA}{D}*)*\; ;
- IP{D}*({COMMA}{D}*)*\; ;
- IW{D}*({COMMA}{D}*)*\; ;
- SA\; ;
- SI{D}*{COMMA}{D}*\; ;
- SL{D}*\; ;
- SM{A}\; ;
- SR{R}*{COMMA}{R}*\; ;
- SS\; ;
- SA\; ;
- TL{D}*({COMMA}{D}+)?\; ;
- VS{D}*\; ;
- XT\; ;
- YT\; ;
- %%
-