50 if ((c ==
' ') || (c ==
'\t')) {
62 if ((c ==
'0') || (c ==
'1')) {
74 if ((c ==
'0') || (c ==
'1') || (c ==
'2') || (c ==
'3') || (c ==
'4') || (c ==
'5') || (c ==
'6') || (c ==
'7')) {
85static int iseos(lex_state_t * state) {
86 if ((state->buffer + state->len) <= (state->pos)) {
108static int ischr(lex_state_t * state,
char chr) {
109 return (state->pos[0] == chr);
118 return c ==
'+' || c ==
'-';
127 return c ==
'h' || c ==
'H';
136 return c ==
'b' || c ==
'B';
145 return c ==
'q' || c ==
'Q';
154 return c ==
'e' || c ==
'E';
159#define SKIP_INCOMPLETE -1
172 while (!
iseos(state) &&
isws(state->pos[0])) {
192 if (!
iseos(state) && isdigit((uint8_t)(state->pos[0]))) {
207 while (!
iseos(state) && isdigit((uint8_t)(state->pos[0]))) {
235 while (!
iseos(state) && isalpha((uint8_t)(state->pos[0]))) {
248static int skipChr(lex_state_t * state,
char chr) {
307 const char * startPos = state->pos;
308 if (!
iseos(state) && isalpha((uint8_t)(state->pos[0]))) {
310 while (!
iseos(state) && (isalnum((uint8_t)(state->pos[0])) ||
ischr(state,
'_'))) {
318 return (state->pos - startPos) *
SKIP_OK;
331 token->ptr = state->pos;
335 token->len = state->pos - token->ptr;
337 if (token->len > 0) {
392 }
else if (firstColon) {
407 token->ptr = state->pos;
434 token->len = state->pos - token->ptr;
437 state->pos = token->ptr;
452 token->ptr = state->pos;
454 if (!
iseos(state) && isalpha((uint8_t)(state->pos[0]))) {
456 while (!
iseos(state) && (isalnum((uint8_t)(state->pos[0])) ||
ischr(state,
'_'))) {
461 token->len = state->pos - token->ptr;
462 if (token->len > 0) {
489 if (!
iseos(state) &&
isE(state->pos[0])) {
510 token->ptr = state->pos;
513 rollback = state->pos;
516 state->pos = rollback;
519 state->pos = token->ptr;
522 token->len = state->pos - token->ptr;
523 if (token->len > 0) {
534 token->ptr = state->pos;
550 token->len = state->pos - token->ptr;
551 if ((token->len > 0)) {
555 state->pos = token->ptr;
565 while (!
iseos(state) && isxdigit((uint8_t)(state->pos[0]))) {
598 token->ptr = state->pos;
601 if (
isH(state->pos[0])) {
605 }
else if (
isQ(state->pos[0])) {
609 }
else if (
isB(state->pos[0])) {
619 token->len = state->pos - token->ptr;
622 state->pos = token->ptr;
625 return token->len > 0 ? token->len + 2 : 0;
630 return (c >= 0) && (c <= 0x7f);
634 while (!
iseos(state)) {
637 }
else if (
ischr(state, quote)) {
666 token->ptr = state->pos;
669 if (
ischr(state,
'"')) {
675 token->len = state->pos - token->ptr;
677 state->pos = token->ptr;
679 }
else if (
ischr(state,
'\'')) {
685 token->len = state->pos - token->ptr;
687 state->pos = token->ptr;
692 token->len = state->pos - token->ptr;
694 if ((token->len > 0)) {
699 state->pos = token->ptr;
703 return token->len > 0 ? token->len : 0;
708 return isdigit(c) && (c !=
'0');
719 int arbitraryBlockLength = 0;
720 const char * ptr = state->pos;
722 token->ptr = state->pos;
727 i = state->pos[0] -
'0';
731 if (!
iseos(state) && isdigit((uint8_t)(state->pos[0]))) {
732 arbitraryBlockLength *= 10;
733 arbitraryBlockLength += (state->pos[0] -
'0');
741 state->pos += arbitraryBlockLength;
742 if ((state->buffer + state->len) >= (state->pos)) {
743 token->ptr = state->pos - arbitraryBlockLength;
744 token->len = arbitraryBlockLength;
749 }
else if (
iseos(state)) {
752 }
else if (
iseos(state)) {
757 if (validData == 1) {
760 }
else if (validData == 0) {
764 state->pos = state->buffer + state->len;
768 state->pos = token->ptr;
772 return token->len + (token->ptr - ptr);
777 if ((c >= 0x20) && (c <= 0x7e)) {
806 token->ptr = state->pos;
814 token->len = state->pos - token->ptr;
820 if ((token->len > 0)) {
824 state->pos = token->ptr;
838 token->ptr = state->pos;
858 token->ptr = state->pos;
878 token->ptr = state->pos;
898 token->ptr = state->pos;
918 token->ptr = state->pos;
923 token->len = state->pos - token->ptr;
925 if ((token->len > 0)) {
929 state->pos = token->ptr;
static int skipProgramMnemonic(lex_state_t *state)
static int skipExponent(lex_state_t *state)
static int skipWs(lex_state_t *state)
static int skipCompoundProgramHeader(lex_state_t *state)
static int skipAlpha(lex_state_t *state)
static int ischr(lex_state_t *state, char chr)
static int isbdigit(int c)
int scpiLex_NewLine(lex_state_t *state, scpi_token_t *token)
static int skipPlusmn(lex_state_t *state)
int scpiLex_StringProgramData(lex_state_t *state, scpi_token_t *token)
static void skipProgramExpression(lex_state_t *state)
int scpiLex_ProgramExpression(lex_state_t *state, scpi_token_t *token)
static int skipDigit(lex_state_t *state)
static void skipQuoteProgramData(lex_state_t *state, char quote)
int scpiLex_ArbitraryBlockProgramData(lex_state_t *state, scpi_token_t *token)
static int isProgramExpression(int c)
static int skipCommonProgramHeader(lex_state_t *state)
static int skipOctNum(lex_state_t *state)
static int skipBinNum(lex_state_t *state)
static int isascii7bit(int c)
int scpiLex_DecimalNumericProgramData(lex_state_t *state, scpi_token_t *token)
static int iseos(lex_state_t *state)
static int isqdigit(int c)
static void skipDoubleQuoteProgramData(lex_state_t *state)
int scpiLex_ProgramHeader(lex_state_t *state, scpi_token_t *token)
int scpiLex_SpecificCharacter(lex_state_t *state, scpi_token_t *token, char chr)
int scpiLex_SuffixProgramData(lex_state_t *state, scpi_token_t *token)
static int isplusmn(int c)
static void skipSingleQuoteProgramData(lex_state_t *state)
int scpiLex_Semicolon(lex_state_t *state, scpi_token_t *token)
static int isNonzeroDigit(int c)
static int skipColon(lex_state_t *state)
static int skipMantisa(lex_state_t *state)
static int skipHexNum(lex_state_t *state)
int scpiLex_IsEos(lex_state_t *state)
int scpiLex_CharacterProgramData(lex_state_t *state, scpi_token_t *token)
int scpiLex_WhiteSpace(lex_state_t *state, scpi_token_t *token)
static int skipChr(lex_state_t *state, char chr)
static int skipStar(lex_state_t *state)
static int skipSlashDot(lex_state_t *state)
int scpiLex_Comma(lex_state_t *state, scpi_token_t *token)
int scpiLex_Colon(lex_state_t *state, scpi_token_t *token)
static int skipNumbers(lex_state_t *state)
int scpiLex_NondecimalNumericData(lex_state_t *state, scpi_token_t *token)
@ SCPI_TOKEN_PROGRAM_MNEMONIC
@ SCPI_TOKEN_DOUBLE_QUOTE_PROGRAM_DATA
@ SCPI_TOKEN_COMMON_QUERY_PROGRAM_HEADER
@ SCPI_TOKEN_SINGLE_QUOTE_PROGRAM_DATA
@ SCPI_TOKEN_COMPOUND_QUERY_PROGRAM_HEADER
@ SCPI_TOKEN_INCOMPLETE_COMMON_PROGRAM_HEADER
@ SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA
@ SCPI_TOKEN_SPECIFIC_CHARACTER
@ SCPI_TOKEN_COMMON_PROGRAM_HEADER
@ SCPI_TOKEN_ARBITRARY_BLOCK_PROGRAM_DATA
@ SCPI_TOKEN_PROGRAM_EXPRESSION
@ SCPI_TOKEN_INCOMPLETE_COMPOUND_PROGRAM_HEADER
@ SCPI_TOKEN_COMPOUND_PROGRAM_HEADER
@ SCPI_TOKEN_SUFFIX_PROGRAM_DATA