Commit f35ced3d authored by Michael Meskes's avatar Michael Meskes

- Fixed reduce/reduce conflict in parser.

        - Synced preproc.y with gram.y.
        - Synced pgc.l with scan.l.
        - Synced keywords.c.
parent f76bc9c7
...@@ -1247,6 +1247,13 @@ Sun Apr 28 19:16:40 CEST 2002 ...@@ -1247,6 +1247,13 @@ Sun Apr 28 19:16:40 CEST 2002
- Synced preproc.y with gram.y. - Synced preproc.y with gram.y.
- Fixed typo in comment printed by ecpg. - Fixed typo in comment printed by ecpg.
Sun May 19 19:21:34 CEST 2002
- Fixed reduce/reduce conflict in parser.
- Synced preproc.y with gram.y.
- Synced pgc.l with scan.l.
- Synced keywords.c.
- Set ecpg version to 2.10.0. - Set ecpg version to 2.10.0.
- Set library version to 3.4.0. - Set library version to 3.4.0.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* lexical token lookup for reserved words in postgres embedded SQL * lexical token lookup for reserved words in postgres embedded SQL
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.25 2001/09/19 14:09:32 meskes Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.26 2002/05/19 20:00:53 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -34,6 +34,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -34,6 +34,7 @@ static ScanKeyword ScanKeywords[] = {
{"connection", SQL_CONNECTION}, {"connection", SQL_CONNECTION},
{"continue", SQL_CONTINUE}, {"continue", SQL_CONTINUE},
{"count", SQL_COUNT}, {"count", SQL_COUNT},
{"current", SQL_CURRENT},
{"data", SQL_DATA}, {"data", SQL_DATA},
{"datetime_interval_code", SQL_DATETIME_INTERVAL_CODE}, {"datetime_interval_code", SQL_DATETIME_INTERVAL_CODE},
{"datetime_interval_precision", SQL_DATETIME_INTERVAL_PRECISION}, {"datetime_interval_precision", SQL_DATETIME_INTERVAL_PRECISION},
...@@ -48,7 +49,6 @@ static ScanKeyword ScanKeywords[] = { ...@@ -48,7 +49,6 @@ static ScanKeyword ScanKeywords[] = {
{"goto", SQL_GOTO}, {"goto", SQL_GOTO},
{"identified", SQL_IDENTIFIED}, {"identified", SQL_IDENTIFIED},
{"indicator", SQL_INDICATOR}, {"indicator", SQL_INDICATOR},
{"int", SQL_INT},
{"key_member", SQL_KEY_MEMBER}, {"key_member", SQL_KEY_MEMBER},
{"length", SQL_LENGTH}, {"length", SQL_LENGTH},
{"long", SQL_LONG}, {"long", SQL_LONG},
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.47 2002/04/22 18:54:43 meskes Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.48 2002/05/19 20:00:53 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -50,11 +50,14 @@ static ScanKeyword ScanKeywords[] = { ...@@ -50,11 +50,14 @@ static ScanKeyword ScanKeywords[] = {
{"before", BEFORE}, {"before", BEFORE},
{"begin", BEGIN_TRANS}, {"begin", BEGIN_TRANS},
{"between", BETWEEN}, {"between", BETWEEN},
{"bigint", BIGINT},
{"binary", BINARY}, {"binary", BINARY},
{"bit", BIT}, {"bit", BIT},
{"boolean", BOOLEAN},
{"both", BOTH}, {"both", BOTH},
{"by", BY}, {"by", BY},
{"cache", CACHE}, {"cache", CACHE},
{"called", CALLED},
{"cascade", CASCADE}, {"cascade", CASCADE},
{"case", CASE}, {"case", CASE},
{"cast", CAST}, {"cast", CAST},
...@@ -93,6 +96,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -93,6 +96,7 @@ static ScanKeyword ScanKeywords[] = {
{"default", DEFAULT}, {"default", DEFAULT},
{"deferrable", DEFERRABLE}, {"deferrable", DEFERRABLE},
{"deferred", DEFERRED}, {"deferred", DEFERRED},
{"definer", DEFINER},
{"delete", DELETE}, {"delete", DELETE},
{"delimiters", DELIMITERS}, {"delimiters", DELIMITERS},
{"desc", DESC}, {"desc", DESC},
...@@ -112,6 +116,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -112,6 +116,7 @@ static ScanKeyword ScanKeywords[] = {
{"execute", EXECUTE}, {"execute", EXECUTE},
{"exists", EXISTS}, {"exists", EXISTS},
{"explain", EXPLAIN}, {"explain", EXPLAIN},
{"external", EXTERNAL},
{"extract", EXTRACT}, {"extract", EXTRACT},
{"false", FALSE_P}, {"false", FALSE_P},
{"fetch", FETCH}, {"fetch", FETCH},
...@@ -132,6 +137,8 @@ static ScanKeyword ScanKeywords[] = { ...@@ -132,6 +137,8 @@ static ScanKeyword ScanKeywords[] = {
{"hour", HOUR_P}, {"hour", HOUR_P},
{"ilike", ILIKE}, {"ilike", ILIKE},
{"immediate", IMMEDIATE}, {"immediate", IMMEDIATE},
{"immutable", IMMUTABLE},
{"implicit", IMPLICIT},
{"in", IN}, {"in", IN},
{"increment", INCREMENT}, {"increment", INCREMENT},
{"index", INDEX}, {"index", INDEX},
...@@ -139,12 +146,16 @@ static ScanKeyword ScanKeywords[] = { ...@@ -139,12 +146,16 @@ static ScanKeyword ScanKeywords[] = {
{"initially", INITIALLY}, {"initially", INITIALLY},
{"inner", INNER_P}, {"inner", INNER_P},
{"inout", INOUT}, {"inout", INOUT},
{"input", INPUT},
{"insensitive", INSENSITIVE}, {"insensitive", INSENSITIVE},
{"insert", INSERT}, {"insert", INSERT},
{"instead", INSTEAD}, {"instead", INSTEAD},
{"int", INT},
{"integer", INTEGER},
{"intersect", INTERSECT}, {"intersect", INTERSECT},
{"interval", INTERVAL}, {"interval", INTERVAL},
{"into", INTO}, {"into", INTO},
{"invoker", INVOKER},
{"is", IS}, {"is", IS},
{"isnull", ISNULL}, {"isnull", ISNULL},
{"isolation", ISOLATION}, {"isolation", ISOLATION},
...@@ -213,6 +224,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -213,6 +224,7 @@ static ScanKeyword ScanKeywords[] = {
{"procedural", PROCEDURAL}, {"procedural", PROCEDURAL},
{"procedure", PROCEDURE}, {"procedure", PROCEDURE},
{"read", READ}, {"read", READ},
{"real", REAL},
{"references", REFERENCES}, {"references", REFERENCES},
{"reindex", REINDEX}, {"reindex", REINDEX},
{"relative", RELATIVE}, {"relative", RELATIVE},
...@@ -229,6 +241,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -229,6 +241,7 @@ static ScanKeyword ScanKeywords[] = {
{"schema", SCHEMA}, {"schema", SCHEMA},
{"scroll", SCROLL}, {"scroll", SCROLL},
{"second", SECOND_P}, {"second", SECOND_P},
{"security", SECURITY},
{"select", SELECT}, {"select", SELECT},
{"sequence", SEQUENCE}, {"sequence", SEQUENCE},
{"serializable", SERIALIZABLE}, {"serializable", SERIALIZABLE},
...@@ -238,13 +251,16 @@ static ScanKeyword ScanKeywords[] = { ...@@ -238,13 +251,16 @@ static ScanKeyword ScanKeywords[] = {
{"setof", SETOF}, {"setof", SETOF},
{"share", SHARE}, {"share", SHARE},
{"show", SHOW}, {"show", SHOW},
{"smallint", SMALLINT},
{"some", SOME}, {"some", SOME},
{"stable", STABLE},
{"start", START}, {"start", START},
{"statement", STATEMENT}, {"statement", STATEMENT},
{"statistics", STATISTICS}, {"statistics", STATISTICS},
{"stdin", STDIN}, {"stdin", STDIN},
{"stdout", STDOUT}, {"stdout", STDOUT},
{"storage", STORAGE}, {"storage", STORAGE},
{"strict", STRICT},
{"substring", SUBSTRING}, {"substring", SUBSTRING},
{"sysid", SYSID}, {"sysid", SYSID},
{"table", TABLE}, {"table", TABLE},
...@@ -282,6 +298,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -282,6 +298,7 @@ static ScanKeyword ScanKeywords[] = {
{"verbose", VERBOSE}, {"verbose", VERBOSE},
{"version", VERSION}, {"version", VERSION},
{"view", VIEW}, {"view", VIEW},
{"volatile", VOLATILE},
{"when", WHEN}, {"when", WHEN},
{"where", WHERE}, {"where", WHERE},
{"with", WITH}, {"with", WITH},
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.90 2002/04/05 11:39:45 momjian Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.91 2002/05/19 20:00:53 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -49,7 +49,10 @@ static int literalalloc; /* current allocated buffer size */ ...@@ -49,7 +49,10 @@ static int literalalloc; /* current allocated buffer size */
#define startlit() (literalbuf[0] = '\0', literallen = 0) #define startlit() (literalbuf[0] = '\0', literallen = 0)
static void addlit(char *ytext, int yleng); static void addlit(char *ytext, int yleng);
static void addlitchar (unsigned char);
static unsigned char unescape_single_char(unsigned char);
static char *token_start;
int state_before; int state_before;
struct _yy_buffer struct _yy_buffer
...@@ -131,10 +134,11 @@ xqstart {quote} ...@@ -131,10 +134,11 @@ xqstart {quote}
xqstop {quote} xqstop {quote}
xqdouble {quote}{quote} xqdouble {quote}{quote}
xqinside [^\\']+ xqinside [^\\']+
xqliteral [\\](.|\n) xqescape [\\][^0-7]
xqoctesc [\\][0-7]{1,3}
xqcat {quote}{whitespace_with_newline}{quote} xqcat {quote}{whitespace_with_newline}{quote}
/* Delimited quote /* Double quote
* Allows embedded spaces and other special characters into identifiers. * Allows embedded spaces and other special characters into identifiers.
*/ */
dquote \" dquote \"
...@@ -229,7 +233,7 @@ non_newline [^\n\r] ...@@ -229,7 +233,7 @@ non_newline [^\n\r]
comment ("--"{non_newline}*) comment ("--"{non_newline}*)
whitespace ({space}|{comment}) whitespace ({space}+|{comment})
/* /*
* SQL92 requires at least one newline in the whitespace separating * SQL92 requires at least one newline in the whitespace separating
...@@ -262,10 +266,7 @@ ip {ipdigit}\.{ipdigit}\.{ipdigit}\.{ipdigit} ...@@ -262,10 +266,7 @@ ip {ipdigit}\.{ipdigit}\.{ipdigit}\.{ipdigit}
/* Take care of cpp continuation lines */ /* Take care of cpp continuation lines */
cppline {space}*#(.*\\{space})*.* cppline {space}*#(.*\\{space})*.*
/* DO NOT PUT ANY COMMENTS IN THE FOLLOWING SECTION. /*
* AT&T lex does not properly handle C-style comments in this second lex block.
* So, put comments here. thomas - 1997-09-08
*
* Quoted strings must allow some special characters such as single-quote * Quoted strings must allow some special characters such as single-quote
* and newline. * and newline.
* Embedded single-quotes are implemented both in the SQL92-standard * Embedded single-quotes are implemented both in the SQL92-standard
...@@ -278,9 +279,16 @@ cppline {space}*#(.*\\{space})*.* ...@@ -278,9 +279,16 @@ cppline {space}*#(.*\\{space})*.*
*/ */
%% %%
%{
/* code to execute during start of each call of yylex() */
token_start = NULL;
%}
<SQL>{whitespace} { /* ignore */ } <SQL>{whitespace} { /* ignore */ }
{xcstart} { {xcstart} {
token_start = yytext;
state_before = YYSTATE; state_before = YYSTATE;
xcdepth = 0; xcdepth = 0;
BEGIN(xc); BEGIN(xc);
...@@ -298,7 +306,10 @@ cppline {space}*#(.*\\{space})*.* ...@@ -298,7 +306,10 @@ cppline {space}*#(.*\\{space})*.*
<xc>{xcstop} { <xc>{xcstop} {
ECHO; ECHO;
if (xcdepth <= 0) if (xcdepth <= 0)
BEGIN(state_before); {
BEGIN(INITIAL);
token_start = NULL;
}
else else
xcdepth--; xcdepth--;
} }
...@@ -309,8 +320,10 @@ cppline {space}*#(.*\\{space})*.* ...@@ -309,8 +320,10 @@ cppline {space}*#(.*\\{space})*.*
<xc><<EOF>> { mmerror(PARSE_ERROR, ET_ERROR, "Unterminated /* comment"); } <xc><<EOF>> { mmerror(PARSE_ERROR, ET_ERROR, "Unterminated /* comment"); }
<SQL>{xbitstart} { <SQL>{xbitstart} {
token_start = yytext;
BEGIN(xbit); BEGIN(xbit);
startlit(); startlit();
addlitchar('b');
} }
<xbit>{xbitstop} { <xbit>{xbitstop} {
BEGIN(SQL); BEGIN(SQL);
...@@ -327,6 +340,7 @@ cppline {space}*#(.*\\{space})*.* ...@@ -327,6 +340,7 @@ cppline {space}*#(.*\\{space})*.*
<xbit><<EOF>> { mmerror(PARSE_ERROR, ET_ERROR, "Unterminated bit string"); } <xbit><<EOF>> { mmerror(PARSE_ERROR, ET_ERROR, "Unterminated bit string"); }
<SQL>{xhstart} { <SQL>{xhstart} {
token_start = yytext;
BEGIN(xh); BEGIN(xh);
startlit(); startlit();
} }
...@@ -351,6 +365,7 @@ cppline {space}*#(.*\\{space})*.* ...@@ -351,6 +365,7 @@ cppline {space}*#(.*\\{space})*.*
<xh><<EOF>> { mmerror(PARSE_ERROR, ET_ERROR, "Unterminated hexadecimal integer"); } <xh><<EOF>> { mmerror(PARSE_ERROR, ET_ERROR, "Unterminated hexadecimal integer"); }
<C,SQL>{xqstart} { <C,SQL>{xqstart} {
token_start = yytext;
state_before = YYSTATE; state_before = YYSTATE;
BEGIN(xq); BEGIN(xq);
startlit(); startlit();
...@@ -360,9 +375,11 @@ cppline {space}*#(.*\\{space})*.* ...@@ -360,9 +375,11 @@ cppline {space}*#(.*\\{space})*.*
yylval.str = mm_strdup(literalbuf); yylval.str = mm_strdup(literalbuf);
return SCONST; return SCONST;
} }
<xq>{xqdouble} | <xq>{xqdouble} { addlitchar('\''); }
<xq>{xqinside} | <xq>{xqinside} { addlit(yytext, yyleng); }
<xq>{xqliteral} { addlit(yytext, yyleng); } <xq>{xqescape} { addlitchar(unescape_single_char(yytext[1])); }
<xq>{xqoctesc} { unsigned char c = strtoul(yytext+1, NULL, 8);
addlitchar(c); }
<xq>{xqcat} { /* ignore */ } <xq>{xqcat} { /* ignore */ }
<xq><<EOF>> { mmerror(PARSE_ERROR, ET_ERROR, "Unterminated quoted string"); } <xq><<EOF>> { mmerror(PARSE_ERROR, ET_ERROR, "Unterminated quoted string"); }
...@@ -374,20 +391,13 @@ cppline {space}*#(.*\\{space})*.* ...@@ -374,20 +391,13 @@ cppline {space}*#(.*\\{space})*.*
} }
<xd>{xdstop} { <xd>{xdstop} {
BEGIN(state_before); BEGIN(state_before);
if (strlen(literalbuf) >= NAMEDATALEN) if (literallen == 0)
mmerror(PARSE_ERROR, ET_ERROR, "zero-length delimited identifier");
if (literallen >= NAMEDATALEN)
{ {
#ifdef MULTIBYTE_NOTUSED
int len;
len = pg_mbcliplen(literalbuf,strlen(literalbuf),NAMEDATALEN-1);
sprintf(errortext, "identifier \"%s\" will be truncated to \"%.*s\"",
literalbuf, len, literalbuf);
literalbuf[len] = '\0';
#else
sprintf(errortext, "identifier \"%s\" will be truncated to \"%.*s\"", sprintf(errortext, "identifier \"%s\" will be truncated to \"%.*s\"",
literalbuf, NAMEDATALEN-1, literalbuf); literalbuf, NAMEDATALEN-1, literalbuf);
literalbuf[NAMEDATALEN-1] = '\0'; literalbuf[NAMEDATALEN-1] = '\0';
#endif
mmerror(PARSE_ERROR, ET_WARNING, errortext); mmerror(PARSE_ERROR, ET_WARNING, errortext);
} }
...@@ -399,7 +409,7 @@ cppline {space}*#(.*\\{space})*.* ...@@ -399,7 +409,7 @@ cppline {space}*#(.*\\{space})*.*
yylval.str = mm_strdup(literalbuf); yylval.str = mm_strdup(literalbuf);
return CSTRING; return CSTRING;
} }
<xd>{xddouble} { addlit(yytext, yyleng-1); } <xd>{xddouble} { addlitchar('"'); }
<xd>{xdinside} { addlit(yytext, yyleng); } <xd>{xdinside} { addlit(yytext, yyleng); }
<xd,xdc><<EOF>> { mmerror(PARSE_ERROR, ET_ERROR, "Unterminated quoted identifier"); } <xd,xdc><<EOF>> { mmerror(PARSE_ERROR, ET_ERROR, "Unterminated quoted identifier"); }
<C,SQL>{xdstart} { <C,SQL>{xdstart} {
...@@ -426,8 +436,8 @@ cppline {space}*#(.*\\{space})*.* ...@@ -426,8 +436,8 @@ cppline {space}*#(.*\\{space})*.*
* character will match a prior rule, not this one. * character will match a prior rule, not this one.
*/ */
int nchars = yyleng; int nchars = yyleng;
char *slashstar = strstr((char*)yytext, "/*"); char *slashstar = strstr(yytext, "/*");
char *dashdash = strstr((char*)yytext, "--"); char *dashdash = strstr(yytext, "--");
if (slashstar && dashdash) if (slashstar && dashdash)
{ {
...@@ -438,7 +448,7 @@ cppline {space}*#(.*\\{space})*.* ...@@ -438,7 +448,7 @@ cppline {space}*#(.*\\{space})*.*
else if (!slashstar) else if (!slashstar)
slashstar = dashdash; slashstar = dashdash;
if (slashstar) if (slashstar)
nchars = slashstar - ((char*)yytext); nchars = slashstar - yytext;
/* /*
* For SQL92 compatibility, '+' and '-' cannot be the * For SQL92 compatibility, '+' and '-' cannot be the
...@@ -480,14 +490,14 @@ cppline {space}*#(.*\\{space})*.* ...@@ -480,14 +490,14 @@ cppline {space}*#(.*\\{space})*.*
} }
/* Convert "!=" operator to "<>" for compatibility */ /* Convert "!=" operator to "<>" for compatibility */
if (strcmp((char*)yytext, "!=") == 0) if (strcmp(yytext, "!=") == 0)
yylval.str = mm_strdup("<>"); yylval.str = mm_strdup("<>");
else else
yylval.str = mm_strdup((char*)yytext); yylval.str = mm_strdup(yytext);
return Op; return Op;
} }
<SQL>{param} { <SQL>{param} {
yylval.ival = atol((char*)&yytext[1]); yylval.ival = atol(yytext+1);
return PARAM; return PARAM;
} }
<C,SQL>{integer} { <C,SQL>{integer} {
...@@ -504,26 +514,26 @@ cppline {space}*#(.*\\{space})*.* ...@@ -504,26 +514,26 @@ cppline {space}*#(.*\\{space})*.*
) )
{ {
errno = 0; errno = 0;
yylval.str = mm_strdup((char*)yytext); yylval.str = mm_strdup(yytext);
return FCONST; return FCONST;
} }
yylval.ival = val; yylval.ival = val;
return ICONST; return ICONST;
} }
<SQL>{ip} { <SQL>{ip} {
yylval.str = mm_strdup((char*)yytext); yylval.str = mm_strdup(yytext);
return IP; return IP;
} }
{decimal} { {decimal} {
yylval.str = mm_strdup((char*)yytext); yylval.str = mm_strdup(yytext);
return FCONST; return FCONST;
} }
<C,SQL>{real} { <C,SQL>{real} {
yylval.str = mm_strdup((char*)yytext); yylval.str = mm_strdup(yytext);
return FCONST; return FCONST;
} }
<SQL>:{identifier}(("->"|\.){identifier})* { <SQL>:{identifier}(("->"|\.){identifier})* {
yylval.str = mm_strdup((char*)yytext+1); yylval.str = mm_strdup(yytext+1);
return(CVARIABLE); return(CVARIABLE);
} }
<SQL>{identifier} { <SQL>{identifier} {
...@@ -531,12 +541,12 @@ cppline {space}*#(.*\\{space})*.* ...@@ -531,12 +541,12 @@ cppline {space}*#(.*\\{space})*.*
struct _defines *ptr; struct _defines *ptr;
/* Is it an SQL keyword? */ /* Is it an SQL keyword? */
keyword = ScanKeywordLookup((char*) yytext); keyword = ScanKeywordLookup(yytext);
if (keyword != NULL) if (keyword != NULL)
return keyword->value; return keyword->value;
/* Is it an ECPG keyword? */ /* Is it an ECPG keyword? */
keyword = ScanECPGKeywordLookup((char*) yytext); keyword = ScanECPGKeywordLookup( yytext);
if (keyword != NULL) if (keyword != NULL)
return keyword->value; return keyword->value;
...@@ -571,7 +581,7 @@ cppline {space}*#(.*\\{space})*.* ...@@ -571,7 +581,7 @@ cppline {space}*#(.*\\{space})*.*
*/ */
if (ptr == NULL) if (ptr == NULL)
{ {
yylval.str = mm_strdup((char*) yytext); yylval.str = mm_strdup( yytext);
return IDENT; return IDENT;
} }
} }
...@@ -586,19 +596,19 @@ cppline {space}*#(.*\\{space})*.* ...@@ -586,19 +596,19 @@ cppline {space}*#(.*\\{space})*.*
if (*endptr != '\0' || errno == ERANGE) if (*endptr != '\0' || errno == ERANGE)
{ {
errno = 0; errno = 0;
yylval.str = mm_strdup((char*)yytext); yylval.str = mm_strdup(yytext);
return SCONST; return SCONST;
} }
return ICONST; return ICONST;
} }
<C>{cppline} { <C>{cppline} {
yylval.str = mm_strdup((char*)yytext); yylval.str = mm_strdup(yytext);
return(CPP_LINE); return(CPP_LINE);
} }
<C>{identifier} { <C>{identifier} {
ScanKeyword *keyword; ScanKeyword *keyword;
keyword = ScanCKeywordLookup((char*)yytext); keyword = ScanCKeywordLookup(yytext);
if (keyword != NULL) { if (keyword != NULL) {
return keyword->value; return keyword->value;
} }
...@@ -627,7 +637,7 @@ cppline {space}*#(.*\\{space})*.* ...@@ -627,7 +637,7 @@ cppline {space}*#(.*\\{space})*.*
} }
if (ptr == NULL) if (ptr == NULL)
{ {
yylval.str = mm_strdup((char*)yytext); yylval.str = mm_strdup(yytext);
return IDENT; return IDENT;
} }
} }
...@@ -731,7 +741,7 @@ cppline {space}*#(.*\\{space})*.* ...@@ -731,7 +741,7 @@ cppline {space}*#(.*\\{space})*.*
yytext[i+1] = '\0'; yytext[i+1] = '\0';
for ( defptr = defines; defptr != NULL && for ( defptr = defines; defptr != NULL &&
( strcmp((char*)yytext, defptr->old) != 0 ); defptr = defptr->next ); ( strcmp(yytext, defptr->old) != 0 ); defptr = defptr->next );
preproc_tos++; preproc_tos++;
stacked_if_value[preproc_tos].else_branch = FALSE; stacked_if_value[preproc_tos].else_branch = FALSE;
...@@ -911,7 +921,37 @@ addlit(char *ytext, int yleng) ...@@ -911,7 +921,37 @@ addlit(char *ytext, int yleng)
literalbuf[literallen] = '\0'; literalbuf[literallen] = '\0';
} }
int yywrap(void) static void
addlitchar(unsigned char ychar)
{ {
return 1; /* enlarge buffer if needed */
if ((literallen+1) >= literalalloc)
{
literalalloc *= 2;
literalbuf = (char *) realloc(literalbuf, literalalloc);
}
/* append new data, add trailing null */
literalbuf[literallen] = ychar;
literallen += 1;
literalbuf[literallen] = '\0';
}
unsigned char
unescape_single_char(unsigned char c)
{
switch (c)
{
case 'b':
return '\b';
case 'f':
return '\f';
case 'n':
return '\n';
case 'r':
return '\r';
case 't':
return '\t';
default:
return c;
}
} }
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment