GithubHelp home page GithubHelp logo

Comments (4)

alecthomas avatar alecthomas commented on June 19, 2024 1

If it's already in Go then it's definitely fine to update.

I find that surprising. Why is compiled Go code slower/larger?

This is a bit surprising, but each lexer is a whole bunch of what is effectively dynamic code to the Go compiler, so it a) expands to a very large amount of machine code and b) takes a considerable amount of time to execute at init time. If the Go compiler were a lot smarter this would probably end up being static data sections, but it isn't.

I can't find the heredoc lexing. Can you point me to it? I don't see any << stuff in bash.xml.

Search for &lt;&lt;. It's a single regex with a backreference.

from chroma.

alecthomas avatar alecthomas commented on June 19, 2024

Look at how the bash lexer does it, it's the same concept.

I will not accept Go lexers unless there's a good reason, you should use XML. Chroma is used by a lot of people who aren't programmers, so XML is a better choice to foster contributions than Go. It's also much much more efficient in terms of binary size and startup time.

from chroma.

francislavoie avatar francislavoie commented on June 19, 2024

I will not accept Go lexers unless there's a good reason, you should use XML.

To be clear, I'm not making a new lexer, only updating an existing one. https://github.com/alecthomas/chroma/blob/master/lexers/caddyfile.go

It's also much much more efficient in terms of binary size and startup time.

I find that surprising. Why is compiled Go code slower/larger?

Look at how the bash lexer does it, it's the same concept.

I can't find the heredoc lexing. Can you point me to it? I don't see any << stuff in bash.xml.

Edit: oh, &lt;&lt;&lt; 🤦‍♂️

from chroma.

francislavoie avatar francislavoie commented on June 19, 2024

I see the \2. So it's a single regexp.

Is there a way to do this with state though (push + pop)? I have some other token types I want to handle within the heredoc.

For example, if something like {foo} appears within the heredoc, I want that to be a LiteralStringEscape.

from chroma.

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.