winprefslex.l revision 35c4bbdf
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 void ErrorF (const char* /*f*/, ...);
41
42/* Copy the parsed string, must be free()d in yacc parser */
43static 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 */ }
68MENU                    { return MENU; }
69ICONDIRECTORY           { return ICONDIRECTORY; }
70DEFAULTICON             { return DEFAULTICON; }
71ICONS                   { return ICONS; }
72STYLES                  { return STYLES; }
73TOPMOST                 { return TOPMOST; }
74MAXIMIZE                { return MAXIMIZE; }
75MINIMIZE                { return MINIMIZE; }
76BOTTOM                  { return BOTTOM; }
77NOTITLE                 { return NOTITLE; }
78OUTLINE                 { return OUTLINE; }
79NOFRAME                 { return NOFRAME; }
80ROOTMENU                { return ROOTMENU; }
81DEFAULTSYSMENU          { return DEFAULTSYSMENU; }
82SYSMENU                 { return SYSMENU; }
83SEPARATOR               { return SEPARATOR; }
84ATSTART                 { return ATSTART; }
85ATEND                   { return ATEND; }
86EXEC                    { return EXEC; }
87ALWAYSONTOP             { return ALWAYSONTOP; }
88DEBUG                   { return DEBUGOUTPUT; }
89RELOAD                  { return RELOAD; }
90TRAYICON                { return TRAYICON; }
91FORCEEXIT		{ return FORCEEXIT; }
92SILENTEXIT		{ 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 */
105int
106yywrap (void)
107{
108  return 1;
109}
110
111/*
112 * Run a file through the yacc parser
113 */
114int
115parse_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