yyast/count.h File Reference

#include <yyast/types.h>

Go to the source code of this file.

Defines

#define YA_MAX_NR_FILENAMES   65536
 Maximum number of source filenames being tracked.
#define YY_USER_ACTION   { yylval = ya_count(yytext, yyleng); }
 Count columns and lines for each token found by lex.

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
ya_position_t ya_current_position


Define Documentation

#define YA_MAX_NR_FILENAMES   65536

Maximum number of source filenames being tracked.

Definition at line 32 of file count.h.

Referenced by ya_get_file_nr().

#define YY_USER_ACTION   { yylval = ya_count(yytext, yyleng); }

Count columns and lines for each token found by lex.

Definition at line 77 of file count.h.


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().

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