diff options
author | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2012-12-28 17:21:48 +0100 |
---|---|---|
committer | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2012-12-28 17:21:48 +0100 |
commit | c2c423a7a42ae060947b9e014309ae48d63a8086 (patch) | |
tree | d981f9dd585376377be15cb16a359fa6cd3015e7 /Bin | |
parent | a722f62162f035e92f908b10b02592543d2caadb (diff) | |
download | Praspel-c2c423a7a42ae060947b9e014309ae48d63a8086.zip Praspel-c2c423a7a42ae060947b9e014309ae48d63a8086.tar.gz Praspel-c2c423a7a42ae060947b9e014309ae48d63a8086.tar.bz2 |
Add autocompleter on realistic domain names.
Diffstat (limited to 'Bin')
-rw-r--r-- | Bin/Shell.php | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/Bin/Shell.php b/Bin/Shell.php index cb39bf1..57cbbb3 100644 --- a/Bin/Shell.php +++ b/Bin/Shell.php @@ -71,7 +71,17 @@ from('Hoa') /** * \Hoa\Console\Cursor */ --> import('Console.Cursor'); +-> import('Console.Cursor') + +/** + * \Hoa\Console\Readline + */ +-> import('Console.Readline.~') + +/** + * \Hoa\Console\Readline\Autocompleter\Word + */ +-> import('Console.Readline.Autocompleter.Word'); } @@ -123,12 +133,27 @@ class Shell extends \Hoa\Console\Dispatcher\Kit { \Hoa\Realdom::setDefaultSampler(new \Hoa\Math\Sampler\Random()); - $compiler = \Hoa\Compiler\Llk::load( + $compiler = \Hoa\Compiler\Llk::load( new \Hoa\File\Read('hoa://Library/Praspel/Grammar.pp') ); $interpreter = new \Hoa\Praspel\Visitor\Interpreter(); $dump = new \Hoa\Praspel\Visitor\Compiler(); $interpreter->visit($compiler->parse('@requires;')); + $words = array(); + + from('Hoathis or Hoa') + -> foreachImport('Realdom.*', function ( $classname ) use ( &$words ) { + + $class = new \ReflectionClass($classname); + + if($class->isSubclassOf('\Hoa\Realdom')) + $words[] = $classname::NAME; + }); + + $readline = new \Hoa\Console\Readline(); + $readline->setAutocompleter( + new \Hoa\Console\Readline\Autocompleter\Word($words) + ); $handle = null; $expression = '.h'; @@ -224,7 +249,7 @@ class Shell extends \Hoa\Console\Dispatcher\Kit { echo "\n"; - } while('.quit' !== $expression = $this->readLine('> ')); + } while('.quit' !== $expression = $readline->readLine('> ')); return; } |