1 /************************************************************
2 Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
4 Permission to use, copy, modify, and distribute this
5 software and its documentation for any purpose and without
6 fee is hereby granted, provided that the above copyright
7 notice appear in all copies and that both that copyright
8 notice and this permission notice appear in supporting
9 documentation, and that the name of Silicon Graphics not be
10 used in advertising or publicity pertaining to distribution
11 of the software without specific prior written permission.
12 Silicon Graphics makes no representation about the suitability
13 of this software for any purpose. It is provided "as is"
14 without any express or implied warranty.
16 SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19 GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
23 THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 ********************************************************/
34 #include "parseutils.h"
37 char *scanFile = NULL;
41 unsigned long scanULong;
46 extern int yyparse(void);
50 %option case-insensitive
53 %option never-interactive
64 \" s = scanBuf; BEGIN(S_STR);
65 \< s = scanBuf; BEGIN(S_KEY);
67 <S_STR>\" BEGIN(INITIAL); *s = '\0'; return STRING;
68 <S_KEY>\> BEGIN(INITIAL); *s = '\0'; return KEYNAME;
70 <S_STR,S_KEY>\\[0-7]{1,3} {
71 /* octal escape sequence */
74 (void) sscanf( yytext + 1, "%o", &result );
77 fprintf(stderr, "Illegal octal escape %s\n", yytext);
84 <S_STR,S_KEY>\\[0-9]+ {
85 fprintf(stderr, "Illegal octal escape %s\n", yytext);
89 <S_STR,S_KEY>\\n *s++ = '\n';
90 <S_STR,S_KEY>\\t *s++ = '\t';
91 <S_STR,S_KEY>\\r *s++ = '\r';
92 <S_STR,S_KEY>\\b *s++ = '\b';
93 <S_STR,S_KEY>\\f *s++ = '\f';
94 <S_STR,S_KEY>\\v *s++ = '\v';
95 <S_STR,S_KEY>\\e *s++ = '\033';
97 <S_STR,S_KEY>. *s++ = yytext[0];
99 xkb_keymap return XKB_KEYMAP;
100 xkb_keycodes return XKB_KEYCODES;
101 xkb_types return XKB_TYPES;
102 xkb_symbols return XKB_SYMBOLS;
103 xkb_compat return XKB_COMPATMAP;
104 xkb_compat_map return XKB_COMPATMAP;
105 xkb_compatibility return XKB_COMPATMAP;
106 xkb_compatibility_map return XKB_COMPATMAP;
107 xkb_geometry return XKB_GEOMETRY;
108 xkb_semantics return XKB_SEMANTICS;
109 xkb_layout return XKB_LAYOUT;
110 include return INCLUDE;
111 override return OVERRIDE;
112 augment return AUGMENT;
113 replace return REPLACE;
114 alternate return ALTERNATE;
115 partial return PARTIAL;
116 default return DEFAULT;
117 hidden return HIDDEN;
118 virtual_modifiers return VIRTUAL_MODS;
120 interpret return INTERPRET;
121 action return ACTION_TOK;
125 modmap return MODIFIER_MAP;
126 mod_map return MODIFIER_MAP;
127 modifier_map return MODIFIER_MAP;
128 indicator return INDICATOR;
132 section return SECTION;
133 overlay return OVERLAY;
135 outline return OUTLINE;
138 virtual return VIRTUAL;
139 alphanumeric_keys return ALPHANUMERIC_KEYS;
140 modifier_keys return MODIFIER_KEYS;
141 keypad_keys return KEYPAD_KEYS;
142 function_keys return FUNCTION_KEYS;
143 alternate_group return ALTERNATE_GROUP;
145 [a-zA-Z_][a-zA-Z_0-9]* memcpy(scanBuf, yytext, yyleng + 1); return IDENT;
150 scanInt = strtol(yytext, &end, 0);
151 scanULong = strtoul(yytext, &end, 0);
157 scanInt = strtod(yytext, &end) * XkbGeomPtsPerMM;
181 <<EOF>> return END_OF_FILE;
188 yyerror(const char *msg)
190 if (warningLevel>0) {
191 fprintf(stderr,"%s: line %d of %s\n",msg,yylineno,
192 (scanFile?scanFile:"(unknown)"));
194 fprintf(stderr,"last scanned symbol is: %s\n",scanBuf);
199 void setScanState(const char *file, int lineno)
203 scanFile = strdup(file);
207 XKBParseString(const char *string, XkbFile ** pRtrn)
209 YY_BUFFER_STATE state;
215 state = yy_scan_string(string);
220 yy_delete_buffer(state);
221 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
223 CheckDefaultMap(rtrnValue);
230 XKBParseFile(FILE * file, XkbFile ** pRtrn)
243 CheckDefaultMap(rtrnValue);