From cf33d5a972d12bdf3043a7de8dd337051b2d21b0 Mon Sep 17 00:00:00 2001 From: Iztok Jeras <iztok.jeras@redpitaya.com> Date: ćšć, 08 10æ 2015 03:00:34 +0800 Subject: [PATCH] integer parser: fixed some integer castings --- libscpi/src/lexer.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 46 insertions(+), 9 deletions(-) diff --git a/libscpi/src/lexer.c b/libscpi/src/lexer.c index aaca475..ee4696c 100644 --- a/libscpi/src/lexer.c +++ b/libscpi/src/lexer.c @@ -771,12 +771,12 @@ /* 7.7.7 <EXPRESSION PROGRAM DATA> */ static int isProgramExpression(int c) { if ((c >= 0x20) && (c <= 0x7e)) { - if ((c != 0x22) - && (c != 0x23) - && (c != 0x27) - && (c != 0x28) - && (c != 0x29) - && (c != 0x3B)) { + if ((c != '"') + && (c != '#') + && (c != '\'') + && (c != '(') + && (c != ')') + && (c != ';')) { return 1; } } @@ -865,6 +865,46 @@ } /** + * Detect token colon + * @param state + * @param token + * @return + */ +int scpiLex_Colon(lex_state_t * state, scpi_token_t * token) { + token->ptr = state->pos; + + if (skipChr(state, ':')) { + token->len = 1; + token->type = SCPI_TOKEN_COLON; + } else { + token->len = 0; + token->type = SCPI_TOKEN_UNKNOWN; + } + + return token->len; +} + +/** + * Detect specified character + * @param state + * @param token + * @return + */ +int scpiLex_SpecificCharacter(lex_state_t * state, scpi_token_t * token, char chr) { + token->ptr = state->pos; + + if (skipChr(state, chr)) { + token->len = 1; + token->type = SCPI_TOKEN_SPECIFIC_CHARACTER; + } else { + token->len = 0; + token->type = SCPI_TOKEN_UNKNOWN; + } + + return token->len; +} + +/** * Detect token New line * @param state * @param token @@ -888,6 +928,3 @@ return token->len; } - - - -- Gitblit v1.9.1