-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node and token location information #5
Comments
Current balance: 0.0 ETH |
Hi @onbjerg . Could you place example criteria for this task? Lets say we have this line 'Text
or it should be something different? |
@oivoodoo Your example is correct, however, when your addition expression gets turned into an AST node, the node should also look like this: {
type: 'BinaryExpression',
operator: 'PLUS',
// left: ...,
// right: ...,
location: {
start: 6,
end: 8
}
} The usefulness of this being implemented is that error messages can be a lot more helpful 😊 The thing I did for LLL.js (not finished, but available on my GitHub profile) is that I created a function that takes a closure that returns a node. It roughly looks like this: function emitToken (closure) {
let start = this.cursor
let node = closure()
return { location: { start, end: this.cursor }, ...node }
} And then I wrapped every emittance of new nodes with this function, so that each time I consume a token etc., it will be reflected in the location property |
sounds great, going to give a try tonight :)
…On 15 January 2018 at 17:16, Oliver ***@***.***> wrote:
@oivoodoo <https://github.com/oivoodoo> Your example is correct, however,
when your addition expression gets turned into an AST node, the node should
also look like this:
{
type: 'BinaryExpression',
operator: 'PLUS',
// left: ...,
// right: ...,
location: {
start: 6,
end: 8
}
}
The usefulness of this being implemented is that error messages can be a
lot more helpful 😊
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AADUxYSr_X-6i4-WlkbcXG2BV9Dia8Amks5tK13BgaJpZM4Q8mDs>
.
--
Best Regards,
Alexandr
skype: oivoodoo
|
Add location information to tokens and AST nodes that map to the corresponding range in the source Radspec expression.
The location information should be under the key
location
and have the form:Note that we do not support lines, since Radspec expressions are single line only (should we change this?).
This information will be used for #19.
Acceptance criteria
The text was updated successfully, but these errors were encountered: