trunk/eiffel.c:

trunk/fortran.c: 
trunk/jscript.c: 
trunk/keyword.c: 
trunk/keyword.h: 
trunk/sql.c: 
trunk/vhdl.c: we only need one copy of analyzeToken.


git-svn-id: svn://svn.code.sf.net/p/ctags/code/trunk@658 c5d04d22-be80-434c-894e-aa346cc9e8e8
This commit is contained in:
elliotth 2008-04-20 23:21:35 +00:00
parent 95315d2198
commit 570a6720a1
7 changed files with 18 additions and 64 deletions

View File

@ -599,18 +599,6 @@ static void parseFreeOperator (vString *const string, const int firstChar)
fileUngetc (c); /* unget non-identifier character */
}
static keywordId analyzeToken (vString *const name)
{
vString *keyword = vStringNew ();
keywordId id;
vStringCopyToLower (keyword, name);
id = (keywordId) lookupKeyword (vStringValue (keyword), Lang_eiffel);
vStringDelete (keyword);
return id;
}
static void readToken (tokenInfo *const token)
{
int c;
@ -719,7 +707,8 @@ getNextChar:
if (isalpha (c))
{
parseIdentifier (token->string, c);
token->keyword = analyzeToken (token->string);
token->keyword =
analyzeToken (token->string, Lang_eiffel);
if (isKeyword (token, KEYWORD_NONE))
token->type = TOKEN_IDENTIFIER;
else

View File

@ -864,22 +864,6 @@ static void parseIdentifier (vString *const string, const int firstChar)
ungetChar (c); /* unget non-identifier character */
}
/* Analyzes the identifier contained in a statement described by the
* statement structure and adjusts the structure according the significance
* of the identifier.
*/
static keywordId analyzeToken (vString *const name)
{
vString *keyword = vStringNew ();
keywordId id;
vStringCopyToLower (keyword, name);
id = (keywordId) lookupKeyword (vStringValue (keyword), Lang_fortran);
vStringDelete (keyword);
return id;
}
static void checkForLabel (void)
{
tokenInfo* token = NULL;
@ -912,7 +896,7 @@ static void checkForLabel (void)
static void readIdentifier (tokenInfo *const token, const int c)
{
parseIdentifier (token->string, c);
token->keyword = analyzeToken (token->string);
token->keyword = analyzeToken (token->string, Lang_fortran);
if (! isKeyword (token, KEYWORD_NONE))
token->type = TOKEN_KEYWORD;
else
@ -921,7 +905,7 @@ static void readIdentifier (tokenInfo *const token, const int c)
if (strncmp (vStringValue (token->string), "end", 3) == 0)
{
vString *const sub = vStringNewInit (vStringValue (token->string) + 3);
const keywordId kw = analyzeToken (sub);
const keywordId kw = analyzeToken (sub, Lang_fortran);
vStringDelete (sub);
if (kw != KEYWORD_NONE)
{

View File

@ -332,16 +332,6 @@ static void parseIdentifier (vString *const string, const int firstChar)
fileUngetc (c); /* unget non-identifier character */
}
static keywordId analyzeToken (vString *const name)
{
vString *keyword = vStringNew ();
keywordId result;
vStringCopyToLower (keyword, name);
result = (keywordId) lookupKeyword (vStringValue (keyword), Lang_js);
vStringDelete (keyword);
return result;
}
static void readToken (tokenInfo *const token)
{
int c;
@ -432,7 +422,7 @@ getNextChar:
parseIdentifier (token->string, c);
token->lineNumber = getSourceLineNumber ();
token->filePosition = getInputFilePosition ();
token->keyword = analyzeToken (token->string);
token->keyword = analyzeToken (token->string, Lang_js);
if (isKeyword (token, KEYWORD_NONE))
token->type = TOKEN_IDENTIFIER;
else

View File

@ -192,6 +192,16 @@ extern void freeKeywordTable (void)
}
}
extern int analyzeToken (vString *const name, langType language)
{
vString *keyword = vStringNew ();
int result;
vStringCopyToLower (keyword, name);
result = lookupKeyword (vStringValue (keyword), language);
vStringDelete (keyword);
return result;
}
#ifdef DEBUG
static void printEntry (const hashEntry *const entry)

View File

@ -27,6 +27,7 @@ extern void freeKeywordTable (void);
#ifdef DEBUG
extern void printKeywordTable (void);
#endif
extern int analyzeToken (vString *const name, langType language);
#endif /* _KEYWORD_H */

12
sql.c
View File

@ -511,16 +511,6 @@ static void parseIdentifier (vString *const string, const int firstChar)
fileUngetc (c); /* unget non-identifier character */
}
static keywordId analyzeToken (vString *const name)
{
vString *keyword = vStringNew ();
keywordId result;
vStringCopyToLower (keyword, name);
result = (keywordId) lookupKeyword (vStringValue (keyword), Lang_sql);
vStringDelete (keyword);
return result;
}
static void readToken (tokenInfo *const token)
{
int c;
@ -654,7 +644,7 @@ getNextChar:
parseIdentifier (token->string, c);
token->lineNumber = getSourceLineNumber ();
token->filePosition = getInputFilePosition ();
token->keyword = analyzeToken (token->string);
token->keyword = analyzeToken (token->string, Lang_sql);
if (isKeyword (token, KEYWORD_rem))
{
vStringClear (token->string);

12
vhdl.c
View File

@ -410,16 +410,6 @@ static void parseIdentifier (vString * const string, const int firstChar)
fileUngetc (c); /* unget non-identifier character */
}
static keywordId analyzeToken (vString * const name)
{
vString *keyword = vStringNew ();
keywordId result;
vStringCopyToLower (keyword, name);
result = (keywordId) lookupKeyword (vStringValue (keyword), Lang_vhdl);
vStringDelete (keyword);
return result;
}
static void readToken (tokenInfo * const token)
{
int c;
@ -487,7 +477,7 @@ static void readToken (tokenInfo * const token)
parseIdentifier (token->string, c);
token->lineNumber = getSourceLineNumber ();
token->filePosition = getInputFilePosition ();
token->keyword = analyzeToken (token->string);
token->keyword = analyzeToken (token->string, Lang_vhdl);
if (isKeyword (token, KEYWORD_NONE))
token->type = TOKEN_IDENTIFIER;
else