parser: remove debug messages

The new parser is proven by now (v4.2 was released 4 months ago), so
removing these messages will make the logfile more readable.
This commit is contained in:
Michael Stapelberg 2012-08-04 16:31:57 +02:00
parent fb4ee17b05
commit 1d95d296a5
1 changed files with 1 additions and 15 deletions

View File

@ -104,7 +104,6 @@ static void push_string(const char *identifier, char *str) {
// XXX: ideally, this would be const char. need to check if that works with all // XXX: ideally, this would be const char. need to check if that works with all
// called functions. // called functions.
static char *get_string(const char *identifier) { static char *get_string(const char *identifier) {
DLOG("Getting string %s from stack...\n", identifier);
for (int c = 0; c < 10; c++) { for (int c = 0; c < 10; c++) {
if (stack[c].identifier == NULL) if (stack[c].identifier == NULL)
break; break;
@ -115,7 +114,6 @@ static char *get_string(const char *identifier) {
} }
static void clear_stack(void) { static void clear_stack(void) {
DLOG("clearing stack.\n");
for (int c = 0; c < 10; c++) { for (int c = 0; c < 10; c++) {
if (stack[c].str != NULL) if (stack[c].str != NULL)
free(stack[c].str); free(stack[c].str);
@ -187,8 +185,6 @@ static struct CommandResult command_output;
static void next_state(const cmdp_token *token) { static void next_state(const cmdp_token *token) {
if (token->next_state == __CALL) { if (token->next_state == __CALL) {
DLOG("should call stuff, yay. call_id = %d\n",
token->extra.call_identifier);
subcommand_output.json_gen = command_output.json_gen; subcommand_output.json_gen = command_output.json_gen;
subcommand_output.needs_tree_render = false; subcommand_output.needs_tree_render = false;
GENERATED_call(token->extra.call_identifier, &subcommand_output); GENERATED_call(token->extra.call_identifier, &subcommand_output);
@ -208,7 +204,7 @@ static void next_state(const cmdp_token *token) {
/* TODO: Return parsing errors via JSON. */ /* TODO: Return parsing errors via JSON. */
struct CommandResult *parse_command(const char *input) { struct CommandResult *parse_command(const char *input) {
DLOG("new parser handling: %s\n", input); DLOG("COMMAND: *%s*\n", input);
state = INITIAL; state = INITIAL;
/* A YAJL JSON generator used for formatting replies. */ /* A YAJL JSON generator used for formatting replies. */
@ -240,19 +236,14 @@ struct CommandResult *parse_command(const char *input) {
*walk == '\r' || *walk == '\n') && *walk != '\0') *walk == '\r' || *walk == '\n') && *walk != '\0')
walk++; walk++;
DLOG("remaining input = %s\n", walk);
cmdp_token_ptr *ptr = &(tokens[state]); cmdp_token_ptr *ptr = &(tokens[state]);
token_handled = false; token_handled = false;
for (c = 0; c < ptr->n; c++) { for (c = 0; c < ptr->n; c++) {
token = &(ptr->array[c]); token = &(ptr->array[c]);
DLOG("trying token %d = %s\n", c, token->name);
/* A literal. */ /* A literal. */
if (token->name[0] == '\'') { if (token->name[0] == '\'') {
DLOG("literal\n");
if (strncasecmp(walk, token->name + 1, strlen(token->name) - 1) == 0) { if (strncasecmp(walk, token->name + 1, strlen(token->name) - 1) == 0) {
DLOG("found literal, moving to next state\n");
if (token->identifier != NULL) if (token->identifier != NULL)
push_string(token->identifier, sstrdup(token->name + 1)); push_string(token->identifier, sstrdup(token->name + 1));
walk += strlen(token->name) - 1; walk += strlen(token->name) - 1;
@ -265,7 +256,6 @@ struct CommandResult *parse_command(const char *input) {
if (strcmp(token->name, "string") == 0 || if (strcmp(token->name, "string") == 0 ||
strcmp(token->name, "word") == 0) { strcmp(token->name, "word") == 0) {
DLOG("parsing this as a string\n");
const char *beginning = walk; const char *beginning = walk;
/* Handle quoted strings (or words). */ /* Handle quoted strings (or words). */
if (*walk == '"') { if (*walk == '"') {
@ -310,7 +300,6 @@ struct CommandResult *parse_command(const char *input) {
} }
if (token->identifier) if (token->identifier)
push_string(token->identifier, str); push_string(token->identifier, str);
DLOG("str is \"%s\"\n", str);
/* If we are at the end of a quoted string, skip the ending /* If we are at the end of a quoted string, skip the ending
* double quote. */ * double quote. */
if (*walk == '"') if (*walk == '"')
@ -322,9 +311,7 @@ struct CommandResult *parse_command(const char *input) {
} }
if (strcmp(token->name, "end") == 0) { if (strcmp(token->name, "end") == 0) {
DLOG("checking for the end token.\n");
if (*walk == '\0' || *walk == ',' || *walk == ';') { if (*walk == '\0' || *walk == ',' || *walk == ';') {
DLOG("yes, indeed. end\n");
next_state(token); next_state(token);
token_handled = true; token_handled = true;
/* To make sure we start with an appropriate matching /* To make sure we start with an appropriate matching
@ -414,7 +401,6 @@ struct CommandResult *parse_command(const char *input) {
y(array_close); y(array_close);
DLOG("command_output.needs_tree_render = %d\n", command_output.needs_tree_render);
return &command_output; return &command_output;
} }