From 11f2f2e329ef404d0e9c022cb2f9fbbb45bae285 Mon Sep 17 00:00:00 2001 From: nancy.liao <huihui.liao@greentest.com.cn> Date: 周日, 27 4月 2025 17:33:31 +0800 Subject: [PATCH] 完成了SCPI命令语法分析器的完整规则 --- libscpi/src/parser.c | 24 ++++++++++-------------- 1 files changed, 10 insertions(+), 14 deletions(-) diff --git a/libscpi/src/parser.c b/libscpi/src/parser.c index 2240d5c..a6376cf 100644 --- a/libscpi/src/parser.c +++ b/libscpi/src/parser.c @@ -37,6 +37,7 @@ #include <ctype.h> #include <string.h> +#include "scpi/externinterface.h" #include "scpi/config.h" #include "scpi/parser.h" @@ -45,7 +46,7 @@ #include "scpi/error.h" #include "scpi/constants.h" #include "scpi/utils.h" - +#include "scpi/externinterface.h" /** * Write data to SCPI output * @param context @@ -180,21 +181,16 @@ * @param context * @result TRUE if context->paramlist is filled with correct values */ -static scpi_bool_t findCommandHeader(scpi_t * context, const char * header, int len) { - int32_t i; - const scpi_command_t * cmd = NULL; - for (i = 0; i<context->cmdlistSize; i++) { - cmd = &context->cmdlist[i]; - bool result =test_match(cmd->pattern, header); - if(result) +scpi_bool_t findCommandHeader(scpi_t * context, const char * header, int len) +{ + + for(int i=0;i<get_pattern_count();i++) + { + if( match_segments_global(header,i) ) { - context->param_list.cmd = &context->cmdlist[i]; + context->param_list.cmd = &context->cmdlist[i]; return TRUE; } - // if (matchCommand(cmd->pattern, header, len, NULL, 0, 0)) { - // context->param_list.cmd = cmd; - // return TRUE; - // } } context->SCPIerror = RETURN_NotFind; return FALSE; @@ -362,7 +358,7 @@ */ scpi_bool_t SCPI_Input(scpi_t * context, const char * data, int len) { - scpi_bool_t result = FALSE; + scpi_bool_t result = FALSE; size_t totcmdlen = 0; int cmdlen = 0; //褰撻暱搴︿负0鏃� 瑙f瀽褰撳墠鐨勬暟鎹� 骞朵笖娓呯┖context鐨刡uff鏍囪浣� -- Gitblit v1.9.1