scanner.l

Tue, 01 Jan 2002 10:16:50 +0000

author
eric
date
Tue, 01 Jan 2002 10:16:50 +0000
changeset 32
3aac131058da
parent 30
35fad7ec7732
child 34
8d7bd2fa5db6
permissions
-rw-r--r--

added start of page size support.

     1 /*
     2 $Id: scanner.l,v 1.14 2002/01/01 02:16:50 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;
    36 		  yylval.size.height = 11.0;
    37                   return (PAGE_SIZE); }
    38 b		{ yylval.size.width = 11.0;
    39                   yylval.size.height = 17.0;
    40                   return (PAGE_SIZE); }
    41 c		{ yylval.size.width = 17.0;
    42                   yylval.size.height = 22.0;
    43                   return (PAGE_SIZE); }
    44 d		{ yylval.size.width = 22.0;
    45                   yylval.size.height = 34.0;
    46                   return (PAGE_SIZE); }
    47 e		{ yylval.size.width = 34.0;
    48                    yylval.size.height = 44.0;
    49                   return (PAGE_SIZE); }
    51 all		{ return (ALL); }
    52 author		{ return (AUTHOR); }
    53 bookmark	{ return (BOOKMARK); }
    54 cm		{ return (CM); }
    55 creator		{ return (CREATOR); }
    56 crop		{ return (CROP); }
    57 even		{ return (EVEN); }
    58 file		{ return (FILE_KEYWORD); }
    59 image		{ return (IMAGE); }
    60 images		{ return (IMAGES); }
    61 inch		{ return (INCH); }
    62 input		{ return (INPUT); }
    63 keywords	{ return (KEYWORDS); }
    64 label		{ return (LABEL); }
    65 landscape	{ return (LANDSCAPE); }
    66 odd		{ return (ODD); }
    67 output		{ return (OUTPUT); }
    68 page		{ return (PAGE); }
    69 pages		{ return (PAGES); }
    70 portrait	{ return (PORTRAIT) ; }
    71 resolution	{ return (RESOLUTION) ; }
    72 rotate		{ return (ROTATE); }
    73 size		{ return (SIZE); }
    74 subject		{ return (SUBJECT); }
    75 title		{ return (TITLE); }
    77 '[^\n']'	{
    78 		  yylval.character = yytext [1];
    79 		  return (CHARACTER);
    80 		}
    82 \"[^\n"]*\"	{
    83                   int len = strlen (yytext) - 2;
    84                   yylval.string = malloc (len + 1);
    85                   memcpy (yylval.string, yytext + 1, len);
    86                   yylval.string [len] = '\0';
    87 		  LDBG (("string \"%s\"\n", yylval.string));
    88                   return (STRING);
    89                 }
    91 [ \t]+		/* whitespace */
    92 \n		{ line++; }
    94 --.*		/* Ada/VHDL style one-line comment */
    95 #.*		/* shell-style one-line comment */
    97 .		{ fprintf (stderr, "Unrecognized character: %s\n", yytext); }
    99 %%