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