Skip to content

Commit

Permalink
Merge pull request #234 from BBasile/decl-locs
Browse files Browse the repository at this point in the history
Add start and end locations to DeclarationOrStatement
merged-on-behalf-of: BBasile <[email protected]>
  • Loading branch information
dlang-bot authored May 13, 2018
2 parents 22c7829 + d75f5a9 commit 157d572
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/dparse/ast.d
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,8 @@ public:

/** */ Declaration declaration;
/** */ Statement statement;
/** */ size_t startLocation;
/** */ size_t endLocation;
mixin OpEquals;
}

Expand Down
4 changes: 4 additions & 0 deletions src/dparse/parser.d
Original file line number Diff line number Diff line change
Expand Up @@ -2232,6 +2232,8 @@ class Parser
{
mixin(traceEnterAndExit!(__FUNCTION__));
auto node = allocator.make!DeclarationOrStatement;
if (moreTokens)
node.startLocation = current.index;
// "Any ambiguities in the grammar between Statements and
// Declarations are resolved by the declarations taking precedence."
immutable b = setBookmark();
Expand All @@ -2252,6 +2254,8 @@ class Parser
goToBookmark(b);
node.declaration = parseDeclaration(true, true);
}
if (moreTokens)
node.endLocation = current.index;
return node;
}

Expand Down

0 comments on commit 157d572

Please sign in to comment.