Git Product home page Git Product logo

Comments (4)

edubart avatar edubart commented on June 26, 2024

Hey @mingodad from what I've seen and used, table captures in re is there documented and working as expected, so I don't see any issues here. Also this repository is a mirror, and I don't think Roberto answers here, if you want an answer back you should ask questions or report issues in Lua mailing list, there more people will also be able to test and help.

Also make sure to be test this in pure LPeg library before reporting as LPeg issue (no LPegLabel or LPegRex forks).

from lpeg.

mingodad avatar mingodad commented on June 26, 2024

I'm not saying that it's not implemented, I'm saying that it's not in the documentation grammar of re, see it ammended reproduced here :

p = [=[

pattern         <- exp !.
exp             <- S (grammar / alternative)

alternative     <- seq ('/' S seq)*
seq             <- prefix*
prefix          <- '&' S prefix / '!' S prefix / suffix
suffix          <- primary S (([+*?]
                            / '^' [+-]? num
                            / '->' S (string / '{}' / name)
                            / '=>' S name) S)*

primary         <- '(' exp ')' / string / class / defined
                 / '{:' (name ':')? exp ':}'
                 / '=' name
                 / '{}'
                 / '{~' exp '~}'
                 / '{|' exp '|}'   --!!! <<< missing table capture
                 / '{' exp '}'
                 / '.'
                 / name S !arrow
                 / '<' name '>'          -- old-style non terminals

grammar         <- definition+
definition      <- name S arrow exp

class           <- '[' '^'? item (!']' item)* ']'
item            <- defined / range / .
range           <- . '-' [^]]

S               <- (%s / '--' [^%nl]*)*   -- spaces and comments
name            <- [A-Za-z][A-Za-z0-9_]*
arrow           <- '<-'
num             <- [0-9]+
string          <- '"' [^"]* '"' / "'" [^']* "'"
defined         <- '%' name

]=]

print(re.match(p, p))   -- a self description must match itself

from lpeg.

edubart avatar edubart commented on June 26, 2024

Oh now I understand, indeed it is missing there. It an issue only in an example of the re documentation page then.

Still chances are higher of that being fixed if this gets reported in the Lua mailing list.

from lpeg.

mingodad avatar mingodad commented on June 26, 2024

The mentioned grammar also is missing an underscore for the first character of a name that is in code and is accepted:
In the documentation:

name            <- [A-Za-z][A-Za-z0-9_]*

In the code:

name            <- [A-Za-z_][A-Za-z0-9_]*

from lpeg.

Related Issues (1)

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.