hoaproject / Compiler

The Hoa\Compiler library.
https://hoa-project.net/
453 stars 47 forks source link

Show all possible Compiler paths. #22

Closed flip111 closed 10 years ago

flip111 commented 10 years ago

This Pull Request adds functions to support the language designer, by showing all paths possible from the language definition. Please see the example given or view the unit tests for more examples. Design documentation is only available in english and can be found in the Internal folder.

One example (given the formatting function as used in the unit tests)

<?php
$i = 0;
foreach ($paths as $path) {
    $output[] = ++$i . ': ' .  implode(' > ', $path) .  PHP_EOL;
}

Input:

%skip space \s
%token hello Hello
%token world world!
%token goodbye Goodbye

#sentence:
    greeting() ::world::

#greeting:
    ::hello:: | ::goodbye::

Output:

1: Hello > world!
2: Goodbye > world!
flip111 commented 10 years ago

Some problems have been found and i was stupid to commit on the master branch. I opened a new branch for this PR here https://github.com/flip111/Compiler/tree/patch-1 But i don't know how to change the PR to use a different branch.

CircleCode commented 10 years ago

Github PR doesn't allow to change the branch. So maybe the simplest is to create a new branch (call it with an explicit name, like for example compiler-show-paths) and open a new PR from this new branch. then reference this issue from the new PR, and close this issue so that the only remaining is the new one.

I hope people will wait until the new PR is open to make comments so that they are all in the same place.

Hywan commented 10 years ago

Is the new PR opened?

flip111 commented 10 years ago

new PR is here https://github.com/hoaproject/Compiler/pull/23