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