1706f2543Smrg%{ # -*- C -*-
2706f2543Smrg/*
3706f2543Smrg * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
4706f2543Smrg * Copyright (C) Colin Harrison 2005-2008
5706f2543Smrg *
6706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining
7706f2543Smrg * a copy of this software and associated documentation files (the
8706f2543Smrg * "Software"), to deal in the Software without restriction, including
9706f2543Smrg * without limitation the rights to use, copy, modify, merge, publish,
10706f2543Smrg * distribute, sublicense, and/or sell copies of the Software, and to
11706f2543Smrg * permit persons to whom the Software is furnished to do so, subject to
12706f2543Smrg * the following conditions:
13706f2543Smrg *
14706f2543Smrg * The above copyright notice and this permission notice shall be
15706f2543Smrg * included in all copies or substantial portions of the Software.
16706f2543Smrg *
17706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18706f2543Smrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19706f2543Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20706f2543Smrg * NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
21706f2543Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
22706f2543Smrg * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23706f2543Smrg * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24706f2543Smrg *
25706f2543Smrg * Except as contained in this notice, the name of the XFree86 Project
26706f2543Smrg * shall not be used in advertising or otherwise to promote the sale, use
27706f2543Smrg * or other dealings in this Software without prior written authorization
28706f2543Smrg * from the XFree86 Project.
29706f2543Smrg *
30706f2543Smrg * Authors:     Earle F. Philhower, III
31706f2543Smrg *              Colin Harrison
32706f2543Smrg */
33706f2543Smrg/* $XFree86: $ */
34706f2543Smrg
35706f2543Smrg#include <stdio.h>
36706f2543Smrg#include <stdlib.h>
37706f2543Smrg#include <string.h>
38706f2543Smrg#include "winprefsyacc.h"
39706f2543Smrg
40706f2543Smrgextern YYSTYPE yylval;
41706f2543Smrgextern char *yytext;
42706f2543Smrgextern int yyparse(void);
43706f2543Smrg
44706f2543Smrgextern void ErrorF (const char* /*f*/, ...);
45706f2543Smrg
46706f2543Smrgint yylineno;
47706f2543Smrg
48706f2543Smrg/* Copy the parsed string, must be free()d in yacc parser */
49706f2543Smrgstatic char *makestr(char *str)
50706f2543Smrg{
51706f2543Smrg  char *ptr;
52706f2543Smrg  ptr = (char*)malloc (strlen(str)+1);
53706f2543Smrg  if (!ptr)
54706f2543Smrg    {
55706f2543Smrg      ErrorF ("winMultiWindowLex:makestr() out of memory\n");
56706f2543Smrg      exit (-1);
57706f2543Smrg    }
58706f2543Smrg  strcpy(ptr, str);
59706f2543Smrg  return ptr;
60706f2543Smrg}
61706f2543Smrg
62706f2543Smrg%}
63706f2543Smrg
64706f2543Smrg%option yylineno
65706f2543Smrg
66706f2543Smrg%%
67706f2543Smrg\#.*[\r\n]              { /* comment */ return NEWLINE; }
68706f2543Smrg\/\/.*[\r\n]            { /* comment */ return NEWLINE; }
69706f2543Smrg[\r\n]                  { return NEWLINE; }
70706f2543Smrg[ \t]+                  { /* ignore whitespace */ }
71706f2543SmrgMENU                    { return MENU; }
72706f2543SmrgICONDIRECTORY           { return ICONDIRECTORY; }
73706f2543SmrgDEFAULTICON             { return DEFAULTICON; }
74706f2543SmrgICONS                   { return ICONS; }
75706f2543SmrgSTYLES                  { return STYLES; }
76706f2543SmrgTOPMOST                 { return TOPMOST; }
77706f2543SmrgMAXIMIZE                { return MAXIMIZE; }
78706f2543SmrgMINIMIZE                { return MINIMIZE; }
79706f2543SmrgBOTTOM                  { return BOTTOM; }
80706f2543SmrgNOTITLE                 { return NOTITLE; }
81706f2543SmrgOUTLINE                 { return OUTLINE; }
82706f2543SmrgNOFRAME                 { return NOFRAME; }
83706f2543SmrgROOTMENU                { return ROOTMENU; }
84706f2543SmrgDEFAULTSYSMENU          { return DEFAULTSYSMENU; }
85706f2543SmrgSYSMENU                 { return SYSMENU; }
86706f2543SmrgSEPARATOR               { return SEPARATOR; }
87706f2543SmrgATSTART                 { return ATSTART; }
88706f2543SmrgATEND                   { return ATEND; }
89706f2543SmrgEXEC                    { return EXEC; }
90706f2543SmrgALWAYSONTOP             { return ALWAYSONTOP; }
91706f2543SmrgDEBUG                   { return DEBUGOUTPUT; }
92706f2543SmrgRELOAD                  { return RELOAD; }
93706f2543SmrgTRAYICON                { return TRAYICON; }
94706f2543SmrgSILENTEXIT		{ return SILENTEXIT; }
95706f2543Smrg"{"                     { return LB; }
96706f2543Smrg"}"                     { return RB; }
97706f2543Smrg"\""[^\"\r\n]+"\""      { yylval.sVal = makestr(yytext+1); \
98706f2543Smrg                          yylval.sVal[strlen(yylval.sVal)-1] = 0; \
99706f2543Smrg                          return STRING; }
100706f2543Smrg[^ \t\r\n]+             { yylval.sVal = makestr(yytext); \
101706f2543Smrg                          return STRING; }
102706f2543Smrg%%
103706f2543Smrg
104706f2543Smrg/*
105706f2543Smrg * Run-of-the mill requirement for yacc
106706f2543Smrg */
107706f2543Smrgint
108706f2543Smrgyywrap (void)
109706f2543Smrg{
110706f2543Smrg  return 1;
111706f2543Smrg}
112706f2543Smrg
113706f2543Smrg/*
114706f2543Smrg * Run a file through the yacc parser
115706f2543Smrg */
116706f2543Smrgvoid
117706f2543Smrgparse_file (FILE *file)
118706f2543Smrg{
119706f2543Smrg  if (!file)
120706f2543Smrg    return;
121706f2543Smrg
122706f2543Smrg  yylineno = 1;
123706f2543Smrg  yyin = file;
124706f2543Smrg  yyparse ();
125706f2543Smrg}
126706f2543Smrg
127