1 %{ 2 /*****************************************************************************/ 3 /** Copyright 1988 by Evans & Sutherland Computer Corporation, **/ 4 /** Salt Lake City, Utah **/ 5 /** Portions Copyright 1989 by the Massachusetts Institute of Technology **/ 6 /** Cambridge, Massachusetts **/ 7 /** **/ 8 /** All Rights Reserved **/ 9 /** **/ 10 /** Permission to use, copy, modify, and distribute this software and **/ 11 /** its documentation for any purpose and without fee is hereby **/ 12 /** granted, provided that the above copyright notice appear in all **/ 13 /** copies and that both that copyright notice and this permis- **/ 14 /** sion notice appear in supporting documentation, and that the **/ 15 /** names of Evans & Sutherland and M.I.T. not be used in advertising **/ 16 /** in publicity pertaining to distribution of the software without **/ 17 /** specific, written prior permission. **/ 18 /** **/ 19 /** EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD **/ 20 /** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ 21 /** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND OR **/ 22 /** M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/ 23 /** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ 24 /** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ 25 /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ 26 /** OR PERFORMANCE OF THIS SOFTWARE. **/ 27 /*****************************************************************************/ 28 29 /*********************************************************************** 30 * 31 * $XConsortium: lex.l,v 1.62 89/12/10 17:46:33 jim Exp $ 32 * 33 * .twmrc lex file 34 * 35 * 12-Nov-87 Thomas E. LaStrange File created 36 * 37 ***********************************************************************/ 38 39 /* #include <stdio.h> */ /* lex already includes stdio.h */ 40 #include "gram.h" 41 #include "parse.h" 42 #include "twm.h" 43 #include "screen.h" 44 #include "prototypes.h" 45 46 extern char *ProgramName; 47 extern int ParseError; 48 49 int rclineno = 1; 50 51 #ifdef FLEX_SCANNER 52 static int yyget_lineno (void); 53 static FILE *yyget_in (void); 54 static FILE *yyget_out (void); 55 static char *yyget_text (void); 56 static void yyset_lineno (int line_number ); 57 static void yyset_in (FILE * in_str ); 58 static void yyset_out (FILE * out_str ); 59 static int yyget_debug (void); 60 static void yyset_debug (int bdebug ); 61 static int yylex_destroy (void); 62 63 #undef YY_INPUT 64 #define YY_INPUT(b,r,s) r = ((b[0] = (*twmInputFunc)()) != 0) 65 #endif 66 %} 67 68 string \"([^"]|\\.)*\" 69 regexp \/([^/]|\\.)*\/ 70 number [0-9]+ 71 %% 72 "{" { return (LB); } 73 "}" { return (RB); } 74 "(" { return (LP); } 75 ")" { return (RP); } 76 "=" { return (EQUALS); } 77 "~" { return (TILDE); } 78 ":" { return (COLON); } 79 "+" { return PLUS; } 80 "-" { return MINUS; } 81 "|" { return OR; } 82 83 [a-zA-Z\.]+ { int token = parse_keyword (yytext, 84 &yylval.num); 85 if (token == ERRORTOKEN) { 86 twmrc_error_prefix(); 87 fprintf (stderr, 88 "ignoring unknown keyword: %s\n", 89 yytext); 90 ParseError = 1; 91 } else 92 return token; 93 } 94 95 "!" { yylval.num = F_EXEC; return FSKEYWORD; } 96 "^" { yylval.num = F_CUT; return FSKEYWORD; } 97 98 {string} { yylval.ptr = (char *)yytext; return STRING; } 99 {regexp} { yylval.ptr = (char *)yytext; return REGEXP; } 100 {number} { (void)sscanf((char *)&yytext[0], "%d", &yylval.num); 101 return (NUMBER); 102 } 103 \#[^\n]*\n {++rclineno;} 104 \n {++rclineno;} 105 [\t ] {;} 106 . { 107 twmrc_error_prefix(); 108 fprintf (stderr, 109 "ignoring character \"%s\"\n", 110 yytext); 111 ParseError = 1; 112 } 113 %% 114 #ifndef yywrap 115 int yywrap(void) { return(1);} 116 #endif 117 118 #undef input 119 #undef feof 120 #define feof() (1) 121 #define input() (*twmInputFunc)() 122 #undef output 123 #define output(c) TwmOutput(c) 124 #undef unput 125 #define unput(c) twmUnput(c) 126