simParse.h 1.8 KB
Newer Older
S
slguan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __SIM_PARSE_H__
#define __SIM_PARSE_H__

#define MAX_NUM_CMD 64
#define MAX_NUM_LABLES 100
#define MAX_LABEL_LEN 40
#define MAX_NUM_BLOCK 100
#define MAX_NUM_JUMP 100
#define MAX_LINE_LEN 3000
#define MAX_CMD_LINES 2048
#define MAX_OPTION_BUFFER 64000

enum {
  BLOCK_IF,
  BLOCK_WHILE,
  BLOCK_SWITCH,
};

/* label stack */
typedef struct {
S
TD-1090  
Shengliang Guan 已提交
36 37
  char    top;                                  /* number of labels */
  int16_t pos[MAX_NUM_LABLES];                  /* the position of the label */
38
  char    label[MAX_NUM_LABLES][MAX_LABEL_LEN]; /* name of the label */
S
slguan 已提交
39 40 41 42
} SLabel;

/* block definition */
typedef struct {
43 44
  char     top;                  /* the number of blocks stacked */
  char     type[MAX_NUM_BLOCK];  /* the block type */
S
TD-1090  
Shengliang Guan 已提交
45 46
  int16_t *pos[MAX_NUM_BLOCK];   /* position of the jump for if/elif/case */
  int16_t  back[MAX_NUM_BLOCK];  /* go back, endw and continue */
47 48
  char     numJump[MAX_NUM_BLOCK];
  int16_t *jump[MAX_NUM_BLOCK][MAX_NUM_JUMP]; /* break or elif */
S
TD-1090  
Shengliang Guan 已提交
49 50
  char     sexp[MAX_NUM_BLOCK][40];           /*switch expression */
  char     sexpLen[MAX_NUM_BLOCK];            /*switch expression length */
S
slguan 已提交
51 52 53 54 55
} SBlock;

bool simParseExpression(char *token, int lineNum);

#endif