📄 lex.soapcpp2_lex.c
字号:
void *ptr;
yy_size_t size;
#endif
{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
* because both ANSI C and C++ allow castless assignment from
* any pointer type to void*, and deal with argument conversions
* as though doing an assignment.
*/
return (void *) realloc( (char *) ptr, size );
}
#ifdef YY_USE_PROTOS
static void yy_flex_free( void *ptr )
#else
static void yy_flex_free( ptr )
void *ptr;
#endif
{
free( ptr );
}
#if YY_MAIN
int main()
{
yylex();
return 0;
}
#endif
#line 175 ".\\soapcpp2_lex.l"
/*
install_id - lookup identifier in symbol table. If found, return token
and symbol table entry. If not found, create entry in symbol table and
return ID token.
*/
static Token
install_id()
{ Symbol *p = lookup(yytext);
if (!p)
p = install(yytext, ID);
yylval.sym = p;
return p->token;
}
/*
install_int - convert digits to integer and return LNG token.
*/
static Token
install_int()
{
sscanf(yytext, SOAP_ULONG_FORMAT, &yylval.i);
return LNG;
}
/*
install_hex - convert hexadecimal digits to integer and return LNG
*/
static Token
install_hex()
{
sscanf(yytext, SOAP_XLONG_FORMAT, &yylval.i);
return LNG;
}
/*
install_num - convert digits to floating point number and return DBL
*/
static Token
install_num()
{ sscanf(yytext, "%lf", &yylval.r);
return DBL;
}
/*
install_chr - convert character constant and return CHR.
*/
static Token
install_chr()
{ int i = 2;
if (yytext[1] == '\\')
yylval.c = convchar(&i);
else yylval.c = yytext[i-1];
if (yytext[i] != '\'')
lexerror("Illegal character constant");
return CHR;
}
/*
install_str - convert and store string in memory. Return STR.
*/
static Token
install_str()
{ int i, j = 0;
yylval.s = emalloc(yyleng-1); /* yyleng = length(yytext) */
for (i = 1; i < yyleng-1; i++)
if (yytext[i] == '\\')
{ if (yytext[++i] != '\n')
{ yylval.s[j++] = convchar(&i);
i--;
}
}
else
yylval.s[j++] = yytext[i];
yylval.s[j] = '\0';
return STR;
}
/*
install_pragma - store pragma in string. Return PRAGMA.
*/
static Token
install_pragma()
{ yylval.s = emalloc(yyleng); /* yyleng = length(yytext) */
strncpy(yylval.s, yytext, strlen(yytext)-1);
yylval.s[strlen(yytext)-1] = '\0';
return PRAGMA;
}
static void directive()
{ int i, j, k;
char *s;
Service *sp;
Method *m;
Data *d;
int service;
for (i = 7; yytext[i]; i++)
if (yytext[i] > 32)
break;
for (j = i; yytext[j]; j++)
if (yytext[j] <= 32)
break;
if (i == j)
return;
s = (char*)emalloc(j-i+1);
for (k = 0; k < j-i; k++)
{ s[k] = yytext[k+i];
if (s[k] == '_')
s[k] = '-';
}
s[k] = '\0';
for (sp = services; sp; sp = sp->next)
if (!strcmp(sp->ns, s))
break;
if (!sp)
{ sp = (Service*)emalloc(sizeof(Service));
sp->next = services;
sp->ns = s;
sp->name = NULL;
sp->porttype = NULL;
sp->portname = NULL;
sp->binding = NULL;
sp->definitions = NULL;
sp->transport = NULL;
sp->URL = NULL;
sp->URI = NULL;
sp->WSDL = NULL;
sp->style = NULL;
sp->encoding = NULL;
sp->elementForm = NULL;
sp->attributeForm = NULL;
sp->executable = NULL;
sp->import = NULL;
sp->documentation = NULL;
sp->list = NULL;
sp->data = NULL;
services = sp;
}
for (i = j; yytext[i]; i++)
if (yytext[i] > 32)
break;
if (!strncmp(yytext+i, "service", 7) || !strncmp(yytext+i, "schema", 6))
{ service = strncmp(yytext+i, "schema", 6);
for (i += 7; yytext[i]; i++)
if (yytext[i] > 32)
break;
for (j = i; yytext[j]; j++)
if (yytext[j] <= 32)
break;
for (; yytext[j]; j++)
if (yytext[j] > 32)
break;
for (k = j; yytext[k]; k++)
if (yytext[k] <= 32)
break;
/*
if (j == k)
return;
*/
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
s[k-j] = '\0';
if (!strncmp(yytext+i, "name:", 5))
{ sp->name = s;
for (j = k; yytext[j]; j++)
if (yytext[j] > 32)
break;
for (k = j; yytext[k]; k++)
if (yytext[k] == 10 || yytext[k] == 13)
break;
if (j == k)
return;
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
s[k-j] = '\0';
sp->documentation = s;
}
else if (!strncmp(yytext+i, "type:", 5))
sp->porttype = s;
else if (!strncmp(yytext+i, "portType:", 9))
sp->porttype = s;
else if (!strncmp(yytext+i, "portName:", 9))
sp->portname = s;
else if (!strncmp(yytext+i, "binding:", 8))
sp->binding = s;
else if (!strncmp(yytext+i, "definitions:", 12))
sp->definitions = s;
else if (!strncmp(yytext+i, "documentation:", 14))
{ for (k = j; yytext[k]; k++)
if (yytext[k] == 10 || yytext[k] == 13)
break;
if (j == k)
return;
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
s[k-j] = '\0';
sp->documentation = s;
}
else if (!strncmp(yytext+i, "transport:", 10))
sp->transport = s;
else if (!strncmp(yytext+i, "location:", 9) || !strncmp(yytext+i, "port:", 5))
sp->URL = s;
else if (!strncmp(yytext+i, "executable:", 11))
sp->executable = s;
else if (!strncmp(yytext+i, "namespace:", 10))
{ if (service)
{ if (!sp->URI)
sp->URI = s;
sp->WSDL = s;
}
else if (!strcmp(sp->ns, "SOAP-ENV"))
sp->URI = envURI = s;
else if (!strcmp(sp->ns, "SOAP-ENC"))
sp->URI = encURI = s;
else
sp->URI = s;
}
else if (!strncmp(yytext+i, "form:", 5))
{ sp->elementForm = s;
sp->attributeForm = s;
}
else if (!strncmp(yytext+i, "elementForm:", 12))
sp->elementForm = s;
else if (!strncmp(yytext+i, "attributeForm:", 14))
sp->attributeForm = s;
else if (!strncmp(yytext+i, "import:", 7))
{ if (!sp->URI)
sp->URI = s;
sp->import = s;
}
else if (!strncmp(yytext+i, "encoding:", 9))
{ if (!strcmp(s, "encoded"))
sp->encoding = "";
else
sp->encoding = s;
}
else if (!strncmp(yytext+i, "style:", 6))
sp->style = s;
else if (!strncmp(yytext+i, "method-style:", 13))
{ m = (Method*)emalloc(sizeof(Method));
m->name = s;
m->mess = STYLE;
m->part = NULL;
m->next = sp->list;
sp->list = m;
for (j = k; yytext[j]; j++)
if (yytext[j] > 32)
break;
for (k = j; yytext[k]; k++)
if (yytext[k] == 10 || yytext[k] == 13)
break;
if (j == k)
return;
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
s[k-j] = '\0';
m->part = s;
}
else if (!strncmp(yytext+i, "method-encoding:", 16))
{ m = (Method*)emalloc(sizeof(Method));
m->name = s;
m->mess = ENCODING;
m->part = NULL;
m->next = sp->list;
sp->list = m;
for (j = k; yytext[j]; j++)
if (yytext[j] > 32)
break;
for (k = j; yytext[k]; k++)
if (yytext[k] == 10 || yytext[k] == 13)
break;
if (j == k)
return;
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
s[k-j] = '\0';
if (strcmp(s, "encoded"))
m->part = s;
else
m->part = "";
}
else if (!strncmp(yytext+i, "method-response-encoding:", 25))
{ m = (Method*)emalloc(sizeof(Method));
m->name = s;
m->mess = RESPONSE_ENCODING;
m->part = NULL;
m->next = sp->list;
sp->list = m;
for (j = k; yytext[j]; j++)
if (yytext[j] > 32)
break;
for (k = j; yytext[k]; k++)
if (yytext[k] == 10 || yytext[k] == 13)
break;
if (j == k)
return;
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
s[k-j] = '\0';
if (strcmp(s, "encoded"))
m->part = s;
else
m->part = "";
}
else if (!strncmp(yytext+i, "method-documentation:", 21))
{ m = (Method*)emalloc(sizeof(Method));
m->name = s;
m->mess = COMMENT;
m->part = NULL;
m->next = sp->list;
sp->list = m;
for (j = k; yytext[j]; j++)
if (yytext[j] > 32)
break;
for (k = j; yytext[k]; k++)
if (yytext[k] == 10 || yytext[k] == 13)
break;
if (j == k)
return;
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
s[k-j] = '\0';
m->part = s;
}
else if (!strncmp(yytext+i, "method-action:", 14))
{ m = (Method*)emalloc(sizeof(Method));
m->name = s;
m->mess = ACTION;
m->part = NULL;
m->next = sp->list;
sp->list = m;
for (j = k; yytext[j]; j++)
if (yytext[j] > 32)
break;
for (k = j; yytext[k]; k++)
if (yytext[k] <= 32)
break;
if (j == k)
return;
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
s[k-j] = '\0';
m->part = s;
}
else if (!strncmp(yytext+i, "method-mime-type:", 17))
{ m = (Method*)emalloc(sizeof(Method));
m->name = s;
m->mess = MIMEIN | MIMEOUT;
m->part = NULL;
m->next = sp->list;
sp->list = m;
for (j = k; yytext[j]; j++)
if (yytext[j] > 32)
break;
for (k = j; yytext[k]; k++)
if (yytext[k] <= 32)
break;
if (j == k)
return;
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
s[k-j] = '\0';
m->part = s;
}
else if (!strncmp(yytext+i, "method-input-mime-type:", 23))
{ m = (Method*)emalloc(sizeof(Method));
m->name = s;
m->mess = MIMEIN;
m->part = NULL;
m->next = sp->list;
sp->list = m;
for (j = k; yytext[j]; j++)
if (yytext[j] > 32)
break;
for (k = j; yytext[k]; k++)
if (yytext[k] <= 32)
break;
if (j == k)
return;
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
s[k-j] = '\0';
m->part = s;
}
else if (!strncmp(yytext+i, "method-output-mime-type:", 24))
{ m = (Method*)emalloc(sizeof(Method));
m->name = s;
m->mess = MIMEOUT;
m->part = NULL;
m->next = sp->list;
sp->list = m;
for (j = k; yytext[j]; j++)
if (yytext[j] > 32)
break;
for (k = j; yytext[k]; k++)
if (yytext[k] <= 32)
break;
if (j == k)
return;
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
s[k-j] = '\0';
m->part = s;
}
else if (!strncmp(yytext+i, "method-header-part:", 19))
{ m = (Method*)emalloc(sizeof(Method));
m->name = s;
m->mess = HDRIN | HDROUT;
m->part = NULL;
m->next = sp->list;
sp->list = m;
for (j = k; yytext[j]; j++)
if (yytext[j] > 32)
break;
for (k = j; yytext[k]; k++)
if (yytext[k] <= 32)
break;
if (j == k)
return;
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
s[k-j] = '\0';
m->part = s;
}
else if (!strncmp(yytext+i, "method-input-header-part:", 25))
{ m = (Method*)emalloc(sizeof(Method));
m->name = s;
m->mess = HDRIN;
m->part = NULL;
m->next = sp->list;
sp->list = m;
for (j = k; yytext[j]; j++)
if (yytext[j] > 32)
break;
for (k = j; yytext[k]; k++)
if (yytext[k] <= 32)
break;
if (j == k)
return;
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
s[k-j] = '\0';
m->part = s;
}
else if (!strncmp(yytext+i, "method-output-header-part:", 26))
{ m = (Method*)emalloc(sizeof(Method));
m->name = s;
m->mess = HDROUT;
m->part = NULL;
m->next = sp->list;
sp->list = m;
for (j = k; yytext[j]; j++)
if (yytext[j] > 32)
break;
for (k = j; yytext[k]; k++)
if (yytext[k] <= 32)
break;
if (j == k)
return;
s = (char*)emalloc(k-j+1);
strncpy(s, yytext+j, k-j);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -