scanner.l

Sun, 30 Dec 2001 16:29:50 +0000

author
eric
date
Sun, 30 Dec 2001 16:29:50 +0000
changeset 17
d4699dfddcc0
parent 15
dda3d673b82b
child 18
3de372e4b230
permissions
-rw-r--r--

*** empty log message ***

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