scanner.l

Mon, 31 Dec 2001 07:25:08 +0000

author
eric
date
Mon, 31 Dec 2001 07:25:08 +0000
changeset 20
a1cd8cb9d09e
parent 18
3de372e4b230
child 27
7a28031fe457
permissions
-rw-r--r--

*** empty log message ***

     1 /*
     2 $Id: scanner.l,v 1.11 2001/12/30 23:25: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 format		{ return (FORMAT); }
    58 image		{ return (IMAGE); }
    59 images		{ return (IMAGES); }
    60 inch		{ return (INCH); }
    61 input		{ return (INPUT); }
    62 landscape	{ return (LANDSCAPE); }
    63 odd		{ return (ODD); }
    64 output		{ return (OUTPUT); }
    65 page		{ return (PAGE); }
    66 pages		{ return (PAGES); }
    67 portrait	{ return (PORTRAIT) ; }
    68 resolution	{ return (RESOLUTION) ; }
    69 rotate		{ return (ROTATE); }
    70 size		{ return (SIZE); }
    72 \"[^\n"]*\"		{ 
    73                   int len = strlen (yytext) - 2;
    74                   yylval.string = malloc (len + 1);
    75                   memcpy (yylval.string, yytext + 1, len);
    76                   yylval.string [len] = '\0';
    77 		  LDBG (("string \"%s\"\n", yylval.string));
    78                   return (STRING);
    79                 }
    81 [ \t]+		/* whitespace */
    82 \n		{ line++; }
    84 --.*		/* Ada/VHDL style one-line comment */
    85 #.*		/* shell-style one-line comment */
    87 .		{ fprintf (stderr, "Unrecognized character: %s\n", yytext); }
    89 %%