1 /* $NetBSD: config_lex.l,v 1.7 2009/10/29 14:40:09 christos Exp $ */ 2 3 /* 4 * Copyright (c) 2003, 2004 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Julio M. Merino Vidal. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. The name authors may not be used to endorse or promote products 16 * derived from this software without specific prior written 17 * permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS 20 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 25 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 %{ 33 34 #include <sys/cdefs.h> 35 36 #ifndef lint 37 __RCSID("$NetBSD: config_lex.l,v 1.7 2009/10/29 14:40:09 christos Exp $"); 38 #endif /* not lint */ 39 40 #include <stdio.h> 41 #include <string.h> 42 #include <sys/time.h> 43 #include <dev/wscons/wsconsio.h> 44 45 #include "wsmoused.h" 46 #include "config_yacc.h" 47 48 extern int yyline; 49 50 extern int yyerror(const char *fmt, ...); 51 int yylex(void); 52 53 54 %} 55 56 %option noyywrap noinput nounput 57 58 STRING [\$A-Za-z\.\/_\-0-9]* 59 SP_STRING [\$A-Za-z\.\/_\-0-9 ]* 60 MODE_PROPS button_[0-9]+_down|button_[0-9]+_up|device|fifo|lefthanded|modes|nodaemon|pidfile|slowdown_x|slowdown_y|ttystat|xconsole|xconsole_delay 61 62 %% 63 64 #.*$ /* Eat up comments */ 65 [ \t]+ /* Eat up whitespace */ 66 \n { yyline++; } 67 68 = { return TK_EQUAL; } 69 ; { return TK_EOL; } 70 "{" { return TK_LBRACE; } 71 "}" { return TK_RBRACE; } 72 mode { return TK_MODE; } 73 {MODE_PROPS} { yylval.string = strdup(yytext); return TK_MODEPROP; } 74 \"{SP_STRING}\" { yylval.string = strdup(yytext + 1); 75 yylval.string[strlen(yytext) - 2] = '\0'; return TK_STRING; } 76 {STRING} { yylval.string = strdup(yytext); return TK_STRING; } 77 78 . { yyerror("illegal token `%s'", yytext); } 79