Coder Social home page Coder Social logo

Comments (5)

josevalim avatar josevalim commented on May 18, 2024

Good work, to me the yecc-based is much cleaner!

A couple notes on the .yrl one:

  1. The parser should stay in the .src directory indeed with the generated .erl being .gitignored
  2. You can match on the error information here to generate proper syntax errors (with line and what not)
  3. If you want, you can generate a map inside .yrl (instead of the translation tuple) and in the Elixir side of things convert them to a struct by doing Map.put(map, :__struct__, Translation).

from gettext.

ericmj avatar ericmj commented on May 18, 2024

I agree that yecc is cleaner but one of the advantages of the elixir version is that anyone can understand and contribute to it because you don't have to learn yet another parser language.

from gettext.

whatyouhide avatar whatyouhide commented on May 18, 2024

@ericmj that was the main reason I wrote the Elixir version too. It's also true that yecc has a very simple grammar and is very easy to understand (you have to know a little bit about CF grammars maybe, but it's nothing complicated).

I think the yecc version is cleaner but also "safer" in the sense that it's less prone to cause subtle bugs since the grammar definition is very concise and straightforward. If that means giving up some possible contributors, maybe it's worth it.

Keep also in mind that the current versions of both parsers only handle msgid/msgstr couples with no pluralisation nor anything else; this may be the first reason why the Elixir code is so simple. I'm confident that when the grammar becomes a little bit more complicated, yecc's clarity will be even more valuable.

from gettext.

josevalim avatar josevalim commented on May 18, 2024

@ericmj plus the grammar will be simpler to the point it will be easier to contribute to a grammar syntax you don't know than a complex hand-written grammar in Elixir. :)

from gettext.

whatyouhide avatar whatyouhide commented on May 18, 2024

I'm closing this since I merged #3, introducing a .po parser generated using yecc. This resulted in a very straightforward grammar and I also managed to move some tedious logic directly to the yecc parser (e.g., concatenation of a series of string tokens), so yay!

from gettext.

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.