Blame src/libkeymap/analyze.l

Packit Service 50ad14
%{
Packit Service 50ad14
#include "config.h"
Packit Service 50ad14
Packit Service 50ad14
#include <stdlib.h>
Packit Service 50ad14
#include <unistd.h> /* readlink */
Packit Service 50ad14
Packit Service 50ad14
#include "nls.h"
Packit Service 50ad14
#include "kbd.h"
Packit Service 50ad14
#include "contextP.h"
Packit Service 50ad14
#include "ksyms.h"
Packit Service 50ad14
#include "paths.h"
Packit Service 50ad14
Packit Service 50ad14
#include "parser.h"
Packit Service 50ad14
%}
Packit Service 50ad14
Packit Service 50ad14
%top {
Packit Service 50ad14
#include "keymap.h"
Packit Service 50ad14
int stack_push(struct lk_ctx *ctx, lkfile_t *fp, void *scanner);
Packit Service 50ad14
int stack_pop(struct lk_ctx *ctx, void *scanner);
Packit Service 50ad14
}
Packit Service 50ad14
Packit Service 50ad14
%option reentrant
Packit Service 50ad14
%option bison-bridge
Packit Service 50ad14
%option stack
Packit Service 50ad14
%option never-interactive
Packit Service 50ad14
%option noyywrap
Packit Service 50ad14
%option nounput
Packit Service 50ad14
%option noinput
Packit Service 50ad14
%option noyy_top_state
Packit Service 50ad14
Packit Service 50ad14
%option extra-type="struct lk_ctx *"
Packit Service 50ad14
Packit Service 50ad14
%{
Packit Service 50ad14
int
Packit Service 50ad14
stack_push(struct lk_ctx *ctx, lkfile_t *fp, void *scanner)
Packit Service 50ad14
{
Packit Service 50ad14
	int i = 0;
Packit Service 50ad14
Packit Service 50ad14
	while (ctx->stack[i]) i++;
Packit Service 50ad14
Packit Service 50ad14
	if (i == MAX_INCLUDE_DEPTH) {
Packit Service 50ad14
		ERR(ctx, _("includes are nested too deeply"));
Packit Service 50ad14
		return -1;
Packit Service 50ad14
	}
Packit Service 50ad14
Packit Service 50ad14
	ctx->stack[i] = fp;
Packit Service 50ad14
Packit Service 50ad14
	yypush_buffer_state(yy_create_buffer(fp->fd, YY_BUF_SIZE, scanner), scanner);
Packit Service 50ad14
	return 0;
Packit Service 50ad14
}
Packit Service 50ad14
Packit Service 50ad14
int
Packit Service 50ad14
stack_pop(struct lk_ctx *ctx, void *scanner)
Packit Service 50ad14
{
Packit Service 50ad14
	int i = 0;
Packit Service 50ad14
Packit Service 50ad14
	while (ctx->stack[i]) i++;
Packit Service 50ad14
	if (!i)
Packit Service 50ad14
		return 0;
Packit Service 50ad14
	i--;
Packit Service 50ad14
Packit Service 50ad14
	/*
Packit Service 50ad14
	 * The top of stack is input file for library. No need to close it.
Packit Service 50ad14
	 */
Packit Service 50ad14
	if (i) {
Packit Service 50ad14
		lk_fpclose(ctx->stack[i]);
Packit Service 50ad14
		free(ctx->stack[i]);
Packit Service 50ad14
	}
Packit Service 50ad14
	ctx->stack[i] = NULL;
Packit Service 50ad14
Packit Service 50ad14
	yypop_buffer_state(scanner);
Packit Service 50ad14
	return 0;
Packit Service 50ad14
}
Packit Service 50ad14
Packit Service 50ad14
/*
Packit Service 50ad14
 * Where shall we look for an include file?
Packit Service 50ad14
 * Current strategy (undocumented, may change):
Packit Service 50ad14
 *
Packit Service 50ad14
 * 1. Look for a user-specified LOADKEYS_INCLUDE_PATH
Packit Service 50ad14
 * 2. Try . and ../include and ../../include
Packit Service 50ad14
 * 3. Try D and D/../include and D/../../include
Packit Service 50ad14
 *    where D is the directory from where we are loading the current file.
Packit Service 50ad14
 * 4. Try KD/include and KD/#/include where KD = DATADIR/KEYMAPDIR.
Packit Service 50ad14
 *
Packit Service 50ad14
 * Expected layout:
Packit Service 50ad14
 * KD has subdirectories amiga, atari, i386, mac, sun, include
Packit Service 50ad14
 * KD/include contains architecture-independent stuff
Packit Service 50ad14
 * like strings and iso-8859-x compose tables.
Packit Service 50ad14
 * KD/i386 has subdirectories qwerty, ... and include;
Packit Service 50ad14
 * this latter include dir contains stuff with keycode=...
Packit Service 50ad14
 *
Packit Service 50ad14
 * (Of course, if the present setup turns out to be reasonable,
Packit Service 50ad14
 * then later also the other architectures will grow and get
Packit Service 50ad14
 * subdirectories, and the hard-coded i386 below will go again.)
Packit Service 50ad14
 *
Packit Service 50ad14
 * People that dislike a dozen lookups for loadkeys
Packit Service 50ad14
 * can easily do "loadkeys file_with_includes; dumpkeys > my_keymap"
Packit Service 50ad14
 * and afterwards use only "loadkeys /fullpath/mykeymap", where no
Packit Service 50ad14
 * lookups are required.
Packit Service 50ad14
 */
Packit Service 50ad14
static const char *const include_dirpath0[] = { "", 0 };
Packit Service 50ad14
static const char *const include_dirpath1[] = { "", "../include/", "../../include/", 0 };
Packit Service 50ad14
static const char *const include_dirpath3[] = {
Packit Service 50ad14
	DATADIR "/" KEYMAPDIR "/include/",
Packit Service 50ad14
	DATADIR "/" KEYMAPDIR "/i386/include/",
Packit Service 50ad14
	DATADIR "/" KEYMAPDIR "/mac/include/", 0
Packit Service 50ad14
};
Packit Service 50ad14
Packit Service 50ad14
static const char *const include_suffixes[] = { "", ".inc", 0 };
Packit Service 50ad14
Packit Service 50ad14
static int
Packit Service 50ad14
find_incl_file_near_fn(struct lk_ctx *ctx, char *s, char *fn, lkfile_t *fp)
Packit Service 50ad14
{
Packit Service 50ad14
	const char *include_dirpath2[] = { 0, 0, 0, 0 };
Packit Service 50ad14
	char *t, *te, *t1 = NULL, *t2 = NULL;
Packit Service 50ad14
	int len, rc = 1;
Packit Service 50ad14
Packit Service 50ad14
	if (!fn)
Packit Service 50ad14
		return 1;
Packit Service 50ad14
Packit Service 50ad14
	t = strdup(fn);
Packit Service 50ad14
	if (t == NULL)
Packit Service 50ad14
		goto nomem;
Packit Service 50ad14
Packit Service 50ad14
	te = strrchr(t, '/');
Packit Service 50ad14
	if (te) {
Packit Service 50ad14
		te[1] = 0;
Packit Service 50ad14
		len = strlen(t);
Packit Service 50ad14
		include_dirpath2[0] = t;
Packit Service 50ad14
		include_dirpath2[1] = t1 = malloc(len + 12);
Packit Service 50ad14
		include_dirpath2[2] = t2 = malloc(len + 15);
Packit Service 50ad14
Packit Service 50ad14
		if (t1 == NULL || t2 == NULL)
Packit Service 50ad14
			goto nomem;
Packit Service 50ad14
Packit Service 50ad14
		strcpy(t1, t);
Packit Service 50ad14
		strcat(t1, "../include/");
Packit Service 50ad14
		strcpy(t2, t);
Packit Service 50ad14
		strcat(t2, "../../include/");
Packit Service 50ad14
		rc = lk_findfile(s, include_dirpath2, include_suffixes, fp);
Packit Service 50ad14
		free(t1);
Packit Service 50ad14
		free(t2);
Packit Service 50ad14
	}
Packit Service 50ad14
	free(t);
Packit Service 50ad14
	return rc;
Packit Service 50ad14
Packit Service 50ad14
nomem:	ERR(ctx, _("out of memory"));
Packit Service 50ad14
	if (t1) free(t1);
Packit Service 50ad14
	if (t2) free(t2);
Packit Service 50ad14
	if (t)  free(t);
Packit Service 50ad14
	return -1;
Packit Service 50ad14
}
Packit Service 50ad14
Packit Service 50ad14
static int
Packit Service 50ad14
find_standard_incl_file(struct lk_ctx *ctx, char *s, lkfile_t *fp)
Packit Service 50ad14
{
Packit Service 50ad14
	char *pathname;
Packit Service 50ad14
	int rc = 1;
Packit Service 50ad14
	int i = 0;
Packit Service 50ad14
Packit Service 50ad14
	while (ctx->stack[i]) i++;
Packit Service 50ad14
	if (i == 0)
Packit Service 50ad14
		return -1;
Packit Service 50ad14
	i--;
Packit Service 50ad14
	pathname = ctx->stack[i]->pathname;
Packit Service 50ad14
Packit Service 50ad14
	if (lk_findfile(s, include_dirpath1, include_suffixes, fp)) {
Packit Service 50ad14
		if ((rc = find_incl_file_near_fn(ctx, s, pathname, fp)) == -1)
Packit Service 50ad14
			return rc;
Packit Service 50ad14
	}
Packit Service 50ad14
Packit Service 50ad14
	/* If filename is a symlink, also look near its target. */
Packit Service 50ad14
	if (rc) {
Packit Service 50ad14
		char buf[MAXPATHLEN], path[MAXPATHLEN], *ptr;
Packit Service 50ad14
		unsigned int n;
Packit Service 50ad14
Packit Service 50ad14
		n = readlink(pathname, buf, sizeof(buf));
Packit Service 50ad14
		if (n > 0 && n < sizeof(buf)) {
Packit Service 50ad14
			buf[n] = 0;
Packit Service 50ad14
			if (buf[0] == '/') {
Packit Service 50ad14
				rc = find_incl_file_near_fn(ctx, s, buf, fp);
Packit Service 50ad14
Packit Service 50ad14
			} else if (strlen(pathname) + n < sizeof(path)) {
Packit Service 50ad14
				strcpy(path, pathname);
Packit Service 50ad14
				path[sizeof(path) - 1] = 0;
Packit Service 50ad14
				ptr = strrchr(path, '/');
Packit Service 50ad14
				if (ptr)
Packit Service 50ad14
					ptr[1] = 0;
Packit Service 50ad14
				strcat(path, buf);
Packit Service 50ad14
				rc = find_incl_file_near_fn(ctx, s, path, fp);
Packit Service 50ad14
			}
Packit Service 50ad14
		}
Packit Service 50ad14
	}
Packit Service 50ad14
Packit Service 50ad14
	if (rc)
Packit Service 50ad14
		rc = lk_findfile(s, include_dirpath3, include_suffixes, fp);
Packit Service 50ad14
	return rc;
Packit Service 50ad14
}
Packit Service 50ad14
Packit Service 50ad14
static int
Packit Service 50ad14
find_incl_file(struct lk_ctx *ctx, char *s, lkfile_t *fp)
Packit Service 50ad14
{
Packit Service 50ad14
	char *ev;
Packit Service 50ad14
Packit Service 50ad14
	if (!s || !*s)
Packit Service 50ad14
		return 1;
Packit Service 50ad14
Packit Service 50ad14
	if (*s == '/')		/* no path required */
Packit Service 50ad14
		return (lk_findfile(s, include_dirpath0, include_suffixes, fp));
Packit Service 50ad14
Packit Service 50ad14
	if ((ev = getenv("LOADKEYS_INCLUDE_PATH")) != NULL) {
Packit Service 50ad14
		/* try user-specified path */
Packit Service 50ad14
		const char *user_dir[2] = { 0, 0 };
Packit Service 50ad14
		while (ev) {
Packit Service 50ad14
			int rc;
Packit Service 50ad14
			char *t = strchr(ev, ':');
Packit Service 50ad14
			char sv = 0;
Packit Service 50ad14
			if (t) {
Packit Service 50ad14
				sv = *t;
Packit Service 50ad14
				*t = 0;
Packit Service 50ad14
			}
Packit Service 50ad14
			user_dir[0] = ev;
Packit Service 50ad14
			if (*ev)
Packit Service 50ad14
				rc = lk_findfile(s, user_dir, include_suffixes, fp);
Packit Service 50ad14
			else	/* empty string denotes system path */
Packit Service 50ad14
				rc = find_standard_incl_file(ctx, s, fp);
Packit Service 50ad14
Packit Service 50ad14
			if (rc <= 0)
Packit Service 50ad14
				return rc;
Packit Service 50ad14
			if (t)
Packit Service 50ad14
				*t++ = sv;
Packit Service 50ad14
			ev = t;
Packit Service 50ad14
		}
Packit Service 50ad14
		return 1;
Packit Service 50ad14
	}
Packit Service 50ad14
	return find_standard_incl_file(ctx, s, fp);
Packit Service 50ad14
}
Packit Service 50ad14
Packit Service 50ad14
static int
Packit Service 50ad14
open_include(struct lk_ctx *ctx, char *s, yyscan_t scanner)
Packit Service 50ad14
{
Packit Service 50ad14
	int rc;
Packit Service 50ad14
	lkfile_t *fp;
Packit Service 50ad14
Packit Service 50ad14
	INFO(ctx, _("switching to %s"), s);
Packit Service 50ad14
Packit Service 50ad14
	fp = malloc(sizeof(lkfile_t));
Packit Service 50ad14
	if (!fp) {
Packit Service 50ad14
		ERR(ctx, _("out of memory"));
Packit Service 50ad14
		return -1;
Packit Service 50ad14
	}
Packit Service 50ad14
	memset(fp, 0, sizeof(lkfile_t));
Packit Service 50ad14
Packit Service 50ad14
	rc = find_incl_file(ctx, s, fp);
Packit Service 50ad14
	if (rc > 0) {
Packit Service 50ad14
		ERR(ctx, _("cannot open include file %s"), s);
Packit Service 50ad14
		free(s);
Packit Service 50ad14
		return -1;
Packit Service 50ad14
	} else if (rc == -1) {
Packit Service 50ad14
		free(s);
Packit Service 50ad14
		return -1;
Packit Service 50ad14
	}
Packit Service 50ad14
Packit Service 50ad14
	free(s);
Packit Service 50ad14
Packit Service 50ad14
	return stack_push(ctx, fp, scanner);
Packit Service 50ad14
}
Packit Service 50ad14
Packit Service 50ad14
%}
Packit Service 50ad14
%s RVALUE
Packit Service 50ad14
%x STR
Packit Service 50ad14
%x INCLSTR
Packit Service 50ad14
Comment			#|!
Packit Service 50ad14
Continuation		\\\n
Packit Service 50ad14
Eol			\n
Packit Service 50ad14
Blank			[ \t]
Packit Service 50ad14
Include			include[ \t]*
Packit Service 50ad14
Decimal			[1-9][0-9]*
Packit Service 50ad14
Octal			0[0-7]*
Packit Service 50ad14
Hex			0[xX][0-9a-fA-F]+
Packit Service 50ad14
Unicode			U\+([0-9a-fA-F]){4}
Packit Service 50ad14
Literal			[a-zA-Z][a-zA-Z_0-9]*
Packit Service 50ad14
Octa			([0-7]){1,3}
Packit Service 50ad14
Charset			charset|Charset|CharSet|CHARSET
Packit Service 50ad14
Keymaps			keymaps|Keymaps|KeyMaps|KEYMAPS
Packit Service 50ad14
Keycode			keycode|Keycode|KeyCode|KEYCODE
Packit Service 50ad14
String			string|String|STRING
Packit Service 50ad14
Equals			=
Packit Service 50ad14
Plain			plain|Plain|PLAIN
Packit Service 50ad14
Shift			shift|Shift|SHIFT
Packit Service 50ad14
Control			control|Control|CONTROL
Packit Service 50ad14
Alt			alt|Alt|ALT
Packit Service 50ad14
AltGr			altgr|Altgr|AltGr|ALTGR
Packit Service 50ad14
ShiftL			shiftl|ShiftL|SHIFTL
Packit Service 50ad14
ShiftR			shiftr|ShiftR|SHIFTR
Packit Service 50ad14
CtrlL			ctrll|CtrlL|CTRLL
Packit Service 50ad14
CtrlR			ctrlr|CtrlR|CTRLR
Packit Service 50ad14
CapsShift		capsshift|Capsshift|CapsShift|CAPSSHIFT
Packit Service 50ad14
AltIsMeta		[aA][lL][tT][-_][iI][sS][-_][mM][eE][tT][aA]
Packit Service 50ad14
Strings			strings|Strings|STRINGS
Packit Service 50ad14
Compose			compose|Compose|COMPOSE
Packit Service 50ad14
As			as|As|AS
Packit Service 50ad14
Usual			usual|Usual|USUAL
Packit Service 50ad14
For			for|For|FOR
Packit Service 50ad14
On			on|On|ON
Packit Service 50ad14
To                      to|To|TO
Packit Service 50ad14
Packit Service 50ad14
%%
Packit Service 50ad14
Packit Service 50ad14
{Include}		{
Packit Service 50ad14
				yy_push_state(INCLSTR, yyscanner);
Packit Service 50ad14
			}
Packit Service 50ad14
<INCLSTR>\"[^\"\n]+\"	{
Packit Service 50ad14
				char *s = strndup(yytext+1, strlen(yytext)-2);
Packit Service 50ad14
				if (s == NULL) {
Packit Service 50ad14
					ERR(yyextra, _("out of memory"));
Packit Service 50ad14
					return(ERROR);
Packit Service 50ad14
				}
Packit Service 50ad14
Packit Service 50ad14
				if (open_include(yyextra, s, yyscanner) == -1)
Packit Service 50ad14
					return(ERROR);
Packit Service 50ad14
Packit Service 50ad14
				while (((struct yyguts_t*)yyscanner)->yy_start_stack_ptr) {
Packit Service 50ad14
					yy_pop_state(yyscanner);
Packit Service 50ad14
				}
Packit Service 50ad14
			}
Packit Service 50ad14
<INCLSTR>[^"]|\"\"|\"[^"\n]*{Eol}	{
Packit Service 50ad14
				ERR(yyextra, _("expected filename between quotes"));
Packit Service 50ad14
				return(ERROR);
Packit Service 50ad14
			}
Packit Service 50ad14
<<EOF>>			{
Packit Service 50ad14
				stack_pop(yyextra, yyscanner);
Packit Service 50ad14
				if (!YY_CURRENT_BUFFER)
Packit Service 50ad14
					yyterminate();
Packit Service 50ad14
			}
Packit Service 50ad14
{Continuation}		{
Packit Service 50ad14
				yyset_lineno(yyget_lineno(yyscanner) + 1, yyscanner);
Packit Service 50ad14
			}
Packit Service 50ad14
{Eol}			{
Packit Service 50ad14
				yyset_lineno(yyget_lineno(yyscanner) + 1, yyscanner);
Packit Service 50ad14
Packit Service 50ad14
				while (((struct yyguts_t*)yyscanner)->yy_start_stack_ptr) {
Packit Service 50ad14
					yy_pop_state(yyscanner);
Packit Service 50ad14
				}
Packit Service 50ad14
				return(EOL);
Packit Service 50ad14
			}
Packit Service 50ad14
{Blank}+		; /* do nothing */
Packit Service 50ad14
{Comment}.*/{Eol}	; /* do nothing */
Packit Service 50ad14
{Equals}		{
Packit Service 50ad14
				yy_push_state(RVALUE, yyscanner);
Packit Service 50ad14
				lk_array_empty(yyextra->key_line);
Packit Service 50ad14
				return(EQUALS);
Packit Service 50ad14
			}
Packit Service 50ad14
{String}		{
Packit Service 50ad14
				yy_push_state(RVALUE, yyscanner);
Packit Service 50ad14
				return(STRING);
Packit Service 50ad14
			}
Packit Service 50ad14
{To}			{
Packit Service 50ad14
				yy_push_state(RVALUE, yyscanner);
Packit Service 50ad14
				return(TO);
Packit Service 50ad14
			}
Packit Service 50ad14
{Unicode}		{
Packit Service 50ad14
				yylval->num = strtol(yytext + 1, NULL, 16);
Packit Service 50ad14
				if (yylval->num >= 0xf000) {
Packit Service 50ad14
					ERR(yyextra, _("unicode keysym out of range: %s"),
Packit Service 50ad14
						yytext);
Packit Service 50ad14
					return(ERROR);
Packit Service 50ad14
				}
Packit Service 50ad14
				return(UNUMBER);
Packit Service 50ad14
			}
Packit Service 50ad14
{Decimal}|{Octal}|{Hex}	{
Packit Service 50ad14
				yylval->num = strtol(yytext, NULL, 0);
Packit Service 50ad14
				return(NUMBER);
Packit Service 50ad14
			}
Packit Service 50ad14
<RVALUE>{Literal}	{	return((yylval->num = ksymtocode(yyextra, yytext, TO_AUTO)) == -1 ? ERROR : LITERAL);	}
Packit Service 50ad14
\-			{	return(DASH);		}
Packit Service 50ad14
\,			{	return(COMMA);		}
Packit Service 50ad14
\+			{	return(PLUS);		}
Packit Service 50ad14
{Charset}		{	return(CHARSET);	}
Packit Service 50ad14
{Keymaps}		{	return(KEYMAPS);	}
Packit Service 50ad14
{Keycode}		{	return(KEYCODE);	}
Packit Service 50ad14
{Plain}			{	return(PLAIN);		}
Packit Service 50ad14
{Shift}			{	return(SHIFT);		}
Packit Service 50ad14
{Control}		{	return(CONTROL);	}
Packit Service 50ad14
{Alt}			{	return(ALT);		}
Packit Service 50ad14
{AltGr}			{	return(ALTGR);		}
Packit Service 50ad14
{ShiftL}		{	return(SHIFTL);		}
Packit Service 50ad14
{ShiftR}		{	return(SHIFTR);		}
Packit Service 50ad14
{CtrlL}			{	return(CTRLL);		}
Packit Service 50ad14
{CtrlR}			{	return(CTRLR);		}
Packit Service 50ad14
{CapsShift}		{	return(CAPSSHIFT);	}
Packit Service 50ad14
{AltIsMeta}		{	return(ALT_IS_META);	}
Packit Service 50ad14
{Strings}		{	return(STRINGS);	}
Packit Service 50ad14
{Compose}		{	return(COMPOSE);	}
Packit Service 50ad14
{As}			{	return(AS);		}
Packit Service 50ad14
{Usual}			{	return(USUAL);		}
Packit Service 50ad14
{On}			{	return(ON);		}
Packit Service 50ad14
{For}			{	return(FOR);		}
Packit Service 50ad14
'\\{Octa}'              {
Packit Service 50ad14
				yylval->num = strtol(yytext + 2, NULL, 8);
Packit Service 50ad14
				return(CCHAR);
Packit Service 50ad14
			}
Packit Service 50ad14
'\\.'                   {
Packit Service 50ad14
				yylval->num = (unsigned char) yytext[2];
Packit Service 50ad14
				return(CCHAR);
Packit Service 50ad14
			}
Packit Service 50ad14
'.'                     {
Packit Service 50ad14
				yylval->num = (unsigned char) yytext[1];
Packit Service 50ad14
				return(CCHAR);
Packit Service 50ad14
			}
Packit Service 50ad14
\"			{
Packit Service 50ad14
				yylval->str.data[0] = '\0';
Packit Service 50ad14
				yylval->str.len = 0;
Packit Service 50ad14
Packit Service 50ad14
				yy_push_state(STR, yyscanner);
Packit Service 50ad14
			}
Packit Service 50ad14
<STR>\\{Octa}		{
Packit Service 50ad14
				if (yylval->str.len == MAX_PARSER_STRING) {
Packit Service 50ad14
					ERR(yyextra, _("string too long"));
Packit Service 50ad14
					return(ERROR);
Packit Service 50ad14
				}
Packit Service 50ad14
				yylval->str.data[yylval->str.len++] = strtol(yytext + 1, NULL, 8);
Packit Service 50ad14
			}
Packit Service 50ad14
<STR>\\\"               {
Packit Service 50ad14
				if (yylval->str.len == MAX_PARSER_STRING) {
Packit Service 50ad14
					ERR(yyextra, _("string too long"));
Packit Service 50ad14
					return(ERROR);
Packit Service 50ad14
				}
Packit Service 50ad14
				yylval->str.data[yylval->str.len++] = '"';
Packit Service 50ad14
			}
Packit Service 50ad14
<STR>\\\\               {
Packit Service 50ad14
				if (yylval->str.len == MAX_PARSER_STRING) {
Packit Service 50ad14
					ERR(yyextra, _("string too long"));
Packit Service 50ad14
					return(ERROR);
Packit Service 50ad14
				}
Packit Service 50ad14
				yylval->str.data[yylval->str.len++] = '\\';
Packit Service 50ad14
			}
Packit Service 50ad14
<STR>\\n		{
Packit Service 50ad14
				if (yylval->str.len == MAX_PARSER_STRING) {
Packit Service 50ad14
					ERR(yyextra, _("string too long"));
Packit Service 50ad14
					return(ERROR);
Packit Service 50ad14
				}
Packit Service 50ad14
				yylval->str.data[yylval->str.len++] = '\n';
Packit Service 50ad14
			}
Packit Service 50ad14
<STR>[^\"\\]*		{
Packit Service 50ad14
				int len = strlen(yytext);
Packit Service 50ad14
Packit Service 50ad14
				if (yylval->str.len + len >= MAX_PARSER_STRING) {
Packit Service 50ad14
					ERR(yyextra, _("string too long"));
Packit Service 50ad14
					return(ERROR);
Packit Service 50ad14
				}
Packit Service 50ad14
Packit Service 50ad14
				strcpy((char *) yylval->str.data + yylval->str.len, yytext);
Packit Service 50ad14
				yylval->str.len += len;
Packit Service 50ad14
			}
Packit Service 50ad14
<STR>\"			{
Packit Service 50ad14
				yylval->str.data[yylval->str.len] = '\0';
Packit Service 50ad14
				while (((struct yyguts_t*)yyscanner)->yy_start_stack_ptr) {
Packit Service 50ad14
					yy_pop_state(yyscanner);
Packit Service 50ad14
				}
Packit Service 50ad14
				return(STRLITERAL);
Packit Service 50ad14
			}
Packit Service 50ad14
.			{
Packit Service 50ad14
				return(ERROR);
Packit Service 50ad14
			}
Packit Service 50ad14
%%