Update the go parser to the latest version from ctags

This commit is contained in:
Jiří Techet 2014-12-07 22:25:13 +01:00
parent 0184083a7e
commit 7c22ceacf9

View File

@ -521,20 +521,16 @@ static void makeTag (tokenInfo *const token, const goKind kind)
static void parsePackage (tokenInfo *const token)
{
tokenInfo *const name = newToken ();
readToken (name);
if (isType (name, TOKEN_IDENTIFIER))
readToken (token);
if (isType (token, TOKEN_IDENTIFIER))
{
makeTag (name, GOTAG_PACKAGE);
makeTag (token, GOTAG_PACKAGE);
if (!scope && Option.include.qualifiedTags)
{
scope = vStringNew ();
vStringCopy (scope, name->string);
vStringCopy (scope, token->string);
}
}
deleteToken (name);
}
static void parseFunctionOrMethod (tokenInfo *const token)
@ -545,15 +541,16 @@ static void parseFunctionOrMethod (tokenInfo *const token)
// MethodDecl = "func" Receiver MethodName Signature [ Body ] .
// Receiver = "(" [ identifier ] [ "*" ] BaseTypeName ")" .
// BaseTypeName = identifier .
tokenInfo *const name = newToken ();
// Skip over receiver.
readToken (name);
if (isType (name, TOKEN_OPEN_PAREN))
skipToMatched (name);
readToken (token);
if (isType (token, TOKEN_OPEN_PAREN))
skipToMatched (token);
if (isType (name, TOKEN_IDENTIFIER))
if (isType (token, TOKEN_IDENTIFIER))
{
makeTag (token, GOTAG_FUNCTION);
// Skip over parameters.
readToken (token);
skipToMatched (token);
@ -564,11 +561,7 @@ static void parseFunctionOrMethod (tokenInfo *const token)
// Skip over function body.
if (isType (token, TOKEN_OPEN_CURLY))
skipToMatched (token);
makeTag (name, GOTAG_FUNCTION);
}
deleteToken (name);
}
static void parseConstTypeVar (tokenInfo *const token, goKind kind)
@ -581,49 +574,46 @@ static void parseConstTypeVar (tokenInfo *const token, goKind kind)
// TypeSpec = identifier Type .
// VarDecl = "var" ( VarSpec | "(" { VarSpec ";" } ")" ) .
// VarSpec = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) .
tokenInfo *const name = newToken ();
boolean usesParens = FALSE;
readToken (name);
readToken (token);
if (isType (name, TOKEN_OPEN_PAREN))
if (isType (token, TOKEN_OPEN_PAREN))
{
usesParens = TRUE;
readToken (name);
readToken (token);
}
again:
while (1)
do
{
if (isType (name, TOKEN_IDENTIFIER))
while (!isType (token, TOKEN_EOF))
{
makeTag (name, kind);
if (isType (token, TOKEN_IDENTIFIER))
{
makeTag (token, kind);
readToken (token);
}
if (!isType (token, TOKEN_COMMA))
break;
readToken (token);
}
if (!isType (token, TOKEN_COMMA))
break;
readToken (name);
}
skipType (token);
while (!isType (token, TOKEN_SEMICOLON) && !isType (token, TOKEN_CLOSE_PAREN)
&& !isType (token, TOKEN_EOF))
{
readToken (token);
skipToMatched (token);
}
if (usesParens)
{
if (!isType (token, TOKEN_CLOSE_PAREN)) // we are at TOKEN_SEMICOLON
skipType (token);
while (!isType (token, TOKEN_SEMICOLON) && !isType (token, TOKEN_CLOSE_PAREN)
&& !isType (token, TOKEN_EOF))
{
readToken (name);
if (!isType (name, TOKEN_CLOSE_PAREN) && !isType (name, TOKEN_EOF))
goto again;
readToken (token);
skipToMatched (token);
}
if (usesParens && !isType (token, TOKEN_CLOSE_PAREN))
{
// we are at TOKEN_SEMICOLON
readToken (token);
}
}
deleteToken (name);
while (!isType (token, TOKEN_EOF) &&
usesParens && !isType (token, TOKEN_CLOSE_PAREN));
}
static void parseGoFile (tokenInfo *const token)