Code Monkey home page Code Monkey logo

Comments (5)

erezsh avatar erezsh commented on June 11, 2024 1

Well, you have to set propagate_positions=True to enable the Tree meta .

from lark.

thehappycheese avatar thehappycheese commented on June 11, 2024

Ahh thanks so much @erezsh :) Really appreciate that you took the time. I did not spot that in the docs... I searched for a bunch of things along the lines of "metadata" but i guess thats no substitute for carefully reading the whole thing

I changed

lgram = Lark(grammar_text, propagate_positions=True)

and

print(f"Comment: line Token({line=}) Tree({meta.line=})")
Comment: line Token(line=53) Tree(meta.line=2)
exponent
Comment: line Token(line=53) Tree(meta.line=4)

Now I get the correct line when reading the metadata from the Tree(meta.line), but interestingly the same seemingly incorrect result when reading Token(line). Probably i will need to do some more careful reading 😕

from lark.

erezsh avatar erezsh commented on June 11, 2024

I'm sure you'll figure it out.

I suggest starting with a minimal example and debugging it. (minimal grammar, minimal input)

If you have it, but still can't figure it out, paste it here and I'll take a look.

from lark.

erezsh avatar erezsh commented on June 11, 2024

Many thanks <3 awesome project :)

Thanks :)

from lark.

thehappycheese avatar thehappycheese commented on June 11, 2024

Ahhh now I get it... of course, Token(line) is the line that the rule comment was declared in the grammar 🤦‍♂️

from lark.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.