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