Giter Site home page Giter Site logo

grammatista's People

Contributors

ddelbondio avatar dzuelke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

grammatista's Issues

The PHP parser should work on an AST instead of tokens internally

given the pattern t(declare(singular_message), declare(parameters), declare(domain)) and a code like t("msg", [], "master") the token matching breaks down completely since in the declare(parameters) part it looks for a single token and then fails to detect the domain.

We could solve this by changing the parsing to look for the next token in the pattern when at the declare() position (in this case the ,) while skipping all parts in brackets/parenthesis. But I think this would be rather brittle.

Additionally having a generic way to parse an AST would also allow us implementing other languages pretty easily. Python supports getting the AST from code, with Javascript we could use http://lisperator.net/uglifyjs/ast.

The PHP parser should skip parsed tokens on successful match

Assuming a pattern definition like

'->t(declare(singular_message))' => [...],
't(declare(singular_message))' => [...],

both pattern will match for a line like $this->t(...), since

if(($pattern = $this->compareToken($tokens, $i)) !== false) {
doesn't explicitly skip the matched pattern count, but will simply try parsing with the next token.

One Problem with skipping the amount of matched tokens could be code like $this->t($this->t(...)) which would then only find the outer t() call. That seems to me to be a rather edge case though, so we could add an option to a pattern which allows the old behaviour?

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.