jroesch commented on a change in pull request #6162:
URL: https://github.com/apache/incubator-tvm/pull/6162#discussion_r463857316
##########
File path: src/ir/span.cc
##########
@@ -61,18 +61,29 @@ TVM_REGISTER_NODE_TYPE(SourceNameNode)
return static_cast<const SourceNameNode*>(n)->name;
});
-Span::Span(SourceName source, int lineno, int col_offset) {
+Span::Span(SourceName source, int line, int column, int end_line, int
end_column) {
auto n = make_object<SpanNode>();
n->source = std::move(source);
- n->line = lineno;
- n->column = col_offset;
+ n->line = line;
+ n->column = column;
+ n->end_line = end_line;
+ n->end_column = end_column;
data_ = std::move(n);
}
+Span Span::Merge(const Span& other) {
Review comment:
I converted the tokenizer to track spans as well and removed any use of
raw column and/or row. Now the idea is my head is most tokens will start off as
a single character or set of characters i.e (1, 1, 1, 2) or something similar
to this. The tokens are consecutive, so my goal is to union them into a larger
region as we parse to compute spans which track the entire source fragment. i.e
if I have two tokens like `def` `(` the bigger span will be
`tok1->span.Merge(tok2->span)` we can do this multiple times to compute the
greatest spanning region for the outer most node.
maybe more clearly a parent node's span will be roughly
`MergeAll(children.map(|x| { return x.span })`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]