-
-
Notifications
You must be signed in to change notification settings - Fork 414
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
propagate_positions isn't well documented #1293
Labels
Comments
It's tree.meta
…On Wed, 28 Jun 2023 at 21:31, ningit ***@***.***> wrote:
*Describe the bug*
The keyword argument propagate_positions of Lark
<https://lark-parser.readthedocs.io/en/latest/classes.html#lark.Lark>
constructor is not obeyed. The attributes line, column, end_line, and
end_column are not available in the Tree objects returned by Lark.parse.
*To Reproduce*
In the following code, the last two lines produce an AttributeError:
'Tree' object has no attribute 'line', while they should return 1.
import lark
grammar = ''' %import common.WS %ignore WS %import common.INT -> NUMBER start: expr expr: NUMBER | NUMBER "+" NUMBER'''
parser = lark.Lark(grammar, parser='lalr', propagate_positions=True)tree = parser.parse('1 + 2')
print(tree.children[0].children[0].line)print(tree.children[0].line)print(tree.line)
—
Reply to this email directly, view it on GitHub
<#1293>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFSSSD4QKACQRQG45TXHXTXNR2ARANCNFSM6AAAAAAZXQB4NU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Many thanks and sorry. Now I see this is mentioned in the documentation for the constructor of the Anyhow, making explicit that these attributes are available through |
erezsh
changed the title
propagate_positions does not work
propagate_positions ~does not work~ not well documented
Jun 29, 2023
erezsh
changed the title
propagate_positions ~does not work~ not well documented
propagate_positions ~~does not work~~ not well documented
Jun 29, 2023
erezsh
changed the title
propagate_positions ~~does not work~~ not well documented
propagate_positions isn't well documented
Jun 29, 2023
Great, it is now clearer. I think the PR solves the issue. |
Great! Added even more explanations too. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
The keyword argument
propagate_positions
of Lark constructor is not obeyed. The attributesline
,column
,end_line
, andend_column
are not available in theTree
objects returned byLark.parse
.To Reproduce
In the following code, the last two lines produce an
AttributeError: 'Tree' object has no attribute 'line'
, while they should return 1.The text was updated successfully, but these errors were encountered: