openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

tokenizer.h (2035B)


      1 /* 
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * File:        tokenizer.h
      8  * Purpose:     API mode tokenizer
      9  */
     10 
     11 #ifndef   _TOKENIZER_H_
     12 #define   _TOKENIZER_H_
     13 
     14 #include "cint_interpreter.h"
     15 
     16 typedef enum api_mode_token_type_e {
     17     API_MODE_TOKEN_TYPE_NONE,
     18     API_MODE_TOKEN_TYPE_VALUE,
     19     API_MODE_TOKEN_TYPE_QUOTE,
     20     API_MODE_TOKEN_TYPE_SEPARATOR,
     21     API_MODE_TOKEN_TYPE_COMMENT,
     22     API_MODE_TOKEN_TYPE_ERROR
     23 } api_mode_token_type_t;
     24 
     25 typedef enum api_mode_token_error_e {
     26     API_MODE_TOKEN_ERROR_NONE,
     27     API_MODE_TOKEN_ERROR_INIT,
     28     API_MODE_TOKEN_ERROR_ESCAPE,
     29     API_MODE_TOKEN_ERROR_QUOTE,
     30     API_MODE_TOKEN_ERROR_CHAR,
     31     API_MODE_TOKEN_ERROR_UNEXPECTED,
     32     API_MODE_TOKEN_ERROR_STATE,
     33     API_MODE_TOKEN_ERROR_LAST
     34 } api_mode_token_error_t;
     35 
     36 typedef struct api_mode_token_s {
     37     const char *str;                    /* NUL terminated token string */
     38     int first_line;                     /* source buffer start line */
     39     int first_column;                   /* source buffer start column */
     40     int last_line;                      /* source buffer end line */
     41     int last_column;                    /* source buffer end column */
     42     int ident;                          /* indentifier? */
     43     api_mode_token_type_t token_type;   /* tokenizer type */
     44 } api_mode_token_t;
     45 
     46 typedef struct api_mode_tokens_s {
     47     int len;                            /* number of valid tokens */
     48     api_mode_token_error_t error;       /* error state */
     49     char *buf;                          /* token data memory buffer */
     50     api_mode_token_t *token;            /* array of 'len' tokens */
     51 } api_mode_tokens_t;
     52 
     53 
     54 extern int api_mode_tokenizer(const char *input, api_mode_tokens_t *tokens);
     55 extern int api_mode_tokenizer_free(api_mode_tokens_t *tokens);
     56 extern const char *api_mode_tokenizer_error_str(api_mode_token_error_t error);
     57 
     58 #endif /* _TOKENIZER_H_ */