<commit_before>/*
 * Copyright 2020 <NAME>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

#include <ctype.h>
#include "parser.h"
#include "helper.h"
#include "token.h"

#define _check(v) { int _ret = v; if (_ret) { return _ret; }};

#ifdef DEBUG
#include <stdio.h>
#define debugf(...) fprintf(stderr, __VA_ARGS__)
#else
#define debugf (void)sizeof
#endif


static tokendef td; 
static prsr_callback callback;
static int top_context;

static int consume_statement(int);
static int consume_expr_group(int);
static int consume_optional_expr(int);
static int consume_class(int);
static int consume_module_list(int);
static int consume_function(int);
static int consume_expr_compound(int);

static inline void internal_next_comment() {
  for (;;) {
    int out = prsr_next(&td);
    if (out != TOKEN_COMMENT) {
      break;
    }
    callback(0);
  }
}

// yields previous, places the next useful token in curr, skipping comments
static void internal_next() {
  callback(0);
  internal_next_comment();
}<commit_msg>note on speed<commit_after>/*
 * Copyright 2020 <NAME>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

#include <ctype.h>
#include "parser.h"
#include "helper.h"
#include "token.h"

#define _check(v) { int _ret = v; if (_ret) { return _ret; }};

#ifdef DEBUG
#include <stdio.h>
#define debugf(...) fprintf(stderr, __VA_ARGS__)
#else
#define debugf (void)sizeof
#endif


static tokendef td;
static prsr_callback callback;  // TODO: calling FP adds about 5%
static int top_context;

static int consume_statement(int);
static int consume_expr_group(int);
static int consume_optional_expr(int);
static int consume_class(int);
static int consume_module_list(int);
static int consume_function(int);
static int consume_expr_compound(int);

static inline void internal_next_comment() {
  for (;;) {
    int out = prsr_next(&td);
    if (out != TOKEN_COMMENT) {
      break;
    }
    callback(0);
  }
}

// yields previous, places the next useful token in curr, skipping comments
static void internal_next() {
  callback(0);
  internal_next_comment();
}
{'fraction_non_alphanumeric': 0.10362694300518134, 'fraction_numerical': 0.006800518134715026, 'mean_word_length': 4.362847222222222, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1489901', 'n_tokens_mistral': 938, 'n_tokens_neox': 916, 'n_words': 350}