summaryrefslogtreecommitdiff
path: root/src/defs.h.in
diff options
context:
space:
mode:
authorkx <kx@radix-linux.su>2026-09-30 21:14:58 +0300
committerkx <kx@radix-linux.su>2026-09-30 21:14:58 +0300
commit5b1c65152f77e03a4800fceae32d16efe2dadc9c (patch)
treecaffe4b2235503cccfedfb772dc266cb311840b3 /src/defs.h.in
parent8b354d2b9f2640d90705abd324a413a0d8fa3867 (diff)
downloadzubr-trunk.tar.xz
Version 4.1.0HEAD4.1.0trunk
Diffstat (limited to 'src/defs.h.in')
-rw-r--r--src/defs.h.in573
1 files changed, 573 insertions, 0 deletions
diff --git a/src/defs.h.in b/src/defs.h.in
new file mode 100644
index 0000000..9784f95
--- /dev/null
+++ b/src/defs.h.in
@@ -0,0 +1,573 @@
+
+/***************************************************************
+ DEFS.H
+
+ This file containt common declarations for ZUBR .
+
+ PART OF : ZUBR - Parsers generator for multiple syntax
+ language compilers .
+
+ COMPILE : .
+
+ NOTE : NONE .
+
+ Copyright (C) 1995 - 2026 by Andrey V.Kosteltsev.
+ All Rights Reserved.
+ ***************************************************************/
+/*
+ This file contant RUSSIAN letters( code-page: UTF-8 )
+ ***************************************************************/
+
+#ifndef _DEFS_H
+#define _DEFS_H
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h> /* exit() */
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_SIGNAL_H
+#include <signal.h> /* signal() */
+#endif
+
+#if HAVE_LIBMPU && HAVE_LIBMPUIO
+#include <libmpuio.h>
+#else
+#define __NO_COMPILE 1
+#endif
+
+#ifndef ZUBR_VERSION
+#define ZUBR_VERSION MPU_UCS2( "@ZUBR_VERSION@" )
+#endif
+#ifndef ZUBR_BITS_PER_INT
+#define ZUBR_BITS_PER_INT @ZUBR_BITS_PER_INT@
+#endif
+
+#ifndef NUL
+#define NUL 0
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __NO_COMPILE
+
+/***************************************************************
+ Определения PATH_SEPARATOR, DIR_SEPARATOR, IS_DIR_SEPARATOR
+ ***************************************************************/
+#ifndef PATH_SEPARATOR
+#define PATH_SEPARATOR ':'
+#endif
+
+#ifndef DIR_SEPARATOR
+#define DIR_SEPARATOR '/'
+#endif
+
+#ifndef IS_DIR_SEPARATOR
+#define IS_DIR_SEPARATOR(_c_) ((_c_) == ('/'))
+#endif
+
+#define COMMON_DIR_SEPARATOR ('/') /* Доступен в UNIX && Windows NT */
+
+#define MAXCHAR 0xffff /* maximum UCS-2 character value */
+#define MAXWORD 32767 /* 32767 maximum value of a short int */
+#define MINWORD (-32768) /* (-32767-1) minimum value of a short int */
+#define MAXTABLE 32500 /* от фонаря < SHRT_MAX */
+
+
+#undef _NOT_BIT_MACRO
+#undef _NON_COMPILE
+#if ZUBR_BITS_PER_INT == 64
+#define RPOW2 6
+/*************************************************************************
+
+ ... r[0]
+ --|------------------------------------------------------------------|
+ | 0000000000000000000000000000000000000000000000000000000000000000 |
+ --|------------------------------------------------------------------|
+ n: 63 0
+
+*************************************************************************/
+#else
+#if ZUBR_BITS_PER_INT == 32
+#define RPOW2 5
+/*************************************************************************
+
+ ... r[1] r[0]
+ --|----------------------------------|----------------------------------|
+ | 00000000000000000000000000000000 | 00000000000000000000000000000000 |
+ --|----------------------------------|----------------------------------|
+ n: 63 32 31 0
+
+ *************************************************************************/
+#else
+#if ZUBR_BITS_PER_INT == 16
+#define RPOW2 4
+/*************************************************************************
+
+ ... r[1] r[0]
+ --|------------------|------------------|
+ | 0000000000000000 | 0000000000000000 |
+ --|------------------|------------------|
+ n: 31 16 15 0
+
+ *************************************************************************/
+#else /* not (ZUBR_BITS_PER_INT == 16) */
+#define _NOT_BIT_MACRO 1
+#define _NON_COMPILE
+#endif /* ZUBR_BITS_PER_INT == 16 */
+#endif /* ZUBR_BITS_PER_INT == 32 */
+#endif /* ZUBR_BITS_PER_INT == 64 */
+
+#if !defined( _NOT_BIT_MACRO )
+#define SIZE_IN_INT(n) (((n)+(ZUBR_BITS_PER_INT-1))/ZUBR_BITS_PER_INT)
+#if defined( BIT ) || defined( SETBIT )
+#undef BIT
+#undef SETBIT
+#endif
+#define BIT(r,n) ((((r)[(n)>>RPOW2])>>((n)&(ZUBR_BITS_PER_INT-1)))&1)
+#define SETBIT(r,n) ((r)[(n)>>RPOW2]|=((unsigned)1<<((n)&(ZUBR_BITS_PER_INT-1))))
+#endif /* _NOT_BIT_MACRO */
+
+
+
+/******* character names ***********************************************/
+/* определены в configx.h
+ #define NUL '\0' - the null character
+ #define NEWLINE '\n' - line feed
+ #define SP ' ' - space
+ #define BS '\b' - backspace
+ #define HT '\t' - horizontal tab
+ #define VT '\013' - vertical tab
+ #define CR '\r' - carriage return
+ #define FF '\f' - form feed
+ #define QUOTE '\'' - single quote
+ #define DOUBLE_QUOTE '\"' - double quote
+ #define BACKSLASH '\\' - backslash
+ */
+
+/******* defines for constructing filenames ****************************/
+
+#define PROC_C_SUFFIX MPU_UCS2( ".c" )
+#define PROC_CPP_SUFFIX MPU_UCS2( ".cpp" )
+#define HEADER_SUFFIX MPU_UCS2( ".h" )
+#define CODE_SUFFIX MPU_UCS2( "_code" )
+#define DEFINES_SUFFIX MPU_UCS2( "_tab.h" )
+#define OUTPUT_SUFFIX MPU_UCS2( "_tab" )
+#define VERBOSE_SUFFIX MPU_UCS2( ".output" )
+#define MAX_SUFFIX_LEN 7 /* strlen( VERBOSE_SUFFIX ) */
+
+/******* keyword codes *************************************************/
+
+#define TOKEN 0
+#define LEFT 1
+#define RIGHT 2
+#define NONASSOC 3
+#define MARK 4
+#define TEXT 5
+#define TYPE 6
+#define START 7
+#define UNION 8
+#define IDENT 9
+
+
+/******* symbol classes ************************************************/
+
+#define UNKNOWN 0
+#define TERM 1
+#define NONTERM 2
+
+
+/******* the undefined value *******************************************/
+
+#define UNDEFINED (-1)
+
+
+/******* action codes **************************************************/
+
+#define SHIFT 1
+#define REDUCE 2
+
+
+/******* character macros **********************************************/
+
+#define IS_IDENT(c) (zubr_is_alnum(c) || (c) == '_' || (c) == '.' || (c) == '$')
+#define IS_OCTAL(c) ((c) >= '0' && (c) <= '7')
+
+#define NUMERIC_VALUE(c) ((c) - '0')
+
+
+/******* symbol macros *************************************************/
+
+#define ISTOKEN(s) ((s) < start_symbol)
+#define ISVAR(s) ((s) >= start_symbol)
+
+
+/******* the structure of a symbol table entry *************************/
+
+typedef struct bucket bucket;
+struct bucket
+{
+ struct bucket *link;
+ struct bucket *next;
+ __mpu_char16_t *name;
+ __mpu_char16_t *tag;
+
+ int value; /* old: short */
+ int index; /* old: short */
+ int prec; /* old: short */
+
+ char class;
+ char assoc;
+};
+
+
+/******* the structure of the LR(0) state machine **********************/
+
+typedef struct core core;
+struct core
+{
+ struct core *next;
+ struct core *link;
+
+ int number;
+ int accessing_symbol;
+ int nitems;
+ int items[1];
+};
+
+
+/******* the structure used to record shifts ***************************/
+
+typedef struct shifts shifts;
+struct shifts
+{
+ struct shifts *next;
+
+ int number;
+ int nshifts;
+ int shift[1];
+};
+
+
+/******* the structure used to store reductions ************************/
+
+typedef struct reductions reductions;
+struct reductions
+{
+ struct reductions *next;
+
+ int number;
+ int nreds;
+ int rules[1];
+};
+
+
+/******* the structure used to represent parser actions ****************/
+
+typedef struct action action;
+struct action
+{
+ struct action *next;
+
+ int symbol;
+ int number;
+ int prec;
+ char action_code;
+ char assoc;
+ char suppressed;
+};
+
+
+/*************************************************************************
+ global variables
+ *************************************************************************/
+
+/******* lalr.c ********************************************************/
+
+extern int *lookaheads;
+extern int *LAruleno;
+extern unsigned *LA;
+extern int *accessing_symbol;
+extern core **state_table;
+extern shifts **shift_table;
+extern reductions **reduction_table;
+extern int *goto_map;
+extern int *from_state;
+extern int *to_state;
+
+
+/******* lr0.c *********************************************************/
+
+extern int nstates;
+extern core *first_state;
+extern shifts *first_shift;
+extern reductions *first_reduction;
+
+
+/******* main.c ********************************************************/
+
+extern char bflag;
+extern char p_name_flag;
+extern char l_name_flag;
+extern char iflag;
+
+extern char dflag;
+extern char lflag;
+extern char pflag;
+extern char rflag;
+extern char sflag;
+extern char tflag;
+extern char vflag;
+
+
+
+extern __mpu_char16_t *myname;
+extern int lineno;
+extern int outline;
+
+extern __mpu_char16_t *parse_func_name;
+extern __mpu_char16_t *lex_func_name;
+extern __mpu_char16_t *inc_token_filename;
+extern __mpu_char16_t *name_prefix;
+extern __mpu_char16_t *name_prefix_upper;
+
+extern __mpu_char16_t *parse_header_file_name;
+extern __mpu_char16_t *action_file_name;
+extern __mpu_char16_t *text_file_name;
+extern __mpu_char16_t *union_file_name;
+extern __mpu_char16_t *input_file_name;
+extern __mpu_char16_t *output_file_name;
+extern __mpu_char16_t *defines_file_name;
+extern __mpu_char16_t *code_file_name;
+extern __mpu_char16_t *verbose_file_name;
+
+
+extern mpu_FILE *parse_header_file;
+extern mpu_FILE *action_file;
+extern mpu_FILE *text_file;
+extern mpu_FILE *union_file;
+extern mpu_FILE *input_file;
+extern mpu_FILE *output_file;
+extern mpu_FILE *defines_file;
+extern mpu_FILE *code_file;
+extern mpu_FILE *verbose_file;
+
+extern int nitems;
+extern int nrules;
+extern int nsyms;
+extern int ntokens;
+extern int nvars;
+
+extern int start_symbol;
+extern __mpu_char16_t **symbol_name;
+extern int *symbol_value;
+extern int *symbol_prec;
+extern char *symbol_assoc;
+
+extern int *ritem;
+extern int *rlhs;
+extern int *rrhs;
+extern int *rprec;
+extern char *rassoc;
+
+extern int **derives;
+extern char *nullable;
+
+
+/******* mkpar.c *******************************************************/
+
+extern action **parser;
+extern int SRtotal;
+extern int RRtotal;
+extern int *SRconflicts;
+extern int *RRconflicts;
+extern int *defred;
+extern int *rules_used;
+extern int nunused;
+extern int final_state;
+
+
+/******* reader.c ******************************************************/
+
+extern __mpu_char16_t *cptr;
+extern __mpu_char16_t *line;
+extern int ntags;
+extern char unionized;
+extern __mpu_char16_t line_format[];
+
+
+/******* skeleton.c ****************************************************/
+
+
+/******* symtab.c ******************************************************/
+
+extern bucket *first_symbol;
+extern bucket *last_symbol;
+
+
+/*************************************************************************
+ global functions
+ *************************************************************************/
+
+/******* error.c *******************************************************/
+
+extern void fatal( __mpu_char16_t *message );
+extern void fatal_reorder( __mpu_char16_t *fname );
+extern void no_space( void );
+extern void bad_fileprefix( __mpu_char16_t *s, int l );
+extern void bad_filename( __mpu_char16_t *s, int l );
+extern void bad_funcname( __mpu_char16_t *s, int l );
+extern void open_error( __mpu_char16_t *filename );
+extern void input_error( void );
+extern void unexpected_EOF( void );
+extern void print_pos( __mpu_char16_t *st_line, __mpu_char16_t *st_cptr );
+extern void syntax_error( int st_lineno, __mpu_char16_t *st_line, __mpu_char16_t *st_cptr );
+extern void unterminated_comment( int c_lineno, __mpu_char16_t *c_line, __mpu_char16_t *c_cptr );
+extern void unterminated_string( int s_lineno, __mpu_char16_t *s_line, __mpu_char16_t *s_cptr );
+extern void unterminated_text( int t_lineno, __mpu_char16_t *t_line, __mpu_char16_t *t_cptr ) __attribute__((noreturn));
+extern void unterminated_union( int u_lineno, __mpu_char16_t *u_line, __mpu_char16_t *u_cptr );
+extern void over_unionized( __mpu_char16_t *u_cptr );
+extern void illegal_character( __mpu_char16_t *c_cptr );
+extern void used_reserved( __mpu_char16_t *s );
+extern void illegal_tag( int t_lineno, __mpu_char16_t *t_line, __mpu_char16_t *t_cptr );
+extern void tokenized_start( __mpu_char16_t *s );
+extern void terminal_start( __mpu_char16_t *s );
+extern void no_grammar( void ) __attribute__((noreturn));
+extern void terminal_lhs( int s_lineno );
+extern void unterminated_action( int a_lineno, __mpu_char16_t *a_line, __mpu_char16_t *a_cptr ) __attribute__((noreturn));
+extern void untyped_lhs( void );
+extern void untyped_rhs( int i, __mpu_char16_t *s );
+extern void unknown_rhs( int i );
+extern void undefined_goal( __mpu_char16_t *s );
+extern void dollar_error( int a_lineno, __mpu_char16_t *a_line, __mpu_char16_t *a_cptr );
+
+extern void bad_option( __mpu_char16_t *s ) __attribute__((noreturn));
+extern void bad_code_page( __mpu_char16_t *s, __mpu_char16_t *p );
+
+
+/********** warnings **********/
+extern void dollar_warning( int a_lineno, int i );
+extern void retyped_warning( __mpu_char16_t *s );
+extern void reprec_warning( __mpu_char16_t *s );
+extern void revalued_warning( __mpu_char16_t *s );
+extern void restarted_warning( void );
+extern void default_action_warning( void );
+extern void undefined_symbol_warning( __mpu_char16_t *s );
+extern void prec_redeclared( void );
+
+/******* closure.c ****************************************************/
+
+extern void set_first_derives( void ); /* use in LR0.C */
+extern void closure( int *nucleus, int n ); /* use in LR0.C */
+extern void finalize_closure( void ); /* use in LR0.C */
+
+/******* lalr.c ********************************************************/
+
+extern void lalr( void );
+
+/******* lr0.c *********************************************************/
+
+extern void lr0( void );
+extern void free_nullable( void );
+extern void free_derives( void );
+
+/******* main.c ********************************************************/
+
+extern void done( int k ) __attribute__((noreturn));
+extern void onintr( int sig_number );
+extern void set_signals( void );
+extern void usage( void );
+extern void getargs( int argc, __mpu_char16_t *argv[] );
+extern char *allocate( unsigned n );
+extern void create_file_names( void );
+extern void open_files( void );
+
+/******* mkpar.c *******************************************************/
+
+extern void make_parser( void );
+extern void free_parser( void ); /* use in OUTPUT.C */
+
+/******* output.c ******************************************************/
+
+extern void output( void );
+
+/******* reader.c ******************************************************/
+
+extern void reader( void );
+
+/******* skeleton.c ****************************************************/
+
+extern void write_parse_name_definition( void );
+extern void write_parse_name_declaration( void );
+
+extern void write_banner( void );
+extern void write_extern_tables( void );
+extern void write_header( void );
+extern void write_header_definitions( void );
+extern void write_begin_body( void );
+extern void write_end_body( void );
+extern void write_trailer( void );
+
+/******* symtab.c ******************************************************/
+
+extern int hash( __mpu_char16_t *name );
+extern bucket * make_bucket( __mpu_char16_t *name );
+extern bucket * lookup( __mpu_char16_t *name ); /* use in READER.C */
+extern void create_symbol_table( void ); /* use in READER.C */
+extern void free_symbol_table( void ); /* use in READER.C */
+extern void free_symbols( void ); /* use in READER.C */
+
+/******* verbose.c *****************************************************/
+
+extern void verbose( void );
+
+/******* warshall.c ****************************************************/
+
+extern void reflexive_transitive_closure( unsigned *R, int n );
+ /* use in CLOSURE.C */
+
+/******* zubr-port.c ***************************************************/
+
+extern int zubr_is_alpha( __mpu_char16_t c );
+extern int zubr_is_alnum( __mpu_char16_t c );
+extern int zubr_is_digit( __mpu_char16_t c );
+extern int zubr_is_upper( __mpu_char16_t c );
+extern int zubr_is_print( __mpu_char16_t c );
+extern __mpu_char16_t zubr_to_lower( __mpu_char16_t c );
+extern __mpu_char16_t zubr_to_upper( __mpu_char16_t c );
+extern mpu_FILE *zubr_fopen( const __mpu_char16_t *filename, const char *mode );
+extern int zubr_unlink( const __mpu_char16_t *filename );
+extern __mpu_char16_t *zubr_getenv( const char *name );
+extern __mpu_char16_t *zubr_utf8_to_ucs2_dup( const char *s );
+
+
+/******* storage allocation macros *************************************/
+
+#define MALLOC(n) (malloc((size_t)(n)))
+#define CALLOC(k,n) (calloc((size_t)(k),(size_t)(n)))
+#define REALLOC(p,n) (realloc((void *)(p),(size_t)(n)))
+#define FREE(x) (free((void *)(x)))
+#define NEW(t) ((t*)allocate(sizeof(t)))
+#define NEW2(n,t) ((t*)allocate((unsigned)((n)*sizeof(t))))
+
+
+#endif /* __NO_COMPILE */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DEFS_H */
+
+/************************* END OF FILE DEFS.H **************************/