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.

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