scanner.l

Sun, 30 Dec 2001 17:09:08 +0000

author
eric
date
Sun, 30 Dec 2001 17:09:08 +0000
changeset 18
3de372e4b230
parent 17
d4699dfddcc0
child 20
a1cd8cb9d09e
permissions
-rw-r--r--

*** empty log message ***

     1 /*
     2 $Id: scanner.l,v 1.10 2001/12/30 09:09:08 eric Exp $
     3 */
     5 %option case-insensitive
     6 %option noyywrap
     8 %{
     9 #include <stdio.h>
    10 #include <string.h>
    11 #include "type.h"
    12 #include "semantics.h"
    13 #include "parser.tab.h"
    15 #ifdef SCANNER_DEBUG
    16 #define LDBG(x) printf x
    17 #else
    18 #define LDBG(x)
    19 #endif
    20 %}
    23 digit [0-9]
    24 alpha [a-zA-Z]
    25 dot [\.]
    27 %%
    29 [\,;{}]		{ return (yytext [0]); }
    30 {dot}{dot}	{ LDBG(("elipsis\n")); return (ELIPSIS); }
    32 {digit}+	{ yylval.integer = atoi (yytext); LDBG(("integer %d\n", yylval.integer)); return (INTEGER); }
    33 {digit}+\.{digit}+ { yylval.fp = atof (yytext); return (FLOAT); }
    35 a		{ yylval.size.width = 8.5 * 25.4;
    36 		  yylval.size.height = 11.0 * 25.4;
    37                   return (PAGE_SIZE); }
    38 b		{ yylval.size.width = 11.0 * 25.4;
    39                   yylval.size.height = 17.0 * 25.4;
    40                   return (PAGE_SIZE); }
    41 c		{ yylval.size.width = 17.0 * 25.4;
    42                   yylval.size.height = 22.0 * 25.4;
    43                   return (PAGE_SIZE); }
    44 d		{ yylval.size.width = 22.0 * 25.4;
    45                   yylval.size.height = 34.0 * 25.4;
    46                   return (PAGE_SIZE); }
    47 e		{ yylval.size.width = 34.0 * 25.4;
    48                    yylval.size.height = 44.0 * 25.4;
    49                   return (PAGE_SIZE); }
    51 all		{ return (ALL); }
    52 bookmark	{ return (BOOKMARK); }
    53 cm		{ return (CM); }
    54 crop		{ return (CROP); }
    55 even		{ return (EVEN); }
    56 file		{ return (FILE_KEYWORD); }
    57 image		{ return (IMAGE); }
    58 images		{ return (IMAGES); }
    59 inch		{ return (INCH); }
    60 input		{ return (INPUT); }
    61 landscape	{ return (LANDSCAPE); }
    62 odd		{ return (ODD); }
    63 output		{ return (OUTPUT); }
    64 page		{ return (PAGE); }
    65 pages		{ return (PAGES); }
    66 portrait	{ return (PORTRAIT) ; }
    67 resolution	{ return (RESOLUTION) ; }
    68 rotate		{ return (ROTATE); }
    69 size		{ return (SIZE); }
    71 \".*\"		{ 
    72                   int len = strlen (yytext) - 2;
    73                   yylval.string = malloc (len + 1);
    74                   memcpy (yylval.string, yytext + 1, len);
    75                   yylval.string [len] = '\0';
    76 		  LDBG (("string \"%s\"\n", yylval.string));
    77                   return (STRING);
    78                 }
    80 [ \t]+		/* whitespace */
    81 \n		{ line++; }
    83 --.*		/* Ada/VHDL style one-line comment */
    84 #.*		/* shell-style one-line comment */
    86 .		{ fprintf (stderr, "Unrecognized character: %s\n", yytext); }
    88 %%