hafriedlander / php-peg

PEG (parsing expression grammar) compiler for PHP
Other
191 stars 53 forks source link

psr-0 standard compliance #14

Closed ju1ius closed 12 years ago

ju1ius commented 12 years ago

For better integration with other libraries, using the psr-0 standard would be really usefull. It would also simplify development and testing a lot, by giving a more organized directory structure.

I'm currently working on improving the library, by adding new features, like arbitrary quantifiers in the pcre form ({2,4}, {4,}, etc...), case insensitive literals (globally or case by case), unicode modifiers, etc... But having all these classes sticked into one big file is really slowing down the process.

Would you like me to implement this ? Proposed directory layout:

+ hafriedlander
 \-+ Peg
   |-- Compiler.php
   |-+ Compiler
   | |-- Builder.php
   | |-- Flags.php
   | \-- Writer.php
   |-+ Exception
   | |-- GrammarException.php
   | \-- ParseException.php
   |-- Parser.php
   |-+ Parser
   | |-- ConservativePackrat.php
   | |-- FalseOnlyPackrat.php
   | |-- Packrat.php
   | \-- Regex.php
   |-- PendingRule.php
   |-- Rule.php
   |-- RuleSet.php
   |-- Token.php
   \-+ Token
     |-- Expressionable.php
     |-- ExpressionedRecurse.php
     |-- Literal.php
     |-- Option.php
     |-- Recurse.php
     |-- Regex.php
     |-- Sequence.php
     |-- Terminal.php
     \-- Whitespace.php
hafriedlander commented 12 years ago

Hmm. The naming on these classes would have to change. There's a patch floating around that adds namespacing, that I think I'd pull in before starting on this.

Generally a good idea though. I'd make a Peg\Parser\Parser.php though - the Parser class isn't any more special than Packrat, etc.

ju1ius commented 12 years ago

I'd make a Peg\Parser\Parser.php though - the Parser class isn't any more special than Packrat, etc.

Well PackratParser extends Parser so it seems more logical to have the directory structure reflect the class hierarchy (IMHO).

hafriedlander commented 12 years ago

This is now in master, all be it a slightly different organisation from that above. Thanks for the suggestion & the initial work.