usnig flex directly, renaming symbols so that theres no clash with other lexers
This commit is contained in:
parent
a7ec81b798
commit
37a9456f87
3 changed files with 28 additions and 24 deletions
|
@ -24,3 +24,4 @@ config.rpath
|
||||||
py-compile
|
py-compile
|
||||||
ABOUT-NLS
|
ABOUT-NLS
|
||||||
compile
|
compile
|
||||||
|
lex.cparse.c
|
||||||
|
|
|
@ -27,12 +27,15 @@ openbox3_LDADD=@LIBINTL@ ../render/librender.a
|
||||||
openbox3_LDFLAGS=-export-dynamic
|
openbox3_LDFLAGS=-export-dynamic
|
||||||
openbox3_SOURCES=client.c event.c extensions.c focus.c frame.c openbox.c \
|
openbox3_SOURCES=client.c event.c extensions.c focus.c frame.c openbox.c \
|
||||||
prop.c screen.c stacking.c xerror.c timer.c dispatch.c \
|
prop.c screen.c stacking.c xerror.c timer.c dispatch.c \
|
||||||
engine.c plugin.c action.c grab.c cparse.l config.c
|
engine.c plugin.c action.c grab.c lex.cparse.c config.c
|
||||||
|
|
||||||
noinst_HEADERS=client.h event.h extensions.h focus.h frame.h geom.h gettext.h \
|
noinst_HEADERS=client.h event.h extensions.h focus.h frame.h geom.h gettext.h \
|
||||||
openbox.h prop.h screen.h stacking.h xerror.h dispatch.h \
|
openbox.h prop.h screen.h stacking.h xerror.h dispatch.h \
|
||||||
timer.h engine.h plugin.h action.h grab.h config.h
|
timer.h engine.h plugin.h action.h grab.h config.h
|
||||||
|
|
||||||
|
lex.cparse.c: cparse.l
|
||||||
|
$(FLEX) -Pcparse $^
|
||||||
|
|
||||||
MAINTAINERCLEANFILES= Makefile.in
|
MAINTAINERCLEANFILES= Makefile.in
|
||||||
|
|
||||||
distclean-local:
|
distclean-local:
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
static char *yyfilename;
|
static char *filename;
|
||||||
static int yylineno = 1;
|
static int lineno = 1;
|
||||||
static gboolean haserror = FALSE;
|
static gboolean haserror = FALSE;
|
||||||
static gboolean comment = FALSE;
|
static gboolean comment = FALSE;
|
||||||
static ConfigEntry entry = { NULL, -1 };
|
static ConfigEntry entry = { NULL, -1 };
|
||||||
|
@ -13,7 +13,7 @@ static void numbervalue();
|
||||||
static void boolvalue();
|
static void boolvalue();
|
||||||
static void identifier();
|
static void identifier();
|
||||||
static void newline();
|
static void newline();
|
||||||
static int yywrap();
|
static int cparsewrap();
|
||||||
%}
|
%}
|
||||||
|
|
||||||
number [0-9]+
|
number [0-9]+
|
||||||
|
@ -25,7 +25,7 @@ bool ([tT][rR][uU][eE]|[fF][aA][lL][sS][eE]|[yY][eE][sS]|[nN][oO]|[oO][nN]|[oO][
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
^# comment = TRUE;
|
^{white}# comment = TRUE;
|
||||||
{bool}/{white}\n boolvalue();
|
{bool}/{white}\n boolvalue();
|
||||||
{string}/{white}\n stringvalue();
|
{string}/{white}\n stringvalue();
|
||||||
{number}/{white}\n numbervalue();
|
{number}/{white}\n numbervalue();
|
||||||
|
@ -42,12 +42,12 @@ static void stringvalue()
|
||||||
if (!comment) {
|
if (!comment) {
|
||||||
if (!haserror && entry.name != NULL && (signed)entry.type < 0) {
|
if (!haserror && entry.name != NULL && (signed)entry.type < 0) {
|
||||||
entry.type = Config_String;
|
entry.type = Config_String;
|
||||||
entry.value.string = g_strdup(yytext+1); /* drop the left quote */
|
entry.value.string = g_strdup(cparsetext+1); /* drop the left quote */
|
||||||
if (entry.value.string[yyleng-2] != '"')
|
if (entry.value.string[cparseleng-2] != '"')
|
||||||
printf("warning: improperly terminated string on line %d\n",
|
printf("warning: improperly terminated string on line %d\n",
|
||||||
yylineno);
|
lineno);
|
||||||
else
|
else
|
||||||
entry.value.string[yyleng-2] = '\0';
|
entry.value.string[cparseleng-2] = '\0';
|
||||||
} else
|
} else
|
||||||
haserror = TRUE;
|
haserror = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ static void numbervalue()
|
||||||
if (!comment) {
|
if (!comment) {
|
||||||
if (!haserror && entry.name != NULL && (signed)entry.type < 0) {
|
if (!haserror && entry.name != NULL && (signed)entry.type < 0) {
|
||||||
entry.type = Config_Integer;
|
entry.type = Config_Integer;
|
||||||
entry.value.integer = atoi(yytext);
|
entry.value.integer = atoi(cparsetext);
|
||||||
} else
|
} else
|
||||||
haserror = TRUE;
|
haserror = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,9 @@ static void boolvalue()
|
||||||
if (!comment) {
|
if (!comment) {
|
||||||
if (!haserror && entry.name != NULL && (signed)entry.type < 0) {
|
if (!haserror && entry.name != NULL && (signed)entry.type < 0) {
|
||||||
entry.type = Config_Bool;
|
entry.type = Config_Bool;
|
||||||
entry.value.bool = (!g_ascii_strcasecmp("true", yytext) ||
|
entry.value.bool = (!g_ascii_strcasecmp("true", cparsetext) ||
|
||||||
!g_ascii_strcasecmp("yes", yytext) ||
|
!g_ascii_strcasecmp("yes", cparsetext) ||
|
||||||
!g_ascii_strcasecmp("on", yytext));
|
!g_ascii_strcasecmp("on", cparsetext));
|
||||||
} else
|
} else
|
||||||
haserror = TRUE;
|
haserror = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ static void boolvalue()
|
||||||
static void identifier()
|
static void identifier()
|
||||||
{
|
{
|
||||||
if (!comment) {
|
if (!comment) {
|
||||||
entry.name = g_strdup(yytext);
|
entry.name = g_strdup(cparsetext);
|
||||||
entry.type = -1;
|
entry.type = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,10 +90,10 @@ static void newline()
|
||||||
if (!comment) {
|
if (!comment) {
|
||||||
if (!haserror && entry.name != NULL && (signed)entry.type >= 0) {
|
if (!haserror && entry.name != NULL && (signed)entry.type >= 0) {
|
||||||
if (!config_set(entry.name, entry.type, entry.value))
|
if (!config_set(entry.name, entry.type, entry.value))
|
||||||
g_warning("Parser error in '%s' on line %d\n", yyfilename,
|
g_warning("Parser error in '%s' on line %d\n", filename,
|
||||||
yylineno);
|
lineno);
|
||||||
} else {
|
} else if (haserror || entry.name != NULL || (signed)entry.type >= 0) {
|
||||||
g_warning("Parser error in '%s' on line %d", yyfilename, yylineno);
|
g_warning("Parser error in '%s' on line %d", filename, lineno);
|
||||||
}
|
}
|
||||||
g_free(entry.name);
|
g_free(entry.name);
|
||||||
entry.name = NULL;
|
entry.name = NULL;
|
||||||
|
@ -104,10 +104,10 @@ static void newline()
|
||||||
haserror = FALSE;
|
haserror = FALSE;
|
||||||
}
|
}
|
||||||
comment = FALSE;
|
comment = FALSE;
|
||||||
++yylineno;
|
++lineno;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int yywrap()
|
static int cparsewrap()
|
||||||
{
|
{
|
||||||
g_free(entry.name);
|
g_free(entry.name);
|
||||||
entry.name = NULL;
|
entry.name = NULL;
|
||||||
|
@ -116,9 +116,9 @@ static int yywrap()
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cparse_go(char *filename, FILE *file)
|
void cparse_go(char *fname, FILE *file)
|
||||||
{
|
{
|
||||||
yyfilename = filename;
|
filename = fname;
|
||||||
yyin = file;
|
cparsein = file;
|
||||||
yylex();
|
cparselex();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue