nancy.liao
6 天以前 5061da0712c43dcd07384e5275b2bcab76e8667e
libscpi/src/lexer.c
@@ -341,7 +341,9 @@
        token->type = SCPI_TOKEN_UNKNOWN;
    }
    return token->len;
   return token->len;
}
/* 7.6.1 <COMMAND PROGRAM HEADER> */
@@ -403,12 +405,23 @@
 * @param token
 * @return 
 */
 /*识别和分类SCPI命令头
    公共命令头 以*识别  如  *IDN?
    复合命令头 以:识别 如  SYSTem:ERRor?
    命令查询  以?识别
        普通命令:MEAS:VOLT
        查询命令:MEAS:VOLT?
 */
int scpiLex_ProgramHeader(lex_state_t * state, scpi_token_t * token) {
     // 记录起始位置 并且初始化类型
    int res;
    token->ptr = state->pos;
    token->type = SCPI_TOKEN_UNKNOWN;
    res = skipCommonProgramHeader(state);
    // 解析到公共命令头后检查查询符
    if (res >= SKIP_OK) {
        if (skipChr(state, '?') >= SKIP_OK) {
            token->type = SCPI_TOKEN_COMMON_QUERY_PROGRAM_HEADER;
@@ -418,6 +431,8 @@
    } else if (res <= SKIP_INCOMPLETE) {
        token->type = SCPI_TOKEN_INCOMPLETE_COMMON_PROGRAM_HEADER;
    } else if (res == SKIP_NONE) {
         // 解析到复合命令后检查查询符
        res = skipCompoundProgramHeader(state);
        if (res >= SKIP_OK) {
@@ -430,7 +445,7 @@
            token->type = SCPI_TOKEN_INCOMPLETE_COMPOUND_PROGRAM_HEADER;
        }
    }
    // 计算长度
    if (token->type != SCPI_TOKEN_UNKNOWN) {
        token->len = state->pos - token->ptr;
    } else {