Skip to content

Commit

Permalink
fix: mark all helper functions static (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Jul 29, 2023
1 parent a41a933 commit 2ca8c12
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 149 deletions.
Binary file modified docs/js/tree-sitter-rst.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion src/scanner.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <tree_sitter/parser.h>
#include "tree_sitter/parser.h"

#include "tree_sitter_rst/scanner.c"
#include "tree_sitter_rst/tokens.h"
Expand Down
48 changes: 24 additions & 24 deletions src/tree_sitter_rst/chars.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "chars.h"
#include <string.h>

bool is_newline(int32_t c)
static bool is_newline(int32_t c)
{
const int32_t newline_chars[] = {
CHAR_EOF,
Expand All @@ -17,7 +17,7 @@ bool is_newline(int32_t c)
return false;
}

bool is_space(int32_t c)
static bool is_space(int32_t c)
{
const int32_t space_chars[] = {
CHAR_SPACE,
Expand All @@ -37,41 +37,41 @@ bool is_space(int32_t c)
return is_space_char || is_newline(c);
}

bool is_number(int32_t c)
static bool is_number(int32_t c)
{
const int32_t upper = 48;
const int32_t lower = 57;
return c >= upper && c <= lower;
}

bool is_abc_lower(int32_t c)
static bool is_abc_lower(int32_t c)
{
const int32_t upper = 97;
const int32_t lower = 122;
return c >= upper && c <= lower;
}

bool is_abc_upper(int32_t c)
static bool is_abc_upper(int32_t c)
{
const int32_t upper = 65;
const int32_t lower = 90;
return c >= upper && c <= lower;
}

bool is_abc(int32_t c)
static bool is_abc(int32_t c)
{
return is_abc_lower(c) || is_abc_upper(c);
}

bool is_alphanumeric(int32_t c)
static bool is_alphanumeric(int32_t c)
{
return is_abc(c) || is_number(c);
}

/// Check if it's an adornment char.
///
/// Adorment characters are used for sections and transitions.
bool is_adornment_char(int32_t c)
static bool is_adornment_char(int32_t c)
{
const int32_t adornment_chars[] = {
'!',
Expand Down Expand Up @@ -119,7 +119,7 @@ bool is_adornment_char(int32_t c)
/// Check if it's a start char.
///
/// Some tokens can start after non-whitespace chars.
bool is_start_char(int32_t c)
static bool is_start_char(int32_t c)
{
const int32_t valid_chars[] = {
'-',
Expand All @@ -144,7 +144,7 @@ bool is_start_char(int32_t c)
/// Check if it's an end char.
///
/// Some tokens can end after non-whitespace chars.
bool is_end_char(int32_t c)
static bool is_end_char(int32_t c)
{
const int32_t valid_chars[] = {
'-',
Expand Down Expand Up @@ -172,7 +172,7 @@ bool is_end_char(int32_t c)
return false;
}

bool is_inline_markup_start_char(int32_t c)
static bool is_inline_markup_start_char(int32_t c)
{
const int32_t inline_markup_chars[] = {
'*', // *emphasis*, and **strong**.
Expand All @@ -190,7 +190,7 @@ bool is_inline_markup_start_char(int32_t c)
return false;
}

bool is_inline_markup_end_char(int32_t c)
static bool is_inline_markup_end_char(int32_t c)
{
const int32_t inline_markup_chars[] = {
'*', // *emphasis*, and **strong**.
Expand All @@ -211,7 +211,7 @@ bool is_inline_markup_end_char(int32_t c)
/// Check if it's an internal reference char.
///
/// References and some other names can't have two consecutive internal characters.
bool is_internal_reference_char(int32_t c)
static bool is_internal_reference_char(int32_t c)
{
const int32_t internal_chars[] = { '-', '_', '.', ':', '+' };
const int length = sizeof(internal_chars) / sizeof(int32_t);
Expand All @@ -226,7 +226,7 @@ bool is_internal_reference_char(int32_t c)
/// Check if it's a bullet char.
///
/// Lists use these characters to start an item.
bool is_char_bullet(int32_t c)
static bool is_char_bullet(int32_t c)
{
const int32_t bullets[] = {
'*',
Expand All @@ -248,7 +248,7 @@ bool is_char_bullet(int32_t c)
/// Check if it's a numeric bullet char.
///
/// Lists cacn use different number formats to start an item.
bool is_numeric_bullet(int32_t c)
static bool is_numeric_bullet(int32_t c)
{
return (
is_numeric_bullet_simple(c)
Expand All @@ -258,12 +258,12 @@ bool is_numeric_bullet(int32_t c)
|| is_numeric_bullet_abc_upper(c));
}

bool is_numeric_bullet_simple(int32_t c)
static bool is_numeric_bullet_simple(int32_t c)
{
return is_number(c) || c == '#';
}

bool is_numeric_bullet_roman_lower(int32_t c)
static bool is_numeric_bullet_roman_lower(int32_t c)
{
const int32_t valid_chars[] = {
'i',
Expand All @@ -283,7 +283,7 @@ bool is_numeric_bullet_roman_lower(int32_t c)
return false;
}

bool is_numeric_bullet_roman_upper(int32_t c)
static bool is_numeric_bullet_roman_upper(int32_t c)
{
const int32_t valid_chars[] = {
'I',
Expand All @@ -303,20 +303,20 @@ bool is_numeric_bullet_roman_upper(int32_t c)
return false;
}

bool is_numeric_bullet_abc_lower(int32_t c)
static bool is_numeric_bullet_abc_lower(int32_t c)
{
return is_abc_lower(c);
}

bool is_numeric_bullet_abc_upper(int32_t c)
static bool is_numeric_bullet_abc_upper(int32_t c)
{
return is_abc_upper(c);
}

/// Check if it's a valid attribution char.
///
/// Attribution chars are used to denot the author of a quote.
bool is_attribution_mark(int32_t c)
static bool is_attribution_mark(int32_t c)
{
const int32_t valid_chars[] = {
'-',
Expand All @@ -334,7 +334,7 @@ bool is_attribution_mark(int32_t c)
/// Get the current indentation level.
///
/// The scanner should be set to a char after a newline.
int get_indent_level(RSTScanner* scanner)
static int get_indent_level(RSTScanner* scanner)
{
int32_t current = scanner->lookahead;
int indent = 0;
Expand All @@ -354,7 +354,7 @@ int get_indent_level(RSTScanner* scanner)
return indent;
}

bool is_known_schema(char* string, unsigned string_len)
static bool is_known_schema(char* string, unsigned string_len)
{
char* valid_schemas[] = {
"http",
Expand All @@ -377,7 +377,7 @@ bool is_known_schema(char* string, unsigned string_len)
return false;
}

bool is_invalid_uri_char(int32_t c)
static bool is_invalid_uri_char(int32_t c)
{
const int32_t invalid_chars[] = {
'^',
Expand Down
56 changes: 28 additions & 28 deletions src/tree_sitter_rst/chars.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,37 @@
// number of spaces to expand a tab to
#define TAB_STOP 8

bool is_newline(int32_t c);
bool is_space(int32_t c);
bool is_number(int32_t c);
bool is_abc_lower(int32_t c);
bool is_abc_upper(int32_t c);
bool is_abc(int32_t c);
bool is_alphanumeric(int32_t c);

bool is_adornment_char(int32_t c);

bool is_start_char(int32_t c);
bool is_end_char(int32_t c);
bool is_inline_markup_start_char(int32_t c);
bool is_inline_markup_end_char(int32_t c);

bool is_internal_reference_char(int32_t c);

bool is_char_bullet(int32_t c);
bool is_numeric_bullet(int32_t c);
bool is_numeric_bullet_simple(int32_t c);
bool is_numeric_bullet_roman_lower(int32_t c);
bool is_numeric_bullet_roman_upper(int32_t c);
bool is_numeric_bullet_abc_lower(int32_t c);
bool is_numeric_bullet_abc_upper(int32_t c);
bool is_known_schema(char* string, unsigned strlen);
bool is_invalid_uri_char(int32_t c);
static bool is_newline(int32_t c);
static bool is_space(int32_t c);
static bool is_number(int32_t c);
static bool is_abc_lower(int32_t c);
static bool is_abc_upper(int32_t c);
static bool is_abc(int32_t c);
static bool is_alphanumeric(int32_t c);

static bool is_adornment_char(int32_t c);

static bool is_start_char(int32_t c);
static bool is_end_char(int32_t c);
static bool is_inline_markup_start_char(int32_t c);
static bool is_inline_markup_end_char(int32_t c);

static bool is_internal_reference_char(int32_t c);

static bool is_char_bullet(int32_t c);
static bool is_numeric_bullet(int32_t c);
static bool is_numeric_bullet_simple(int32_t c);
static bool is_numeric_bullet_roman_lower(int32_t c);
static bool is_numeric_bullet_roman_upper(int32_t c);
static bool is_numeric_bullet_abc_lower(int32_t c);
static bool is_numeric_bullet_abc_upper(int32_t c);
static bool is_known_schema(char* string, unsigned string_len);
static bool is_invalid_uri_char(int32_t c);

#define CHAR_EMDASH 8212

bool is_attribution_mark(int32_t c);
static bool is_attribution_mark(int32_t c);

int get_indent_level(RSTScanner* scanner);
static int get_indent_level(RSTScanner* scanner);

#endif /* ifndef TREE_SITTER_RST_CHARS_H_ */
Loading

0 comments on commit 2ca8c12

Please sign in to comment.