Leonardus
Loading...
Searching...
No Matches
Functions | Variables
parser.l File Reference

The interpreter pass 1 in a single flex file. More...

#include <stdio.h>
#include <string.h>
#include <libgen.h>
#include <errno.h>
#include <quadmath.h>
#include <stdbool.h>
#include <sys/stat.h>
#include <unistd.h>
#include "determinations.h"
#include "dry.h"
+ Include dependency graph for parser.l:

Functions

static void unbackslash (char *p_str)
 String Cleaning 1.
 
static char * endofline (char *p_str)
 String Cleaning 2.
 
static char * norm_check_int (char *p_str)
 Normalization and range check for a string representation of an 128 bit integer.
 
static char * norm_check_rational (char *p_str)
 Normalization and range check for a string representation of a Leonardus rational number.
 
static int check_real (char *p_str)
 Range check for a string representation of an 128 bit float.
 
static bool is_directory (const char *p_path)
 Check if the given path is valid and readable.
 
int yylex (void)
 The generated scanner.
 
static enum ExitCode commandline (int argc, char **argv)
 Command line parsing.
 
int main (int argc, char *argv[])
 The parser main().
 
int yywrap (void)
 yywrap().
 

Variables

static int g_verbose = 0
 Global option "verbose".
 
static int g_suppressaec = 0
 Global option suppress ANSI escape codes.
 
static int g_linebuffer = 0
 Global option "line buffering".
 
static int g_helpprinted = 0
 Global status help printed

 
static char * g_basename = NULL
 My program file name.
 
static char * g_dirname = NULL
 My program path name.
 
static char * g_vocdir1 = NULL
 The path to the vocabularies.
 
static char * g_vocdir2 = NULL
 The path to the vocabularies.
 
static YY_BUFFER_STATE g_buffer_stack [16]
 A stack of buffers for the vocabulary nesting.
 
static FILE * g_file_stack [16]
 A stack of FILE * for the vocabulary nesting.
 
static int g_buffer_stack_top = -1
 Index into the stacks of buffers and FILE * for the vocabulary nesting.
 

Detailed Description

The interpreter pass 1 in a single flex file.

Function Documentation

◆ check_real()

static int check_real ( char *  p_str)
static

Range check for a string representation of an 128 bit float.

Parameters
[in]p_strString to check
Returns
int ... 0 for a valid string
ERANGE for overflows, underflows and general errors.

◆ commandline()

static enum ExitCode commandline ( int  argc,
char **  argv 
)
static

Command line parsing.

Parameters
[in]argcargc from main()
[in]argvargv from main()
Returns
enum ExitCode ... The defined program execution exit codes from dry.h.

< EC_SUCCESS string literal waiting for C++26.

< EC_INTERPRETER string literal waiting for C++26.

< EC_CMDLINE string literal waiting for C++26.

◆ endofline()

static char * endofline ( char *  p_str)
static

String Cleaning 2.

Substitutes all x0a characters by a "\n" sequence. The resulting string is returned in a new allocated storage, which has to be freed by the caller.

Parameters
[in,out]p_strThe string to be cleaned.
Returns
char * ... The resulting string.

◆ is_directory()

static bool is_directory ( const char *  p_path)
static

Check if the given path is valid and readable.

Parameters
[in]p_pathThe path to check.
Returns
bool ... true if the path is valid, oherwise false.

◆ main()

int main ( int  argc,
char *  argv[] 
)

The parser main().

Parameters
[in]argcUsual argc.
[in]argvUsual argv.
Returns
enum ExitCode ... The defined program execution exit codes from dry.h.

◆ norm_check_int()

static char * norm_check_int ( char *  p_str)
static

Normalization and range check for a string representation of an 128 bit integer.

Format of p_str is: [-]?[0-9]+

Parameters
[in]p_strString to check
Returns
char * ... Points somewhere into the normalized p_str buffer.
Is NULL if the range check fails.

◆ norm_check_rational()

static char * norm_check_rational ( char *  p_str)
static

Normalization and range check for a string representation of a Leonardus rational number.

Format of p_str is: {RATIONAL}

Parameters
[in]p_strString to check
Returns
char * ... Points somewhere into the normalized p_str buffer.
Is NULL if the range check fails.

◆ unbackslash()

static void unbackslash ( char *  p_str)
static

String Cleaning 1.

Removes all single backslashes from the string p_str, preserving double backslashes (\) and newline sequences (\n).
These are the only escape sequences recognized in the leon-format format.

Parameters
[in,out]p_strThe string to be cleaned.

◆ yywrap()

int yywrap ( void  )

yywrap().

Returns
int ... It returns 1 for true, then the scanner terminates, returning 0 to its caller.

Variable Documentation

◆ g_vocdir1

char* g_vocdir1 = NULL
static

The path to the vocabularies.

Version 1.

◆ g_vocdir2

char* g_vocdir2 = NULL
static

The path to the vocabularies.

Version 2.