scanner.l

Mon, 26 Aug 2002 05:43:49 +0000

author
eric
date
Mon, 26 Aug 2002 05:43:49 +0000
changeset 47
bfc6aaa089b0
parent 34
8d7bd2fa5db6
child 48
3d0be1c1c1b2
permissions
-rw-r--r--

fixed 'middle-endian' output from TIFFReadScanline

eric@12 1 /*
eric@34 2 $Id: scanner.l,v 1.15 2002/01/02 02:17:24 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@15 11 #include "type.h"
eric@17 12 #include "semantics.h"
eric@18 13 #include "parser.tab.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@34 32 /* decimal integer */
eric@15 33 {digit}+ { yylval.integer = atoi (yytext); LDBG(("integer %d\n", yylval.integer)); return (INTEGER); }
eric@34 34
eric@34 35 /* floating point number - tricky to make sure it doesn't grab an integer
eric@34 36 followed by an elipsis */
eric@34 37 -?{digit}+\.{digit}+ { yylval.fp = atof (yytext); return (FLOAT); }
eric@34 38 -?{digit}+\./[^.] { yylval.fp = atof (yytext); return (FLOAT); }
eric@9 39
eric@32 40 a { yylval.size.width = 8.5;
eric@32 41 yylval.size.height = 11.0;
eric@9 42 return (PAGE_SIZE); }
eric@32 43 b { yylval.size.width = 11.0;
eric@32 44 yylval.size.height = 17.0;
eric@9 45 return (PAGE_SIZE); }
eric@32 46 c { yylval.size.width = 17.0;
eric@32 47 yylval.size.height = 22.0;
eric@9 48 return (PAGE_SIZE); }
eric@32 49 d { yylval.size.width = 22.0;
eric@32 50 yylval.size.height = 34.0;
eric@9 51 return (PAGE_SIZE); }
eric@32 52 e { yylval.size.width = 34.0;
eric@32 53 yylval.size.height = 44.0;
eric@9 54 return (PAGE_SIZE); }
eric@5 55
eric@5 56 all { return (ALL); }
eric@30 57 author { return (AUTHOR); }
eric@5 58 bookmark { return (BOOKMARK); }
eric@9 59 cm { return (CM); }
eric@30 60 creator { return (CREATOR); }
eric@5 61 crop { return (CROP); }
eric@5 62 even { return (EVEN); }
eric@11 63 file { return (FILE_KEYWORD); }
eric@5 64 image { return (IMAGE); }
eric@9 65 images { return (IMAGES); }
eric@9 66 inch { return (INCH); }
eric@5 67 input { return (INPUT); }
eric@30 68 keywords { return (KEYWORDS); }
eric@27 69 label { return (LABEL); }
eric@9 70 landscape { return (LANDSCAPE); }
eric@5 71 odd { return (ODD); }
eric@5 72 output { return (OUTPUT); }
eric@5 73 page { return (PAGE); }
eric@8 74 pages { return (PAGES); }
eric@9 75 portrait { return (PORTRAIT) ; }
eric@11 76 resolution { return (RESOLUTION) ; }
eric@5 77 rotate { return (ROTATE); }
eric@5 78 size { return (SIZE); }
eric@30 79 subject { return (SUBJECT); }
eric@30 80 title { return (TITLE); }
eric@5 81
eric@27 82 '[^\n']' {
eric@27 83 yylval.character = yytext [1];
eric@27 84 return (CHARACTER);
eric@27 85 }
eric@27 86
eric@27 87 \"[^\n"]*\" {
eric@15 88 int len = strlen (yytext) - 2;
eric@15 89 yylval.string = malloc (len + 1);
eric@15 90 memcpy (yylval.string, yytext + 1, len);
eric@15 91 yylval.string [len] = '\0';
eric@15 92 LDBG (("string \"%s\"\n", yylval.string));
eric@15 93 return (STRING);
eric@15 94 }
eric@9 95
eric@15 96 [ \t]+ /* whitespace */
eric@15 97 \n { line++; }
eric@9 98
eric@9 99 --.* /* Ada/VHDL style one-line comment */
eric@15 100 #.* /* shell-style one-line comment */
eric@9 101
eric@15 102 . { fprintf (stderr, "Unrecognized character: %s\n", yytext); }
eric@9 103
eric@12 104 %%