Kannel: Open Source WAP and SMS gateway  svn-r5335
wsint.h File Reference
#include "gw-config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <math.h>
#include "gwlib/gwassert.h"
#include "ws.h"
#include "wserror.h"
#include "wsutf8.h"
#include "wsieee754.h"
#include "wsbuffer.h"
#include "wsencode.h"
#include "wsalloc.h"
#include "wsfalloc.h"
#include "wsstream.h"
#include "wshash.h"
#include "wsbc.h"
#include "wsstree.h"
#include "wsasm.h"
#include "wsopt.h"
#include "wsstdlib.h"

Go to the source code of this file.

Data Structures

struct  WsContBreakRec
 
struct  WsCompilerRec
 

Macros

#define WS_LINE_TERMINATOR   "\n"
 
#define WS_INT8_MIN   -128
 
#define WS_INT8_MAX   127
 
#define WS_INT16_MIN   -32768
 
#define WS_INT16_MAX   32767
 
#define WS_INT32_MIN   -2147483648
 
#define WS_INT32_MAX   2147483647
 
#define WS_ERROR_B_MEMORY   0x01
 
#define WS_ERROR_B_SYNTAX   0x02
 
#define WS_ERROR_B_SEMANTIC   0x04
 
#define COMPILER_MAGIC   (0xfefe0101)
 

Typedefs

typedef unsigned char WsByte
 
typedef signed char WsInt8
 
typedef unsigned char WsUInt8
 
typedef signed short WsInt16
 
typedef unsigned short WsUInt16
 
typedef signed long WsInt32
 
typedef unsigned long WsUInt32
 
typedef double WsFloat
 
typedef struct WsContBreakRec WsContBreak
 
typedef struct WsCompilerRec WsCompiler
 

Enumerations

enum  WsBool { WS_FALSE, WS_TRUE }
 

Functions

int yylex ()
 
WsBool ws_lexer_register_block (WsCompiler *compiler, void *ptr)
 
WsBool ws_lexer_register_utf8 (WsCompiler *compiler, WsUtf8String *string)
 
void ws_lexer_free_block (WsCompiler *compiler, void *ptr)
 
void ws_lexer_free_utf8 (WsCompiler *compiler, WsUtf8String *string)
 
int ws_yy_parse (WsCompiler *compiler)
 

Macro Definition Documentation

◆ COMPILER_MAGIC

#define COMPILER_MAGIC   (0xfefe0101)

◆ WS_ERROR_B_MEMORY

#define WS_ERROR_B_MEMORY   0x01

Definition at line 138 of file wsint.h.

Referenced by ws_error_memory(), and ws_error_syntax().

◆ WS_ERROR_B_SEMANTIC

#define WS_ERROR_B_SEMANTIC   0x04

Definition at line 146 of file wsint.h.

Referenced by ws_src_error().

◆ WS_ERROR_B_SYNTAX

#define WS_ERROR_B_SYNTAX   0x02

Definition at line 141 of file wsint.h.

Referenced by ws_error_syntax().

◆ WS_INT16_MAX

#define WS_INT16_MAX   32767

Definition at line 106 of file wsint.h.

Referenced by ws_bc_encode().

◆ WS_INT16_MIN

#define WS_INT16_MIN   -32768

Definition at line 105 of file wsint.h.

◆ WS_INT32_MAX

#define WS_INT32_MAX   2147483647

Definition at line 109 of file wsint.h.

Referenced by buffer_to_int(), and ws_expr_linearize().

◆ WS_INT32_MIN

#define WS_INT32_MIN   -2147483648

Definition at line 108 of file wsint.h.

◆ WS_INT8_MAX

#define WS_INT8_MAX   127

Definition at line 103 of file wsint.h.

Referenced by ws_bc_encode().

◆ WS_INT8_MIN

#define WS_INT8_MIN   -128

Definition at line 102 of file wsint.h.

◆ WS_LINE_TERMINATOR

#define WS_LINE_TERMINATOR   "\n"

Definition at line 97 of file wsint.h.

Referenced by ws_error_memory(), ws_error_syntax(), ws_info(), ws_src_error(), and ws_src_warning().

Typedef Documentation

◆ WsByte

typedef unsigned char WsByte

Definition at line 113 of file wsint.h.

◆ WsCompiler

typedef struct WsCompilerRec WsCompiler

Definition at line 268 of file wsint.h.

◆ WsContBreak

typedef struct WsContBreakRec WsContBreak

Definition at line 183 of file wsint.h.

◆ WsFloat

typedef double WsFloat

Definition at line 126 of file wsint.h.

◆ WsInt16

typedef signed short WsInt16

Definition at line 118 of file wsint.h.

◆ WsInt32

typedef signed long WsInt32

Definition at line 121 of file wsint.h.

◆ WsInt8

typedef signed char WsInt8

Definition at line 115 of file wsint.h.

◆ WsUInt16

typedef unsigned short WsUInt16

Definition at line 119 of file wsint.h.

◆ WsUInt32

typedef unsigned long WsUInt32

Definition at line 122 of file wsint.h.

◆ WsUInt8

typedef unsigned char WsUInt8

Definition at line 116 of file wsint.h.

Enumeration Type Documentation

◆ WsBool

enum WsBool
Enumerator
WS_FALSE 
WS_TRUE 

Definition at line 128 of file wsint.h.

129 {
130  WS_FALSE,
131  WS_TRUE
132 } WsBool;
Definition: wsint.h:131
WsBool
Definition: wsint.h:128

Function Documentation

◆ ws_lexer_free_block()

void ws_lexer_free_block ( WsCompiler compiler,
void *  ptr 
)

Definition at line 281 of file ws.c.

References WsCompilerRec::lexer_active_list, WsCompilerRec::lexer_active_list_size, ws_fatal(), and ws_free().

Referenced by ws_expr_assign(), ws_expr_call(), ws_expr_postfix_var(), ws_expr_symbol(), ws_expr_unary_var(), ws_lexer_free_utf8(), ws_pragma_use(), and yyparse().

282 {
283  int i;
284 
285  if (ptr == NULL)
286  return;
287 
288  for (i = compiler->lexer_active_list_size - 1; i >= 0; i--) {
289  if (compiler->lexer_active_list[i] == ptr) {
290  memmove(&compiler->lexer_active_list[i],
291  &compiler->lexer_active_list[i + 1],
292  (compiler->lexer_active_list_size - i - 1) * sizeof(void *));
293  compiler->lexer_active_list_size--;
294 
295  ws_free(ptr);
296  return;
297  }
298  }
299 
300  ws_fatal("ws_lexer_free_block(): unknown block 0x%lx",
301  (unsigned long) ptr);
302 }
void ws_fatal(char *fmt,...)
Definition: wserror.c:91
size_t lexer_active_list_size
Definition: wsint.h:215
void ws_free(void *ptr)
Definition: wsalloc.c:139
void ** lexer_active_list
Definition: wsint.h:214

◆ ws_lexer_free_utf8()

void ws_lexer_free_utf8 ( WsCompiler compiler,
WsUtf8String string 
)

Definition at line 305 of file ws.c.

References WsUtf8StringRec::data, and ws_lexer_free_block().

Referenced by ws_expr_const_string(), ws_pragma_meta_body_free(), ws_pragma_use(), and yyparse().

306 {
307  if (string == NULL)
308  return;
309 
310  ws_lexer_free_block(compiler, string->data);
311  ws_lexer_free_block(compiler, string);
312 }
unsigned char * data
Definition: wsutf8.h:84
void ws_lexer_free_block(WsCompiler *compiler, void *ptr)
Definition: ws.c:281

◆ ws_lexer_register_block()

WsBool ws_lexer_register_block ( WsCompiler compiler,
void *  ptr 
)

Definition at line 248 of file ws.c.

References WsCompilerRec::lexer_active_list, WsCompilerRec::lexer_active_list_size, WS_FALSE, ws_realloc(), and WS_TRUE.

Referenced by ws_lexer_register_utf8(), and ws_yy_lex().

249 {
250  void **n;
251 
252  if (ptr == NULL)
253  return WS_TRUE;
254 
255  n = ws_realloc(compiler->lexer_active_list,
256  ((compiler->lexer_active_list_size + 1) * sizeof(void *)));
257  if (n == NULL)
258  return WS_FALSE;
259 
260  compiler->lexer_active_list = n;
261  compiler->lexer_active_list[compiler->lexer_active_list_size++] = ptr;
262 
263  return WS_TRUE;
264 }
size_t lexer_active_list_size
Definition: wsint.h:215
Definition: wsint.h:131
void * ws_realloc(void *ptr, size_t size)
Definition: wsalloc.c:89
void ** lexer_active_list
Definition: wsint.h:214

◆ ws_lexer_register_utf8()

WsBool ws_lexer_register_utf8 ( WsCompiler compiler,
WsUtf8String string 
)

Definition at line 267 of file ws.c.

References WsUtf8StringRec::data, WsCompilerRec::lexer_active_list_size, WS_FALSE, ws_lexer_register_block(), and WS_TRUE.

Referenced by ws_yy_lex().

268 {
269  if (!ws_lexer_register_block(compiler, string))
270  return WS_FALSE;
271 
272  if (!ws_lexer_register_block(compiler, string->data)) {
273  compiler->lexer_active_list_size--;
274  return WS_FALSE;
275  }
276 
277  return WS_TRUE;
278 }
size_t lexer_active_list_size
Definition: wsint.h:215
Definition: wsint.h:131
unsigned char * data
Definition: wsutf8.h:84
WsBool ws_lexer_register_block(WsCompiler *compiler, void *ptr)
Definition: ws.c:248

◆ ws_yy_parse()

int ws_yy_parse ( WsCompiler compiler)

◆ yylex()

int yylex ( )
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.