Update the flex scanner to use a stack for its start conditions
authorAlexey Gladkov <gladkov.alexey@gmail.com>
Wed, 29 Feb 2012 00:38:01 +0000 (04:38 +0400)
committerAlexey Gladkov <gladkov.alexey@gmail.com>
Wed, 29 Feb 2012 00:38:01 +0000 (04:38 +0400)
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
src/Makefile.am
src/loadkeys.analyze.c
src/loadkeys.analyze.h [new file with mode: 0644]
src/loadkeys.analyze.l
src/loadkeys.c
src/loadkeys.y

index 858a40e..0c420d6 100644 (file)
@@ -69,7 +69,8 @@ mapscrn_CFLAGS = -DMAIN
 loadunimap_CFLAGS = -DMAIN
 
 AM_YFLAGS = -d
-BUILT_SOURCES = loadkeys.c loadkeys.analyze.c loadkeys.h
+AM_LFLAGS = --header-file=$(CURDIR)/loadkeys.analyze.h
+BUILT_SOURCES = loadkeys.c loadkeys.analyze.c loadkeys.h loadkeys.analyze.h
 loadkeys_SOURCES = loadkeys.y loadkeys.analyze.l $(GETFD_S) $(KSYMS_S) $(XMAL_S) $(FIND_S)
 
 install-exec-hook:
index 0762959..9fade96 100644 (file)
@@ -796,7 +796,7 @@ int yy_flex_debug = 0;
 char *yytext;
 #line 1 "loadkeys.analyze.l"
 #define YY_NO_INPUT 1
-#line 5 "loadkeys.analyze.l"
+#line 7 "loadkeys.analyze.l"
 #define YY_NO_INPUT 1
 
 #include <stdlib.h>
@@ -1120,6 +1120,14 @@ static int input (void );
 
 #endif
 
+        static int yy_start_stack_ptr = 0;
+        static int yy_start_stack_depth = 0;
+        static int *yy_start_stack = NULL;
+    
+    static void yy_push_state (int new_state );
+    
+    static void yy_pop_state (void );
+    
 /* Amount of stuff to slurp up with each read. */
 #ifndef YY_READ_BUF_SIZE
 #define YY_READ_BUF_SIZE 8192
@@ -1223,7 +1231,7 @@ YY_DECL
        register char *yy_cp, *yy_bp;
        register int yy_act;
     
-#line 283 "loadkeys.analyze.l"
+#line 285 "loadkeys.analyze.l"
 
 
 /* To protect from wrong code in the higher level parser (loadkeys.y), 
@@ -1239,7 +1247,7 @@ YY_DECL
   yylval = YYLVAL_UNDEF;
 
 
-#line 1243 "loadkeys.analyze.c"
+#line 1251 "loadkeys.analyze.c"
 
        if ( !(yy_init) )
                {
@@ -1324,35 +1332,34 @@ do_action:      /* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 298 "loadkeys.analyze.l"
+#line 300 "loadkeys.analyze.l"
 {
-                               BEGIN(INCLSTR);
+                               yy_push_state(INCLSTR);
                        }
        YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 301 "loadkeys.analyze.l"
+#line 303 "loadkeys.analyze.l"
 {
                                char *s = xstrndup(yytext+1, strlen(yytext)-2);
                                /* use static pathname to store *s ? */
                                open_include(s);
-                               BEGIN(0);
+                               yy_pop_state();
                        }
        YY_BREAK
 case 3:
 /* rule 3 can match eol */
 YY_RULE_SETUP
-#line 307 "loadkeys.analyze.l"
+#line 309 "loadkeys.analyze.l"
 {
                                yyerror(_("expected filename between quotes"));
-                               BEGIN(0);
                        }
        YY_BREAK
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(RVALUE):
 case YY_STATE_EOF(STR):
 case YY_STATE_EOF(INCLSTR):
-#line 311 "loadkeys.analyze.l"
+#line 312 "loadkeys.analyze.l"
 {
                                stack_pop();
                                if (!YY_CURRENT_BUFFER)
@@ -1362,7 +1369,7 @@ case YY_STATE_EOF(INCLSTR):
 case 4:
 /* rule 4 can match eol */
 YY_RULE_SETUP
-#line 316 "loadkeys.analyze.l"
+#line 317 "loadkeys.analyze.l"
 {
                                line_nr++;
                        }
@@ -1370,16 +1377,17 @@ YY_RULE_SETUP
 case 5:
 /* rule 5 can match eol */
 YY_RULE_SETUP
-#line 319 "loadkeys.analyze.l"
+#line 320 "loadkeys.analyze.l"
 {
                                line_nr++;
-                               BEGIN(0);
+                               if (yy_start_stack_ptr > 0)
+                                       yy_pop_state();
                                return(EOL);
                        }
        YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 324 "loadkeys.analyze.l"
+#line 326 "loadkeys.analyze.l"
 ; /* do nothing */
        YY_BREAK
 case 7:
@@ -1388,37 +1396,37 @@ case 7:
 (yy_c_buf_p) = yy_cp -= 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 325 "loadkeys.analyze.l"
+#line 327 "loadkeys.analyze.l"
 ; /* do nothing */
        YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 326 "loadkeys.analyze.l"
+#line 328 "loadkeys.analyze.l"
 {
-                               BEGIN(RVALUE);
+                               yy_push_state(RVALUE);
                                rvalct = 0;
                                return(EQUALS);
                        }
        YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 331 "loadkeys.analyze.l"
+#line 333 "loadkeys.analyze.l"
 {
-                               BEGIN(RVALUE);
+                               yy_push_state(RVALUE);
                                return(STRING);
                        }
        YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 335 "loadkeys.analyze.l"
+#line 337 "loadkeys.analyze.l"
 {
-                               BEGIN(RVALUE);
+                               yy_push_state(RVALUE);
                                return(TO);
                        }
        YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 339 "loadkeys.analyze.l"
+#line 341 "loadkeys.analyze.l"
 {
                                yylval = strtol(yytext + 1, NULL, 16);
                                if (yylval >= 0xf000)
@@ -1428,7 +1436,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 345 "loadkeys.analyze.l"
+#line 347 "loadkeys.analyze.l"
 {
                                yylval = strtol(yytext, NULL, 0);
                                return(NUMBER);
@@ -1436,127 +1444,127 @@ YY_RULE_SETUP
        YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 349 "loadkeys.analyze.l"
+#line 351 "loadkeys.analyze.l"
 {      return((yylval = ksymtocode(yytext, TO_AUTO)) == -1 ? ERROR : LITERAL); }
        YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 350 "loadkeys.analyze.l"
+#line 352 "loadkeys.analyze.l"
 {      return(DASH);           }
        YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 351 "loadkeys.analyze.l"
+#line 353 "loadkeys.analyze.l"
 {      return(COMMA);          }
        YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 352 "loadkeys.analyze.l"
+#line 354 "loadkeys.analyze.l"
 {      return(PLUS);           }
        YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 353 "loadkeys.analyze.l"
+#line 355 "loadkeys.analyze.l"
 {      return(CHARSET);        }
        YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 354 "loadkeys.analyze.l"
+#line 356 "loadkeys.analyze.l"
 {      return(KEYMAPS);        }
        YY_BREAK
 case 19:
 YY_RULE_SETUP
-#line 355 "loadkeys.analyze.l"
+#line 357 "loadkeys.analyze.l"
 {      return(KEYCODE);        }
        YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 356 "loadkeys.analyze.l"
+#line 358 "loadkeys.analyze.l"
 {      return(PLAIN);          }
        YY_BREAK
 case 21:
 YY_RULE_SETUP
-#line 357 "loadkeys.analyze.l"
+#line 359 "loadkeys.analyze.l"
 {      return(SHIFT);          }
        YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 358 "loadkeys.analyze.l"
+#line 360 "loadkeys.analyze.l"
 {      return(CONTROL);        }
        YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 359 "loadkeys.analyze.l"
+#line 361 "loadkeys.analyze.l"
 {      return(ALT);            }
        YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 360 "loadkeys.analyze.l"
+#line 362 "loadkeys.analyze.l"
 {      return(ALTGR);          }
        YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 361 "loadkeys.analyze.l"
+#line 363 "loadkeys.analyze.l"
 {      return(SHIFTL);         }
        YY_BREAK
 case 26:
 YY_RULE_SETUP
-#line 362 "loadkeys.analyze.l"
+#line 364 "loadkeys.analyze.l"
 {      return(SHIFTR);         }
        YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 363 "loadkeys.analyze.l"
+#line 365 "loadkeys.analyze.l"
 {      return(CTRLL);          }
        YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 364 "loadkeys.analyze.l"
+#line 366 "loadkeys.analyze.l"
 {      return(CTRLR);          }
        YY_BREAK
 case 29:
 YY_RULE_SETUP
-#line 365 "loadkeys.analyze.l"
+#line 367 "loadkeys.analyze.l"
 {      return(CAPSSHIFT);      }
        YY_BREAK
 case 30:
 YY_RULE_SETUP
-#line 366 "loadkeys.analyze.l"
+#line 368 "loadkeys.analyze.l"
 {      return(ALT_IS_META);    }
        YY_BREAK
 case 31:
 YY_RULE_SETUP
-#line 367 "loadkeys.analyze.l"
+#line 369 "loadkeys.analyze.l"
 {      return(STRINGS);        }
        YY_BREAK
 case 32:
 YY_RULE_SETUP
-#line 368 "loadkeys.analyze.l"
+#line 370 "loadkeys.analyze.l"
 {      return(COMPOSE);        }
        YY_BREAK
 case 33:
 YY_RULE_SETUP
-#line 369 "loadkeys.analyze.l"
+#line 371 "loadkeys.analyze.l"
 {      return(AS);             }
        YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 370 "loadkeys.analyze.l"
+#line 372 "loadkeys.analyze.l"
 {      return(USUAL);          }
        YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 371 "loadkeys.analyze.l"
+#line 373 "loadkeys.analyze.l"
 {      return(ON);             }
        YY_BREAK
 case 36:
 YY_RULE_SETUP
-#line 372 "loadkeys.analyze.l"
+#line 374 "loadkeys.analyze.l"
 {      return(FOR);            }
        YY_BREAK
 case 37:
 YY_RULE_SETUP
-#line 373 "loadkeys.analyze.l"
+#line 375 "loadkeys.analyze.l"
 {
                                yylval = strtol(yytext + 2, NULL, 8);
                                return(CCHAR);
@@ -1564,7 +1572,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 38:
 YY_RULE_SETUP
-#line 377 "loadkeys.analyze.l"
+#line 379 "loadkeys.analyze.l"
 {
                                yylval = (unsigned char) yytext[2];
                                return(CCHAR);
@@ -1572,7 +1580,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 39:
 YY_RULE_SETUP
-#line 381 "loadkeys.analyze.l"
+#line 383 "loadkeys.analyze.l"
 {
                                yylval = (unsigned char) yytext[1];
                                return(CCHAR);
@@ -1580,16 +1588,16 @@ YY_RULE_SETUP
        YY_BREAK
 case 40:
 YY_RULE_SETUP
-#line 385 "loadkeys.analyze.l"
+#line 387 "loadkeys.analyze.l"
 {
                                p = (char *) kbs_buf.kb_string;
                                pmax = p + sizeof(kbs_buf.kb_string) - 1;
-                               BEGIN(STR);
+                               yy_push_state(STR);
                        }
        YY_BREAK
 case 41:
 YY_RULE_SETUP
-#line 390 "loadkeys.analyze.l"
+#line 392 "loadkeys.analyze.l"
 {
                                if (p >= pmax)
                                        lkfatal(_("string too long"));
@@ -1598,7 +1606,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 42:
 YY_RULE_SETUP
-#line 395 "loadkeys.analyze.l"
+#line 397 "loadkeys.analyze.l"
 {
                                if (p >= pmax)
                                        lkfatal(_("string too long"));
@@ -1607,7 +1615,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 43:
 YY_RULE_SETUP
-#line 400 "loadkeys.analyze.l"
+#line 402 "loadkeys.analyze.l"
 {
                                if (p >= pmax)
                                        lkfatal(_("string too long"));
@@ -1616,7 +1624,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 44:
 YY_RULE_SETUP
-#line 405 "loadkeys.analyze.l"
+#line 407 "loadkeys.analyze.l"
 {
                                if (p >= pmax)
                                        lkfatal(_("string too long"));
@@ -1626,7 +1634,7 @@ YY_RULE_SETUP
 case 45:
 /* rule 45 can match eol */
 YY_RULE_SETUP
-#line 410 "loadkeys.analyze.l"
+#line 412 "loadkeys.analyze.l"
 {
                                char *ptmp = p;
                                p += strlen(yytext);
@@ -1637,26 +1645,26 @@ YY_RULE_SETUP
        YY_BREAK
 case 46:
 YY_RULE_SETUP
-#line 417 "loadkeys.analyze.l"
+#line 419 "loadkeys.analyze.l"
 {
                                *p = '\0';
-                               BEGIN(0);
+                               yy_pop_state();
                                return(STRLITERAL);
                        }
        YY_BREAK
 case 47:
 YY_RULE_SETUP
-#line 422 "loadkeys.analyze.l"
+#line 424 "loadkeys.analyze.l"
 {
                                return(ERROR); /* report any unknown characters */
                        }
        YY_BREAK
 case 48:
 YY_RULE_SETUP
-#line 425 "loadkeys.analyze.l"
+#line 427 "loadkeys.analyze.l"
 ECHO;
        YY_BREAK
-#line 1660 "loadkeys.analyze.c"
+#line 1668 "loadkeys.analyze.c"
 
        case YY_END_OF_BUFFER:
                {
@@ -2410,6 +2418,38 @@ YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len )
        return b;
 }
 
+    static void yy_push_state (int  new_state )
+{
+       if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) )
+               {
+               yy_size_t new_size;
+
+               (yy_start_stack_depth) += YY_START_STACK_INCR;
+               new_size = (yy_start_stack_depth) * sizeof( int );
+
+               if ( ! (yy_start_stack) )
+                       (yy_start_stack) = (int *) yyalloc(new_size  );
+
+               else
+                       (yy_start_stack) = (int *) yyrealloc((void *) (yy_start_stack),new_size  );
+
+               if ( ! (yy_start_stack) )
+                       YY_FATAL_ERROR( "out of memory expanding start-condition stack" );
+               }
+
+       (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START;
+
+       BEGIN(new_state);
+}
+
+    static void yy_pop_state  (void)
+{
+       if ( --(yy_start_stack_ptr) < 0 )
+               YY_FATAL_ERROR( "start-condition stack underflow" );
+
+       BEGIN((yy_start_stack)[(yy_start_stack_ptr)]);
+}
+
 #ifndef YY_EXIT_FAILURE
 #define YY_EXIT_FAILURE 2
 #endif
@@ -2530,6 +2570,10 @@ static int yy_init_globals (void)
     (yy_init) = 0;
     (yy_start) = 0;
 
+    (yy_start_stack_ptr) = 0;
+    (yy_start_stack_depth) = 0;
+    (yy_start_stack) =  NULL;
+
 /* Defined in main.c */
 #ifdef YY_STDINIT
     yyin = stdin;
@@ -2560,6 +2604,10 @@ int yylex_destroy  (void)
        yyfree((yy_buffer_stack) );
        (yy_buffer_stack) = NULL;
 
+    /* Destroy the start condition stack. */
+        yyfree((yy_start_stack)  );
+        (yy_start_stack) = NULL;
+
     /* Reset the globals. This is important in a non-reentrant scanner so the next time
      * yylex() is called, initialization will occur. */
     yy_init_globals( );
@@ -2615,7 +2663,7 @@ void yyfree (void * ptr )
 
 #define YYTABLES_NAME "yytables"
 
-#line 425 "loadkeys.analyze.l"
+#line 427 "loadkeys.analyze.l"
 
 
 
diff --git a/src/loadkeys.analyze.h b/src/loadkeys.analyze.h
new file mode 100644 (file)
index 0000000..1b6ee24
--- /dev/null
@@ -0,0 +1,323 @@
+#ifndef yyHEADER_H
+#define yyHEADER_H 1
+#define yyIN_HEADER 1
+
+#line 6 "/mnt/scm/legion/kbd-upstream/src/loadkeys.analyze.h"
+
+#define  YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with  platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types. 
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t; 
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN               (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN              (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN              (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX               (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX              (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX              (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX              (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX             (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX             (4294967295U)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else  /* ! __cplusplus */
+
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
+
+#define YY_USE_CONST
+
+#endif /* defined (__STDC__) */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#define YY_BUF_SIZE 16384
+#endif
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+extern int yyleng;
+
+extern FILE *yyin, *yyout;
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+       {
+       FILE *yy_input_file;
+
+       char *yy_ch_buf;                /* input buffer */
+       char *yy_buf_pos;               /* current position in input buffer */
+
+       /* Size of input buffer in bytes, not including room for EOB
+        * characters.
+        */
+       yy_size_t yy_buf_size;
+
+       /* Number of characters read into yy_ch_buf, not including EOB
+        * characters.
+        */
+       int yy_n_chars;
+
+       /* Whether we "own" the buffer - i.e., we know we created it,
+        * and can realloc() it to grow it, and should free() it to
+        * delete it.
+        */
+       int yy_is_our_buffer;
+
+       /* Whether this is an "interactive" input source; if so, and
+        * if we're using stdio for input, then we want to use getc()
+        * instead of fread(), to make sure we stop fetching input after
+        * each newline.
+        */
+       int yy_is_interactive;
+
+       /* Whether we're considered to be at the beginning of a line.
+        * If so, '^' rules will be active on the next match, otherwise
+        * not.
+        */
+       int yy_at_bol;
+
+    int yy_bs_lineno; /**< The line count. */
+    int yy_bs_column; /**< The column count. */
+    
+       /* Whether to try to fill the input buffer when we reach the
+        * end of it.
+        */
+       int yy_fill_buffer;
+
+       int yy_buffer_status;
+
+       };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+void yyrestart (FILE *input_file  );
+void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
+YY_BUFFER_STATE yy_create_buffer (FILE *file,int size  );
+void yy_delete_buffer (YY_BUFFER_STATE b  );
+void yy_flush_buffer (YY_BUFFER_STATE b  );
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer  );
+void yypop_buffer_state (void );
+
+YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size  );
+YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str  );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len  );
+
+void *yyalloc (yy_size_t  );
+void *yyrealloc (void *,yy_size_t  );
+void yyfree (void *  );
+
+/* Begin user sect3 */
+
+#define yywrap(n) 1
+#define YY_SKIP_YYWRAP
+
+extern int yylineno;
+
+extern char *yytext;
+#define yytext_ptr yytext
+
+#ifdef YY_HEADER_EXPORT_START_CONDITIONS
+#define INITIAL 0
+#define RVALUE 1
+#define STR 2
+#define INCLSTR 3
+
+#endif
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include <unistd.h>
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+/* Accessor methods to globals.
+   These are made visible to non-reentrant scanners for convenience. */
+
+int yylex_destroy (void );
+
+int yyget_debug (void );
+
+void yyset_debug (int debug_flag  );
+
+YY_EXTRA_TYPE yyget_extra (void );
+
+void yyset_extra (YY_EXTRA_TYPE user_defined  );
+
+FILE *yyget_in (void );
+
+void yyset_in  (FILE * in_str  );
+
+FILE *yyget_out (void );
+
+void yyset_out  (FILE * out_str  );
+
+int yyget_leng (void );
+
+char *yyget_text (void );
+
+int yyget_lineno (void );
+
+void yyset_lineno (int line_number  );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap (void );
+#else
+extern int yywrap (void );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * );
+#endif
+
+#ifndef YY_NO_INPUT
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int yylex (void);
+
+#define YY_DECL int yylex (void)
+#endif /* !YY_DECL */
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+#undef YY_NEW_FILE
+#undef YY_FLUSH_BUFFER
+#undef yy_set_bol
+#undef yy_new_buffer
+#undef yy_set_interactive
+#undef YY_DO_BEFORE_ACTION
+
+#ifdef YY_DECL_IS_OURS
+#undef YY_DECL_IS_OURS
+#undef YY_DECL
+#endif
+
+#line 427 "/mnt/scm/legion/kbd-upstream/src/loadkeys.analyze.l"
+
+
+#line 322 "/mnt/scm/legion/kbd-upstream/src/loadkeys.analyze.h"
+#undef yyIN_HEADER
+#endif /* yyHEADER_H */
index b3e6a24..62ab8a3 100644 (file)
@@ -1,3 +1,5 @@
+%option stack
+%option noyy_top_state
 %option noyywrap
 %option nounput
 %option noinput
@@ -296,17 +298,16 @@ To                      to|To|TO
 %}
 
 {Include}              {
-                               BEGIN(INCLSTR);
+                               yy_push_state(INCLSTR);
                        }
 <INCLSTR>\"[^\"\n]+\"  {
                                char *s = xstrndup(yytext+1, strlen(yytext)-2);
                                /* use static pathname to store *s ? */
                                open_include(s);
-                               BEGIN(0);
+                               yy_pop_state();
                        }
 <INCLSTR>[^"]|\"\"|\"[^"\n]*{Eol}      {
                                yyerror(_("expected filename between quotes"));
-                               BEGIN(0);
                        }
 <<EOF>>                        {
                                stack_pop();
@@ -318,22 +319,23 @@ To                      to|To|TO
                        }
 {Eol}                  {
                                line_nr++;
-                               BEGIN(0);
+                               if (yy_start_stack_ptr > 0)
+                                       yy_pop_state();
                                return(EOL);
                        }
 {Blank}+               ; /* do nothing */
 {Comment}.*/{Eol}      ; /* do nothing */
 {Equals}               {
-                               BEGIN(RVALUE);
+                               yy_push_state(RVALUE);
                                rvalct = 0;
                                return(EQUALS);
                        }
 {String}               {
-                               BEGIN(RVALUE);
+                               yy_push_state(RVALUE);
                                return(STRING);
                        }
 {To}                   {
-                               BEGIN(RVALUE);
+                               yy_push_state(RVALUE);
                                return(TO);
                        }
 {Unicode}              {
@@ -385,7 +387,7 @@ To                      to|To|TO
 \"                     {
                                p = (char *) kbs_buf.kb_string;
                                pmax = p + sizeof(kbs_buf.kb_string) - 1;
-                               BEGIN(STR);
+                               yy_push_state(STR);
                        }
 <STR>\\{Octa}          {
                                if (p >= pmax)
@@ -416,7 +418,7 @@ To                      to|To|TO
                        }
 <STR>\"                        {
                                *p = '\0';
-                               BEGIN(0);
+                               yy_pop_state();
                                return(STRLITERAL);
                        }
 .                      {
index fe05609..1e95ea4 100644 (file)
@@ -69,6 +69,8 @@
 /* Line 189 of yacc.c  */
 #line 12 "loadkeys.y"
 
+#define YY_HEADER_EXPORT_START_CONDITIONS 1
+
 #include <errno.h>
 #include <stdio.h>
 #include <getopt.h>
@@ -92,6 +94,8 @@
 #include "nls.h"
 #include "version.h"
 
+#include "loadkeys.analyze.h"
+
 #define U(x) ((x) ^ 0xf000)
 
 #ifdef KDSKBDIACRUC
@@ -142,7 +146,6 @@ extern void stack_push(FILE *fd, int ispipe, char *filename);
 extern int prefer_unicode;
 
 #include "ksyms.h"
-int yylex(void);
 
 static void attr_noreturn usage(void)
 {
@@ -947,7 +950,7 @@ static void attr_noreturn bkeymap(void)
 
 
 /* Line 189 of yacc.c  */
-#line 951 "loadkeys.c"
+#line 954 "loadkeys.c"
 
 /* Enabling traces.  */
 #ifndef YYDEBUG
@@ -1059,7 +1062,7 @@ typedef int YYSTYPE;
 
 
 /* Line 264 of yacc.c  */
-#line 1063 "loadkeys.c"
+#line 1066 "loadkeys.c"
 
 #ifdef short
 # undef short
@@ -1364,12 +1367,12 @@ static const yytype_int8 yyrhs[] =
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   891,   891,   892,   894,   895,   896,   897,   898,   899,
-     900,   901,   902,   903,   905,   910,   915,   920,   924,   929,
-     934,   935,   937,   943,   948,   957,   961,   966,   967,   969,
-     969,   976,   981,   982,   984,   985,   986,   987,   988,   989,
-     990,   991,   992,   994,  1033,  1034,  1036,  1043,  1044,  1045,
-    1046,  1047,  1048
+       0,   894,   894,   895,   897,   898,   899,   900,   901,   902,
+     903,   904,   905,   906,   908,   913,   918,   923,   927,   932,
+     937,   938,   940,   946,   951,   960,   964,   969,   970,   972,
+     972,   979,   984,   985,   987,   988,   989,   990,   991,   992,
+     993,   994,   995,   997,  1036,  1037,  1039,  1046,  1047,  1048,
+    1049,  1050,  1051
 };
 #endif
 
@@ -2341,7 +2344,7 @@ yyreduce:
         case 14:
 
 /* Line 1464 of yacc.c  */
-#line 906 "loadkeys.y"
+#line 909 "loadkeys.y"
     {
                                set_charset((char *) kbs_buf.kb_string);
                        }
@@ -2350,7 +2353,7 @@ yyreduce:
   case 15:
 
 /* Line 1464 of yacc.c  */
-#line 911 "loadkeys.y"
+#line 914 "loadkeys.y"
     {
                                alt_is_meta = 1;
                        }
@@ -2359,7 +2362,7 @@ yyreduce:
   case 16:
 
 /* Line 1464 of yacc.c  */
-#line 916 "loadkeys.y"
+#line 919 "loadkeys.y"
     {
                                strings_as_usual();
                        }
@@ -2368,7 +2371,7 @@ yyreduce:
   case 17:
 
 /* Line 1464 of yacc.c  */
-#line 921 "loadkeys.y"
+#line 924 "loadkeys.y"
     {
                                compose_as_usual((char *) kbs_buf.kb_string);
                        }
@@ -2377,7 +2380,7 @@ yyreduce:
   case 18:
 
 /* Line 1464 of yacc.c  */
-#line 925 "loadkeys.y"
+#line 928 "loadkeys.y"
     {
                                compose_as_usual(0);
                        }
@@ -2386,7 +2389,7 @@ yyreduce:
   case 19:
 
 /* Line 1464 of yacc.c  */
-#line 930 "loadkeys.y"
+#line 933 "loadkeys.y"
     {
                                keymaps_line_seen = 1;
                        }
@@ -2395,7 +2398,7 @@ yyreduce:
   case 22:
 
 /* Line 1464 of yacc.c  */
-#line 938 "loadkeys.y"
+#line 941 "loadkeys.y"
     {
                                int i;
                                for (i = (yyvsp[(1) - (3)]); i <= (yyvsp[(3) - (3)]); i++)
@@ -2406,7 +2409,7 @@ yyreduce:
   case 23:
 
 /* Line 1464 of yacc.c  */
-#line 944 "loadkeys.y"
+#line 947 "loadkeys.y"
     {
                                addmap((yyvsp[(1) - (1)]),1);
                        }
@@ -2415,7 +2418,7 @@ yyreduce:
   case 24:
 
 /* Line 1464 of yacc.c  */
-#line 949 "loadkeys.y"
+#line 952 "loadkeys.y"
     {
                                if (KTYP((yyvsp[(2) - (5)])) != KT_FN)
                                        lkfatal(_("'%s' is not a function key symbol"),
@@ -2428,7 +2431,7 @@ yyreduce:
   case 25:
 
 /* Line 1464 of yacc.c  */
-#line 958 "loadkeys.y"
+#line 961 "loadkeys.y"
     {
                                compose((yyvsp[(2) - (6)]), (yyvsp[(3) - (6)]), (yyvsp[(5) - (6)]));
                        }
@@ -2437,7 +2440,7 @@ yyreduce:
   case 26:
 
 /* Line 1464 of yacc.c  */
-#line 962 "loadkeys.y"
+#line 965 "loadkeys.y"
     {
                                compose((yyvsp[(2) - (6)]), (yyvsp[(3) - (6)]), (yyvsp[(5) - (6)]));
                        }
@@ -2446,21 +2449,21 @@ yyreduce:
   case 27:
 
 /* Line 1464 of yacc.c  */
-#line 966 "loadkeys.y"
+#line 969 "loadkeys.y"
     {  (yyval) = (yyvsp[(1) - (1)]);           }
     break;
 
   case 28:
 
 /* Line 1464 of yacc.c  */
-#line 967 "loadkeys.y"
+#line 970 "loadkeys.y"
     {  (yyval) = (yyvsp[(1) - (1)]) ^ 0xf000;  }
     break;
 
   case 29:
 
 /* Line 1464 of yacc.c  */
-#line 969 "loadkeys.y"
+#line 972 "loadkeys.y"
     {
                                mod = 0;
                        }
@@ -2469,7 +2472,7 @@ yyreduce:
   case 30:
 
 /* Line 1464 of yacc.c  */
-#line 973 "loadkeys.y"
+#line 976 "loadkeys.y"
     {
                                addkey((yyvsp[(4) - (7)]), mod, (yyvsp[(6) - (7)]));
                        }
@@ -2478,7 +2481,7 @@ yyreduce:
   case 31:
 
 /* Line 1464 of yacc.c  */
-#line 977 "loadkeys.y"
+#line 980 "loadkeys.y"
     {
                                addkey((yyvsp[(3) - (6)]), 0, (yyvsp[(5) - (6)]));
                        }
@@ -2487,70 +2490,70 @@ yyreduce:
   case 34:
 
 /* Line 1464 of yacc.c  */
-#line 984 "loadkeys.y"
+#line 987 "loadkeys.y"
     { mod |= M_SHIFT;  }
     break;
 
   case 35:
 
 /* Line 1464 of yacc.c  */
-#line 985 "loadkeys.y"
+#line 988 "loadkeys.y"
     { mod |= M_CTRL;   }
     break;
 
   case 36:
 
 /* Line 1464 of yacc.c  */
-#line 986 "loadkeys.y"
+#line 989 "loadkeys.y"
     { mod |= M_ALT;            }
     break;
 
   case 37:
 
 /* Line 1464 of yacc.c  */
-#line 987 "loadkeys.y"
+#line 990 "loadkeys.y"
     { mod |= M_ALTGR;  }
     break;
 
   case 38:
 
 /* Line 1464 of yacc.c  */
-#line 988 "loadkeys.y"
+#line 991 "loadkeys.y"
     { mod |= M_SHIFTL; }
     break;
 
   case 39:
 
 /* Line 1464 of yacc.c  */
-#line 989 "loadkeys.y"
+#line 992 "loadkeys.y"
     { mod |= M_SHIFTR; }
     break;
 
   case 40:
 
 /* Line 1464 of yacc.c  */
-#line 990 "loadkeys.y"
+#line 993 "loadkeys.y"
     { mod |= M_CTRLL;  }
     break;
 
   case 41:
 
 /* Line 1464 of yacc.c  */
-#line 991 "loadkeys.y"
+#line 994 "loadkeys.y"
     { mod |= M_CTRLR;  }
     break;
 
   case 42:
 
 /* Line 1464 of yacc.c  */
-#line 992 "loadkeys.y"
+#line 995 "loadkeys.y"
     { mod |= M_CAPSSHIFT;      }
     break;
 
   case 43:
 
 /* Line 1464 of yacc.c  */
-#line 995 "loadkeys.y"
+#line 998 "loadkeys.y"
     {
                                int i, j;
 
@@ -2592,7 +2595,7 @@ yyreduce:
   case 46:
 
 /* Line 1464 of yacc.c  */
-#line 1037 "loadkeys.y"
+#line 1040 "loadkeys.y"
     {
                                if (rvalct >= MAX_NR_KEYMAPS)
                                        lkfatal(_("too many key definitions on one line"));
@@ -2603,49 +2606,49 @@ yyreduce:
   case 47:
 
 /* Line 1464 of yacc.c  */
-#line 1043 "loadkeys.y"
+#line 1046 "loadkeys.y"
     { (yyval) = convert_code((yyvsp[(1) - (1)]), TO_AUTO);             }
     break;
 
   case 48:
 
 /* Line 1464 of yacc.c  */
-#line 1044 "loadkeys.y"
+#line 1047 "loadkeys.y"
     { (yyval) = add_capslock((yyvsp[(2) - (2)]));                      }
     break;
 
   case 49:
 
 /* Line 1464 of yacc.c  */
-#line 1045 "loadkeys.y"
+#line 1048 "loadkeys.y"
     { (yyval) = convert_code((yyvsp[(1) - (1)])^0xf000, TO_AUTO);      }
     break;
 
   case 50:
 
 /* Line 1464 of yacc.c  */
-#line 1046 "loadkeys.y"
+#line 1049 "loadkeys.y"
     { (yyval) = add_capslock((yyvsp[(2) - (2)])^0xf000);                       }
     break;
 
   case 51:
 
 /* Line 1464 of yacc.c  */
-#line 1047 "loadkeys.y"
+#line 1050 "loadkeys.y"
     { (yyval) = (yyvsp[(1) - (1)]);                                    }
     break;
 
   case 52:
 
 /* Line 1464 of yacc.c  */
-#line 1048 "loadkeys.y"
+#line 1051 "loadkeys.y"
     { (yyval) = add_capslock((yyvsp[(2) - (2)]));                      }
     break;
 
 
 
 /* Line 1464 of yacc.c  */
-#line 2649 "loadkeys.c"
+#line 2652 "loadkeys.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -2857,7 +2860,7 @@ yyreturn:
 
 
 /* Line 1684 of yacc.c  */
-#line 1050 "loadkeys.y"
+#line 1053 "loadkeys.y"
 
 
 static void parse_keymap(FILE *fd) {
index 2b07328..38f9dcf 100644 (file)
@@ -10,6 +10,8 @@
 %token UNUMBER ALT_IS_META STRINGS AS USUAL ON FOR
 
 %{
+#define YY_HEADER_EXPORT_START_CONDITIONS 1
+
 #include <errno.h>
 #include <stdio.h>
 #include <getopt.h>
@@ -33,6 +35,8 @@
 #include "nls.h"
 #include "version.h"
 
+#include "loadkeys.analyze.h"
+
 #define U(x) ((x) ^ 0xf000)
 
 #ifdef KDSKBDIACRUC
@@ -83,7 +87,6 @@ extern void stack_push(FILE *fd, int ispipe, char *filename);
 extern int prefer_unicode;
 
 #include "ksyms.h"
-int yylex(void);
 
 static void attr_noreturn usage(void)
 {