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

cint_parser.h (3033B)


      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:        cint_parser.h
      8  * Purpose:     CINT parser interfaces
      9  */
     10 
     11 /*******************************************************************************
     12  *
     13  * CINT C Parser Interface
     14  *
     15  * This is the object-oriented interface to the lexical scanner
     16  * and generated parser state machine. 
     17  */
     18 
     19 #ifndef __CINT_CPARSER_H__
     20 #define __CINT_CPARSER_H__
     21 
     22 #include "cint_config.h"
     23 #include "cint_ast.h"
     24 
     25 typedef struct cint_cparser_s {
     26 
     27     /* Private Implementation Members */
     28     cint_ast_t* result; 
     29     void* scanner; 
     30     void* parser; 
     31     int error; 
     32 
     33 } cint_cparser_t; 
     34 
     35 
     36 /*
     37  * Create a C Parser Instance
     38  */
     39 extern cint_cparser_t* cint_cparser_create(void); 
     40 
     41 
     42 /*
     43  * Set the input file handle
     44  */
     45 int cint_cparser_start_handle(cint_cparser_t* cp, void* handle); 
     46 
     47 /*
     48  * Set the input string
     49  */
     50 int cint_cparser_start_string(cint_cparser_t* cp, const char* string); 
     51 
     52 /*
     53  * Parse one C translation unit from the current input handle.  
     54  */
     55 cint_ast_t* cint_cparser_parse(cint_cparser_t* cp); 
     56 
     57 /* 
     58  * Parse one C translation unit from the given input string. 
     59  */
     60 cint_ast_t* cint_cparser_parse_string(const char* string); 
     61 
     62 /*
     63  * Retrieve the error code from the last request for parsing
     64  */
     65 int cint_cparser_error(cint_cparser_t* cp); 
     66 
     67 /*
     68  * Destroy a C Parser Instance
     69  */
     70 int cint_cparser_destroy(cint_cparser_t* cp); 
     71 
     72 /*
     73  * Handle a parser fatal error
     74  */
     75 extern void cint_cparser_fatal_error(char *msg);
     76 
     77 #if CINT_CONFIG_INCLUDE_PARSER_READLINE == 1
     78 extern int cint_cparser_input_readline(void *in, char* buf,
     79                                        int* result, int max_size, int prompt);
     80 #else
     81 
     82 /*
     83  * Default character input
     84  */
     85 extern int cint_cparser_input_default(void *in, char* buf,
     86                                       int* result, int max_size, int prompt);
     87 
     88 /*
     89  * Default character input with echo
     90  */
     91 extern int cint_cparser_input_default_echo(void *in,
     92                                            char* buf,
     93                                            int* result, int max_size,
     94                                            int prompt, int echo);
     95 
     96 #endif /* CINT_CONFIG_INCLUDE_PARSER_READLINE */
     97 
     98 /*
     99    Interfaces to library functions.  Declaring here avoids painful
    100    interactions with other header files and helps keep track of
    101    portability interfaces.
    102 */
    103 
    104 extern void *cint_cparser_alloc(unsigned int size);
    105 extern void *cint_cparser_realloc(void *ptr,  unsigned int size);
    106 extern void cint_cparser_free(void *ptr);
    107 extern void *cint_cparser_memcpy(void *dst, const void *src, int len);
    108 extern void *cint_cparser_memset(void *dst, int c, int len);
    109 extern void cint_cparser_message(const char *msg, int len);
    110 extern int cint_cparser_interactive(void); 
    111 extern int cint_cparser_include(int level);
    112 extern const char *cint_cparser_set_prompt(const char *prompt);
    113 
    114 #endif /* __CINT_CPARSER_H__ */
    115