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