Added location information to block statement and struct body
This commit is contained in:
parent
6e5742167a
commit
2ed0186eaa
20
std/d/ast.d
20
std/d/ast.d
|
@ -567,6 +567,17 @@ class BlockStatement : ASTNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
mixin(DEFAULT_ACCEPT);
|
mixin(DEFAULT_ACCEPT);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Byte position of the opening brace
|
||||||
|
*/
|
||||||
|
size_t startLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Byte position of the closing brace
|
||||||
|
*/
|
||||||
|
size_t endLocation;
|
||||||
|
|
||||||
/** */ DeclarationsAndStatements declarationsAndStatements;
|
/** */ DeclarationsAndStatements declarationsAndStatements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1740,6 +1751,15 @@ class StructBody : ASTNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
mixin(DEFAULT_ACCEPT);
|
mixin(DEFAULT_ACCEPT);
|
||||||
|
/**
|
||||||
|
* Byte position of the opening brace
|
||||||
|
*/
|
||||||
|
size_t startLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Byte position of the closing brace
|
||||||
|
*/
|
||||||
|
size_t endLocation;
|
||||||
/** */ Declaration[] declarations;
|
/** */ Declaration[] declarations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -848,10 +848,14 @@ alias core.sys.posix.stdio.fileno fileno;
|
||||||
{
|
{
|
||||||
mixin(traceEnterAndExit!(__FUNCTION__));
|
mixin(traceEnterAndExit!(__FUNCTION__));
|
||||||
auto node = new BlockStatement();
|
auto node = new BlockStatement();
|
||||||
if (expect(TokenType.lBrace) is null) return null;
|
auto openBrace = expect(TokenType.lBrace);
|
||||||
|
if (openBrace is null) return null;
|
||||||
|
node.startLocation = openBrace.startIndex;
|
||||||
if (!currentIs(TokenType.rBrace))
|
if (!currentIs(TokenType.rBrace))
|
||||||
node.declarationsAndStatements = parseDeclarationsAndStatements();
|
node.declarationsAndStatements = parseDeclarationsAndStatements();
|
||||||
if (expect(TokenType.rBrace) is null) return null;
|
auto closeBrace = expect(TokenType.rBrace);
|
||||||
|
if (closeBrace is null) return null;
|
||||||
|
node.endLocation = closeBrace.startIndex;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4539,10 +4543,10 @@ q{(int a, ...)
|
||||||
{
|
{
|
||||||
mixin(traceEnterAndExit!(__FUNCTION__));
|
mixin(traceEnterAndExit!(__FUNCTION__));
|
||||||
auto node = new StructBody;
|
auto node = new StructBody;
|
||||||
expect(TokenType.lBrace);
|
node.startLocation = expect(TokenType.lBrace).startIndex;
|
||||||
while (!currentIs(TokenType.rBrace) && moreTokens())
|
while (!currentIs(TokenType.rBrace) && moreTokens())
|
||||||
node.declarations ~= parseDeclaration();
|
node.declarations ~= parseDeclaration();
|
||||||
expect(TokenType.rBrace);
|
node.endLocation = expect(TokenType.rBrace).startIndex;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue