GithubHelp home page GithubHelp logo

projectfluent / fluent-kotlin Goto Github PK

View Code? Open in Web Editor NEW
29.0 29.0 12.0 373 KB

Kotlin tooling implementation of ProjectFluent

Home Page: https://www.projectfluent.org/fluent-kotlin/

License: Other

Kotlin 76.39% FreeMarker 18.70% Java 1.13% Python 3.78%

fluent-kotlin's People

Contributors

mikkcz avatar pike avatar stasm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fluent-kotlin's Issues

Replace interfaces with sealed classes?

I think we could also experiment with sealed classes to express sum types, like so:

sealed class VariantKey {
    data class NumberKey(val key: NumberLiteral) : VariantKey()
    data class IdentifierKey(val key: Identifier) : VariantKey()
}

And then, in the parser code:

    fun getVariantKey(ps: FluentStream): VariantKey {
        val ch = ps.currentChar()

        if (ch == null) {
            throw ParseError("E0013")
        }

        val cc = ch.toInt()

        if ((cc >= 48 && cc <= 57) || cc == 45) { // 0-9, -
            return VariantKey.NumberKey(this.getNumber(ps))
        }

        return VariantKey.IdentifierKey(this.getIdentifier(ps))
    }

This is actually close to how enum can be defined in Rust, although (perhaps a bit surp not how we do it in fluent-rs, where a number literal in a variant key position is not the same struct as a number literal in an expression.

I like this approach because it helps document in the code what a variant key can be (rather than searching for all subclasses deriving from the VariantKey interface. OTOH, I realize there are consequences to whast the AST hierarchy looks like. Serializing to JSON, for instance, would be a bit more involved.

Originally posted by @stasm in https://github.com/Pike/fluent-kotlin/pull/2

Create AntiPatterns (working title) to marshall Patterns into something editor-friendly and back

When humans edit Fluent content, they're most often editing straight-forward patterns.

They shouldn't be bothered with leading/trailing whitespace, or escaping {.

Thus we should create a representation of Patterns which is editing-friendly.

Pontoon has code for similar purposes in https://github.com/mozilla/pontoon/tree/master/frontend/src/core/utils/fluent.

Working title is AntiPattern, as combining Patterns and AntiPatters is pure energy. This name should not stick.

Publish to Maven Central/Github Packages

Since a 0.1 release is already out there, having it available as a package in a Maven repo is needed for the community to start creating tooling for Project Fluent (IntelliJ integrations, Framework support, etc.) Instructions on how to do this with GitHub Actions are available here

Reference tests need to be more fine-grained

Right now, reference tests just check the top level item type.

This made a couple of bugs slip through the cracks, we need to dive deeper into the comparison logic against the reference json.

I got some thoughts, taking.

Document fluent.syntax

We should have some documentation for fluent-kotlin and fluent.syntax.

I've looked into generated documentation via dokka, and the output doesn't ring a bell for me. Side thing that I noticed is that all classes of a package are listed in one go, which makes me think that we should put the Visitor and childrenOf into its own package.

There's not a lot of customization we can do there, short of writing our own output generator. It's OK to look at for things like "public" vs "private", though. What needs a doc string, etc.

My suggestion is to not rely on generated docs for now, and to just write some RST in sphinx, like we do for python for much of it.

Add span support to Parser

Currently, the withSpans option doesn't do anything.

The methods we use in js and python land sadly don't work.

Add a Visitor pattern

The visitor pattern would be good to have.

We can probably build on what BaseNode.equals does.

Move Visitor into its own package

Seems that separate files inside a package are not considered to be "different" by at least dokka.

We should probably move visitor into its own package.

Port structure tests from typescript

So far, we only have the reference tests, but not the structure tests, which deal with error detection.

We should port those.

Related issues: #21 for the actual comparison to json. #16 could be related in terms of hidden bugs.

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.