yyast/count.c File Reference

#include <string.h>
#include <sys/types.h>
#include <yyast/node.h>
#include <yyast/leaf.h>
#include <yyast/count.h>
#include <yyast/utils.h>

Go to the source code of this file.

Defines

#define _GNU_SOURCE

Functions

ya_t ya_count (char *s, size_t s_length)
 Count characters.
uint32_t ya_get_file_nr (char *filename)
 Get the file number of a filename.
void ya_reposition (char *s, size_t s_length)
 Reposition.
ya_t ya_get_filenames (void)
 Get a list of filenames, as a node that is placed in the header.
void ya_clear_position (ya_t *node)
 Clear the position of a node.

Variables

ya_position_t ya_previous_position = {0, 0, 0}
ya_position_t ya_current_position = {0, 0, 0}
char * ya_filenames [YA_MAX_NR_FILENAMES]
int ya_nr_filenames = 0


Define Documentation

#define _GNU_SOURCE

Definition at line 26 of file count.c.


Function Documentation

void ya_clear_position ( ya_t node  ) 

Clear the position of a node.

Parameters:
node The node to clear the position of.

Definition at line 146 of file count.c.

References ya_position_s::column, ya_position_s::file, ya_position_s::line, ya_t::node, ya_node_s::position, and ya_t::position.

Referenced by ya_get_filenames(), and ya_header().

ya_t ya_count ( char *  s,
size_t  s_length 
)

Count characters.

This functions keeps track of byte position, line and column. The byte, line and columns are zero index. This function works with UTF-8.

Parameters:
s The string to analyze
s_length The length of the string in bytes.
Returns:
An initialized ya structure without a node.

Definition at line 40 of file count.c.

References ya_position_s::column, ya_position_s::line, ya_t::node, ya_t::position, ya_t::size, ya_t::type, and YA_NODE_TYPE_COUNT.

uint32_t ya_get_file_nr ( char *  filename  ) 

Get the file number of a filename.

Adds the filename to the table when it was not found.

Parameters:
filename Filename to search in the source file list.
Returns:
The index of the filename in the source file list. Or UINT32_MAX if the table is full.

Definition at line 80 of file count.c.

References ya_filenames, YA_MAX_NR_FILENAMES, and ya_nr_filenames.

Referenced by ya_reposition().

ya_t ya_get_filenames ( void   ) 

Get a list of filenames, as a node that is placed in the header.

Returns:
A node with a list of filenames.

Definition at line 128 of file count.c.

References YA_BRANCH, ya_clear_position(), YA_EMPTYLIST, ya_filenames, YA_LIST, ya_nr_filenames, and ya_text().

Referenced by ya_header().

void ya_reposition ( char *  s,
size_t  s_length 
)

Reposition.

The given string is a reposition command, it contains the line number of the next line and optionally a filename.

The regex of s must match: [0-9]+\ "([^"]|\")*"

Definition at line 104 of file count.c.

References ya_position_s::column, ya_position_s::file, ya_position_s::line, and ya_get_file_nr().

Referenced by ya_main().


Variable Documentation

Definition at line 35 of file count.c.

Referenced by ya_error().

char* ya_filenames[YA_MAX_NR_FILENAMES]

Definition at line 37 of file count.c.

Referenced by ya_get_file_nr(), and ya_get_filenames().

int ya_nr_filenames = 0

Definition at line 38 of file count.c.

Referenced by ya_get_file_nr(), and ya_get_filenames().

Definition at line 34 of file count.c.

Referenced by ya_generic_nodev(), and ya_literal().


Generated for yyast-1.0.1 by doxygen 1.5.6