Merge pull request #183 from liranz/master
Some more location information and added declaration attributes into FunctionDeclaration scope
This commit is contained in:
commit
006528704d
|
@ -469,6 +469,8 @@ public:
|
||||||
}
|
}
|
||||||
mixin OpEquals;
|
mixin OpEquals;
|
||||||
/** */ AssignExpression[] items;
|
/** */ AssignExpression[] items;
|
||||||
|
/** */ size_t startLocation;
|
||||||
|
/** */ size_t endLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -745,6 +747,8 @@ public:
|
||||||
/** */ FunctionCallExpression functionCallExpression;
|
/** */ FunctionCallExpression functionCallExpression;
|
||||||
/** */ ArgumentList argumentList;
|
/** */ ArgumentList argumentList;
|
||||||
/** */ Token identifier;
|
/** */ Token identifier;
|
||||||
|
/** */ size_t startLocation;
|
||||||
|
/** */ size_t endLocation;
|
||||||
mixin OpEquals;
|
mixin OpEquals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1527,6 +1531,7 @@ public:
|
||||||
/** */ FunctionBody functionBody;
|
/** */ FunctionBody functionBody;
|
||||||
/** */ MemberFunctionAttribute[] memberFunctionAttributes;
|
/** */ MemberFunctionAttribute[] memberFunctionAttributes;
|
||||||
/** */ string comment;
|
/** */ string comment;
|
||||||
|
/** */ Attribute[] attributes;
|
||||||
mixin OpEquals;
|
mixin OpEquals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1978,6 +1983,8 @@ public:
|
||||||
mixin (visitIfNotNull!(moduleName));
|
mixin (visitIfNotNull!(moduleName));
|
||||||
}
|
}
|
||||||
/** */ IdentifierChain moduleName;
|
/** */ IdentifierChain moduleName;
|
||||||
|
/** */ size_t startLocation;
|
||||||
|
/** */ size_t endLocation;
|
||||||
mixin OpEquals;
|
mixin OpEquals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,11 @@ alias core.sys.posix.stdio.fileno fileno;
|
||||||
ArgumentList parseArgumentList()
|
ArgumentList parseArgumentList()
|
||||||
{
|
{
|
||||||
mixin(traceEnterAndExit!(__FUNCTION__));
|
mixin(traceEnterAndExit!(__FUNCTION__));
|
||||||
return parseCommaSeparatedRule!(ArgumentList, AssignExpression)(true);
|
size_t startLocation = current().index;
|
||||||
|
auto ret= parseCommaSeparatedRule!(ArgumentList, AssignExpression)(true);
|
||||||
|
ret.startLocation = startLocation;
|
||||||
|
ret.endLocation = current().index;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -717,7 +721,9 @@ alias core.sys.posix.stdio.fileno fileno;
|
||||||
{
|
{
|
||||||
mixin(traceEnterAndExit!(__FUNCTION__));
|
mixin(traceEnterAndExit!(__FUNCTION__));
|
||||||
auto node = allocate!AtAttribute;
|
auto node = allocate!AtAttribute;
|
||||||
if (expect(tok!"@") is null) return null;
|
auto start = expect(tok!"@");
|
||||||
|
if (start is null) return null;
|
||||||
|
node.startLocation = start.index;
|
||||||
switch (current.type)
|
switch (current.type)
|
||||||
{
|
{
|
||||||
case tok!"identifier":
|
case tok!"identifier":
|
||||||
|
@ -735,6 +741,7 @@ alias core.sys.posix.stdio.fileno fileno;
|
||||||
error(`"(", or identifier expected`);
|
error(`"(", or identifier expected`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
node.endLocation = current().index;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1783,7 +1790,7 @@ class ClassFive(A, B) : Super if (someTest()) {}}c;
|
||||||
if (peekIs(tok!"="))
|
if (peekIs(tok!"="))
|
||||||
node.variableDeclaration = parseVariableDeclaration(null, true);
|
node.variableDeclaration = parseVariableDeclaration(null, true);
|
||||||
else if (peekIs(tok!"("))
|
else if (peekIs(tok!"("))
|
||||||
node.functionDeclaration = parseFunctionDeclaration(null, true);
|
node.functionDeclaration = parseFunctionDeclaration(null, true, node.attributes);
|
||||||
else
|
else
|
||||||
goto type;
|
goto type;
|
||||||
}
|
}
|
||||||
|
@ -1804,7 +1811,7 @@ class ClassFive(A, B) : Super if (someTest()) {}}c;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (peekIs(tok!"("))
|
if (peekIs(tok!"("))
|
||||||
node.functionDeclaration = parseFunctionDeclaration(type);
|
node.functionDeclaration = parseFunctionDeclaration(type, false, node.attributes);
|
||||||
else
|
else
|
||||||
node.variableDeclaration = parseVariableDeclaration(type);
|
node.variableDeclaration = parseVariableDeclaration(type);
|
||||||
break;
|
break;
|
||||||
|
@ -2533,7 +2540,7 @@ body {} // six
|
||||||
* ($(RULE storageClass) | $(RULE _type)) $(LITERAL Identifier) $(RULE templateParameters) $(RULE parameters) $(RULE memberFunctionAttribute)* $(RULE constraint)? ($(RULE functionBody) | $(LITERAL ';'))
|
* ($(RULE storageClass) | $(RULE _type)) $(LITERAL Identifier) $(RULE templateParameters) $(RULE parameters) $(RULE memberFunctionAttribute)* $(RULE constraint)? ($(RULE functionBody) | $(LITERAL ';'))
|
||||||
* ;)
|
* ;)
|
||||||
*/
|
*/
|
||||||
FunctionDeclaration parseFunctionDeclaration(Type type = null, bool isAuto = false)
|
FunctionDeclaration parseFunctionDeclaration(Type type = null, bool isAuto = false, Attribute[] attributes = null)
|
||||||
{
|
{
|
||||||
mixin(traceEnterAndExit!(__FUNCTION__));
|
mixin(traceEnterAndExit!(__FUNCTION__));
|
||||||
auto node = allocate!FunctionDeclaration;
|
auto node = allocate!FunctionDeclaration;
|
||||||
|
@ -2541,6 +2548,8 @@ body {} // six
|
||||||
comment = null;
|
comment = null;
|
||||||
MemberFunctionAttribute[] memberFunctionAttributes;
|
MemberFunctionAttribute[] memberFunctionAttributes;
|
||||||
|
|
||||||
|
node.attributes = attributes;
|
||||||
|
|
||||||
if (isAuto)
|
if (isAuto)
|
||||||
goto functionName;
|
goto functionName;
|
||||||
|
|
||||||
|
@ -3601,9 +3610,11 @@ invariant() foo();
|
||||||
ModuleDeclaration parseModuleDeclaration()
|
ModuleDeclaration parseModuleDeclaration()
|
||||||
{
|
{
|
||||||
auto node = allocate!ModuleDeclaration;
|
auto node = allocate!ModuleDeclaration;
|
||||||
expect(tok!"module");
|
auto start = expect(tok!"module");
|
||||||
node.moduleName = parseIdentifierChain();
|
node.moduleName = parseIdentifierChain();
|
||||||
expect(tok!";");
|
auto end = expect(tok!";");
|
||||||
|
node.startLocation = start.index;
|
||||||
|
node.endLocation = end.index;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue