hoaproject / Compiler

The Hoa\Compiler library.
https://hoa-project.net/
453 stars 47 forks source link

Add $node->getOffset() support #75

Closed SerafimArts closed 6 years ago

SerafimArts commented 6 years ago

In addition to synax analysis (lex), there is also a semantic analysis of code. And in the case of errors of semantics, it is required to understand exactly where the error occurred. Like:

function a(int $b) {}
a(null);

// Error: Integer required in XXX file on line 2 and offset 3, but null given.
// a(null);
//    ^

The only way to get this information is the TreeNode instance:

class TreeNode {
    +public function getOffset(): int;
}

I tried to implement this in the form of Pull Request, but the source code is pretty confusing =\

SerafimArts commented 6 years ago

Hmmm, duplicate of #70 yep?

Hywan commented 6 years ago

Yes, duplicate of #70.