parsica-php / parsica

Parsica - PHP Parser Combinators - The easiest way to build robust parsers.
https://parsica-php.github.io/
MIT License
405 stars 18 forks source link

Beginner question - extending expression parser #61

Open alex-barylski opened 2 years ago

alex-barylski commented 2 years ago

Curious, I am trying to extend your expression example, by allowing variable names with "." separators:

        $identifier = atLeastOne(alphaChar());
        $identifierDot = many($identifier->optional()->append(char('.')));

This isn't working, so I'm clearly not understanding how this library works. What am I missing? I'm stuck trying to think of the problem in terms of a regex solution.

How would I parse / match a variable with arbitrary number of '.' separators? And have that returned to the AST as a complete string, not further parsed.

Any help much appreciated :)