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 
40 extern void ErrorF (const char* /*f*/, ...);
41 
42 /* Copy the parsed string, must be free()d in yacc parser */
makestr(char * str)43 static char *makestr(char *str)
44 {
45   char *ptr;
46   ptr = malloc(strlen(str)+1);
47   if (!ptr)
48     {
49       ErrorF ("winMultiWindowLex:makestr() out of memory\n");
50       exit (-1);
51     }
52   strcpy(ptr, str);
53   return ptr;
54 }
55 
56 %}
57 
58 %option yylineno
59 %option nounput
60 %option noinput
61 %option never-interactive
62 
63 %%
64 \#.*[\r\n]              { /* comment */ return NEWLINE; }
65 \/\/.*[\r\n]            { /* comment */ return NEWLINE; }
66 [\r\n]                  { return NEWLINE; }
67 [ \t]+                  { /* ignore whitespace */ }
68 MENU                    { return MENU; }
69 ICONDIRECTORY           { return ICONDIRECTORY; }
70 DEFAULTICON             { return DEFAULTICON; }
71 ICONS                   { return ICONS; }
72 STYLES                  { return STYLES; }
73 TOPMOST                 { return TOPMOST; }
74 MAXIMIZE                { return MAXIMIZE; }
75 MINIMIZE                { return MINIMIZE; }
76 BOTTOM                  { return BOTTOM; }
77 NOTITLE                 { return NOTITLE; }
78 OUTLINE                 { return OUTLINE; }
79 NOFRAME                 { return NOFRAME; }
80 ROOTMENU                { return ROOTMENU; }
81 DEFAULTSYSMENU          { return DEFAULTSYSMENU; }
82 SYSMENU                 { return SYSMENU; }
83 SEPARATOR               { return SEPARATOR; }
84 ATSTART                 { return ATSTART; }
85 ATEND                   { return ATEND; }
86 EXEC                    { return EXEC; }
87 ALWAYSONTOP             { return ALWAYSONTOP; }
88 DEBUG                   { return DEBUGOUTPUT; }
89 RELOAD                  { return RELOAD; }
90 TRAYICON                { return TRAYICON; }
91 FORCEEXIT		{ return FORCEEXIT; }
92 SILENTEXIT		{ return SILENTEXIT; }
93 "{"                     { return LB; }
94 "}"                     { return RB; }
95 "\""[^\"\r\n]+"\""      { yylval.sVal = makestr(yytext+1); \
96                           yylval.sVal[strlen(yylval.sVal)-1] = 0; \
97                           return STRING; }
98 [^ \t\r\n]+             { yylval.sVal = makestr(yytext); \
99                           return STRING; }
100 %%
101 
102 /*
103  * Run-of-the mill requirement for yacc
104  */
105 int
106 yywrap (void)
107 {
108   return 1;
109 }
110 
111 /*
112  * Run a file through the yacc parser
113  */
114 int
115 parse_file (FILE *file)
116 {
117   int ret;
118 
119   if (!file)
120     return 1;
121 
122   yylineno = 1;
123   yyin = file;
124   ret = yyparse ();
125   yylex_destroy ();
126   return ret;
127 }
128 
129