summaryrefslogtreecommitdiff
path: root/openbox/cparse.l
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-03-26 04:23:17 +0000
committerDana Jansens <danakj@orodu.net>2003-03-26 04:23:17 +0000
commit37a9456f87b6c4efd00b273f0ca2cbd8416fc5d0 (patch)
tree820e694cafbdebfee1b8edf251e3fd7a122799bf /openbox/cparse.l
parenta7ec81b7980d31918580dafbc02fe27550a096d0 (diff)
usnig flex directly, renaming symbols so that theres no clash with other lexers
Diffstat (limited to 'openbox/cparse.l')
-rw-r--r--openbox/cparse.l46
1 files changed, 23 insertions, 23 deletions
diff --git a/openbox/cparse.l b/openbox/cparse.l
index fcc72f06..966fc6e4 100644
--- a/openbox/cparse.l
+++ b/openbox/cparse.l
@@ -2,8 +2,8 @@
#include <glib.h>
#include "config.h"
-static char *yyfilename;
-static int yylineno = 1;
+static char *filename;
+static int lineno = 1;
static gboolean haserror = FALSE;
static gboolean comment = FALSE;
static ConfigEntry entry = { NULL, -1 };
@@ -13,7 +13,7 @@ static void numbervalue();
static void boolvalue();
static void identifier();
static void newline();
-static int yywrap();
+static int cparsewrap();
%}
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();
{string}/{white}\n stringvalue();
{number}/{white}\n numbervalue();
@@ -42,12 +42,12 @@ static void stringvalue()
if (!comment) {
if (!haserror && entry.name != NULL && (signed)entry.type < 0) {
entry.type = Config_String;
- entry.value.string = g_strdup(yytext+1); /* drop the left quote */
- if (entry.value.string[yyleng-2] != '"')
+ entry.value.string = g_strdup(cparsetext+1); /* drop the left quote */
+ if (entry.value.string[cparseleng-2] != '"')
printf("warning: improperly terminated string on line %d\n",
- yylineno);
+ lineno);
else
- entry.value.string[yyleng-2] = '\0';
+ entry.value.string[cparseleng-2] = '\0';
} else
haserror = TRUE;
}
@@ -58,7 +58,7 @@ static void numbervalue()
if (!comment) {
if (!haserror && entry.name != NULL && (signed)entry.type < 0) {
entry.type = Config_Integer;
- entry.value.integer = atoi(yytext);
+ entry.value.integer = atoi(cparsetext);
} else
haserror = TRUE;
}
@@ -69,9 +69,9 @@ static void boolvalue()
if (!comment) {
if (!haserror && entry.name != NULL && (signed)entry.type < 0) {
entry.type = Config_Bool;
- entry.value.bool = (!g_ascii_strcasecmp("true", yytext) ||
- !g_ascii_strcasecmp("yes", yytext) ||
- !g_ascii_strcasecmp("on", yytext));
+ entry.value.bool = (!g_ascii_strcasecmp("true", cparsetext) ||
+ !g_ascii_strcasecmp("yes", cparsetext) ||
+ !g_ascii_strcasecmp("on", cparsetext));
} else
haserror = TRUE;
}
@@ -80,7 +80,7 @@ static void boolvalue()
static void identifier()
{
if (!comment) {
- entry.name = g_strdup(yytext);
+ entry.name = g_strdup(cparsetext);
entry.type = -1;
}
}
@@ -90,10 +90,10 @@ static void newline()
if (!comment) {
if (!haserror && entry.name != NULL && (signed)entry.type >= 0) {
if (!config_set(entry.name, entry.type, entry.value))
- g_warning("Parser error in '%s' on line %d\n", yyfilename,
- yylineno);
- } else {
- g_warning("Parser error in '%s' on line %d", yyfilename, yylineno);
+ g_warning("Parser error in '%s' on line %d\n", filename,
+ lineno);
+ } else if (haserror || entry.name != NULL || (signed)entry.type >= 0) {
+ g_warning("Parser error in '%s' on line %d", filename, lineno);
}
g_free(entry.name);
entry.name = NULL;
@@ -104,10 +104,10 @@ static void newline()
haserror = FALSE;
}
comment = FALSE;
- ++yylineno;
+ ++lineno;
}
-static int yywrap()
+static int cparsewrap()
{
g_free(entry.name);
entry.name = NULL;
@@ -116,9 +116,9 @@ static int yywrap()
return 1;
}
-void cparse_go(char *filename, FILE *file)
+void cparse_go(char *fname, FILE *file)
{
- yyfilename = filename;
- yyin = file;
- yylex();
+ filename = fname;
+ cparsein = file;
+ cparselex();
}