aboutsummaryrefslogtreecommitdiff
path: root/ell.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-05-19 09:48:53 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2017-05-21 13:19:46 +0200
commit53810d61f20296ce9ef207811e1180b6d10d7a24 (patch)
treee2f00421015c56ea1369766161cdd4663e8e7164 /ell.c
parente76b7139ff470397e73677ead237c86ddf56585d (diff)
downloadell-53810d61f20296ce9ef207811e1180b6d10d7a24.tar.gz
ell-53810d61f20296ce9ef207811e1180b6d10d7a24.tar.xz
ell-53810d61f20296ce9ef207811e1180b6d10d7a24.zip
Get rid of lexer_error()
Diffstat (limited to 'ell.c')
-rwxr-xr-xell.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/ell.c b/ell.c
index f34acdd..c1f784f 100755
--- a/ell.c
+++ b/ell.c
@@ -277,12 +277,6 @@ lexer_advance (struct lexer *self) {
return c;
}
-static inline bool
-lexer_error (const char **e, const char *message) {
- *e = message;
- return false;
-}
-
static bool
lexer_hexa_escape (struct lexer *self, struct buffer *output) {
int i;
@@ -307,11 +301,10 @@ lexer_hexa_escape (struct lexer *self, struct buffer *output) {
return true;
}
-static bool
-lexer_escape_sequence (struct lexer *self, struct buffer *output,
- const char **e) {
+static const char *
+lexer_escape_sequence (struct lexer *self, struct buffer *output) {
if (!self->len)
- return lexer_error (e, "premature end of escape sequence");
+ return "premature end of escape sequence";
unsigned char c = *self->p;
switch (c) {
@@ -329,30 +322,31 @@ lexer_escape_sequence (struct lexer *self, struct buffer *output,
case 'X':
lexer_advance (self);
if (lexer_hexa_escape (self, output))
- return true;
- return lexer_error (e, "invalid hexadecimal escape");
+ return NULL;
+ return "invalid hexadecimal escape";
default:
- return lexer_error (e, "unknown escape sequence");
+ return "unknown escape sequence";
}
buffer_append_c (output, c);
lexer_advance (self);
- return true;
+ return NULL;
}
-static bool
-lexer_string (struct lexer *self, struct buffer *output, const char **e) {
+static const char *
+lexer_string (struct lexer *self, struct buffer *output) {
unsigned char c;
+ const char *e = NULL;
while (self->len) {
if ((c = lexer_advance (self)) == '\'')
- return true;
+ return NULL;
if (c != '\\')
buffer_append_c (output, c);
- else if (!lexer_escape_sequence (self, output, e))
- return false;
+ else if ((e = lexer_escape_sequence (self, output)))
+ return e;
}
- return lexer_error (e, "premature end of string");
+ return "premature end of string";
}
static enum token
@@ -385,7 +379,7 @@ lexer_next (struct lexer *self, const char **e) {
case '\'':
lexer_advance (self);
- if (!lexer_string (self, &self->string, e))
+ if ((*e = lexer_string (self, &self->string)))
return T_ABORT;
return T_STRING;
}