winprefslex.l revision 05b261ec
1%{ # -*- C -*- 2/* 3 * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining 6 * a copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sublicense, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be 14 * included in all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR 20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 21 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 * 24 * Except as contained in this notice, the name of the XFree86 Project 25 * shall not be used in advertising or otherwise to promote the sale, use 26 * or other dealings in this Software without prior written authorization 27 * from the XFree86 Project. 28 * 29 * Authors: Earle F. Philhower, III 30 */ 31/* $XFree86: $ */ 32 33#include <stdio.h> 34#include <stdlib.h> 35#include <string.h> 36#include "winprefsyacc.h" 37 38extern YYSTYPE yylval; 39extern char *yytext; 40extern int yyparse(void); 41 42extern void ErrorF (const char* /*f*/, ...); 43 44int yylineno; 45 46/* Copy the parsed string, must be free()d in yacc parser */ 47static char *makestr(char *str) 48{ 49 char *ptr; 50 ptr = (char*)malloc (strlen(str)+1); 51 if (!ptr) 52 { 53 ErrorF ("winMultiWindowLex:makestr() out of memory\n"); 54 exit (-1); 55 } 56 strcpy(ptr, str); 57 return ptr; 58} 59 60%} 61 62%option yylineno 63 64%% 65\#.*[\r\n] { /* comment */ return NEWLINE; } 66\/\/.*[\r\n] { /* comment */ return NEWLINE; } 67[\r\n] { return NEWLINE; } 68[ \t]+ { /* ignore whitespace */ } 69MENU { return MENU; } 70ICONDIRECTORY { return ICONDIRECTORY; } 71DEFAULTICON { return DEFAULTICON; } 72ICONS { return ICONS; } 73ROOTMENU { return ROOTMENU; } 74DEFAULTSYSMENU { return DEFAULTSYSMENU; } 75SYSMENU { return SYSMENU; } 76SEPARATOR { return SEPARATOR; } 77ATSTART { return ATSTART; } 78ATEND { return ATEND; } 79EXEC { return EXEC; } 80ALWAYSONTOP { return ALWAYSONTOP; } 81DEBUG { return DEBUG; } 82RELOAD { return RELOAD; } 83TRAYICON { return TRAYICON; } 84SILENTEXIT { return SILENTEXIT; } 85"{" { return LB; } 86"}" { return RB; } 87"\""[^\"\r\n]+"\"" { yylval.sVal = makestr(yytext+1); \ 88 yylval.sVal[strlen(yylval.sVal)-1] = 0; \ 89 return STRING; } 90[^ \t\r\n]+ { yylval.sVal = makestr(yytext); \ 91 return STRING; } 92%% 93 94/* 95 * Run-of-the mill requirement for yacc 96 */ 97int 98yywrap () 99{ 100 return 1; 101} 102 103/* 104 * Run a file through the yacc parser 105 */ 106void 107parse_file (FILE *file) 108{ 109 if (!file) 110 return; 111 112 yylineno = 1; 113 yyin = file; 114 yyparse (); 115} 116 117