public function postUpload($unique)
 {
     //disable php timeout and db query log
     DB::disableQueryLog();
     set_time_limit(0);
     $compare = Compare::where('unique', $unique)->first();
     if (!$compare || !Session::get('owner')) {
         return Redirect::to('compare/notfound');
     }
     $file = Input::file('csv');
     $data_set = array();
     $config = new LexerConfig();
     $config->setDelimiter("\t");
     $lexer = new Lexer($config);
     //setup the interpreter
     $interpreter = new Interpreter();
     $interpreter->unstrict();
     $interpreter->addObserver(function (array $row) use(&$data_set) {
         $data_set[] = $row[0];
     });
     //parse it!
     $lexer->parse($file, $interpreter);
     //loop through the data
     foreach ($data_set as $data_item) {
         $data = new Data();
         $data->compare_id = $unique;
         $data->owner_id = Session::get('owner');
         $data->hash = md5($data_item);
         $data->save();
     }
     return Redirect::back();
 }
Ejemplo n.º 2
0
/** Main program. */
function main()
{
    preload();
    $interpreter = new Interpreter();
    $interpreter->hello();
    $interpreter->bye();
}
Ejemplo n.º 3
0
 /**
  * @param array $arguments
  * @param Interpreter $core
  * @return mixed
  */
 public function calculationArguments(array $arguments, Interpreter $core)
 {
     foreach ($arguments as $key => $argument) {
         $arguments[$key] = $core->calculation($argument);
     }
     return $arguments;
 }
 public function run()
 {
     $Attendees = array();
     $lexer = new Lexer(new LexerConfig());
     $interpreter = new Interpreter();
     $interpreter->addObserver(function (array $row) use($Attendees) {
         $ItemOne = \Todo\Attendee::create(array('company' => $row[0], 'lastname' => $row[1], 'firstname' => $row[2], 'phone' => $row[3], 'email' => $row[4], 'paidinfull' => $row[5], 'balance' => $row[6], 'notes' => $row[7], 'seat_id' => $row[8]));
         $this->command->info("Added " . $row[1] . "as an attendee");
     });
     $fileName = $this->getDir() . '/Attendees.csv';
     $lexer->parse($fileName, $interpreter);
 }
Ejemplo n.º 5
0
 public function execute()
 {
     $iterator = new \DirectoryIterator($this->inputDir);
     $interpreter = new Interpreter();
     $operations = [];
     foreach ($iterator as $path) {
         if ($path->getExtension() === 'rst') {
             $operations[] = $interpreter->parse(file_get_contents($path->getRealPath()));
         }
     }
     $operations = array_values(array_filter($operations));
     usort($operations, function ($a, $b) {
         return strlen($a['path']) - strlen($b['path']);
     });
     $writer = new Writer($this->outputDir, $this->namespace, $operations);
     $writer->write();
 }
Ejemplo n.º 6
0
 /**
  * Construct an instance
  * @param array $options Optional array of name/value options
  * @see Options
  */
 public function __construct(array $options = NULL)
 {
     try {
         parent::__construct($options);
         $this->runnable = TRUE;
     } catch (OptionException $e) {
         $result = new RunResult();
         $result->setStatus(Result::FAIL);
         $result->addError($e);
         $this->doOutput($result);
     }
 }
Ejemplo n.º 7
0
 public static function main()
 {
     $obj = new Interpreter();
     $obj->execute("12345abcde");
 }
Ejemplo n.º 8
0
 public function testGetUserCommandToReturnQuitCommand()
 {
     $instance = new Interpreter();
     $this->assertInstanceOf('Pry\\Command\\Quit', $instance->getUserCommand(false));
 }
Ejemplo n.º 9
0
ini_set('display_errors', '1');
function __autoload($class_name)
{
    set_include_path('class');
    include_once $class_name . '.php';
}
writeln('BEGIN TESTING INTERPRETER PATTERN');
writeln('');
//load BookList for test data
$bookList = new BookList();
$inBook1 = new Book('PHP for Cats', 'Larry Truett');
$inBook2 = new Book('MySQL for Cats', 'Larry Truett');
$bookList->addBook($inBook1);
$bookList->addBook($inBook2);
$interpreter = new Interpreter($bookList);
writeln('test 1 - invalid request missing "book"');
writeln($interpreter->interpret('author 1'));
writeln('');
writeln('test 2 - valid book author request');
writeln($interpreter->interpret('book author 1'));
writeln('');
writeln('test 3 - valid book title request');
writeln($interpreter->interpret('book title 2'));
writeln('');
writeln('test 4 - valid book author title request');
writeln($interpreter->interpret('book author title 1'));
writeln('');
writeln('test 5 - invalid request with invalid book number');
writeln($interpreter->interpret('book title 3'));
writeln('');
Ejemplo n.º 10
0
            } elseif ($buffer == self::OP_JMP && $char != 'a') {
                $buffer = $char;
                $this->level += 1;
                $this->stack[$this->level] = [];
            } elseif ($buffer == self::OP_RET && $char != 'a') {
                $buffer = $char;
                $this->_loop();
                $this->level -= 1;
            } elseif ($instruction == self::OP_OUT) {
                $buffer = '';
                if ($this->level > 0) {
                    $this->_push($instruction);
                } else {
                    print chr($this->cells[$this->cellptr]);
                }
            } else {
                $buffer .= $char;
            }
        }
    }
}
if (count($argv) == 2) {
    try {
        $interpreter = new Interpreter();
        $interpreter->evaluate(file_get_contents($argv[1]));
    } catch (Exception $e) {
        print $e;
    }
} else {
    printf("\n    USAGE: php %s /path/to/file.koko\r\n", $argv[0]);
}
Ejemplo n.º 11
0
 /**
  * Construct an instance
  * @param array $options Optional array of name/value options
  * @see Options
  */
 public function __construct(array $options = NULL)
 {
     parent::__construct($options);
 }
Ejemplo n.º 12
0
    }
    function getAuthorAndTitle()
    {
        return $this->getTitle() . ' by ' . $this->getAuthor();
    }
}
define('BR', '<' . 'BR' . '>');
echo 'BEGIN TESTING INTERPRETER PATTERN' . BR;
echo BR;
//load BookList for test data
$bookList = new BookList();
$inBook1 = new Book('PHP for Cats', 'Larry Truett');
$inBook2 = new Book('MySQL for Cats', 'Larry Truett');
$bookList->addBook($inBook1);
$bookList->addBook($inBook2);
$interpreter = new Interpreter($bookList);
echo 'test 1 - invalid request missing "book"' . BR;
echo $interpreter->interpret('author 1');
echo BR . BR;
echo 'test 2 - valid book author request' . BR;
echo $interpreter->interpret('book author 1');
echo BR . BR;
echo 'test 3 - valid book title request' . BR;
echo $interpreter->interpret('book title 2');
echo BR . BR;
echo 'test 4 - valid book author title request' . BR;
echo $interpreter->interpret('book author title 1');
echo BR . BR;
echo 'test 5 - invalid request with invalid book number' . BR;
echo $interpreter->interpret('book title 3');
echo BR . BR;
Ejemplo n.º 13
0
                return "九";
        }
    }
}
class ExpressionCharater extends Expression
{
    function interpreter($str)
    {
        return strtoupper($str);
    }
}
class Interpreter
{
    function execute($string)
    {
        $expression = null;
        for ($i = 0; $i < strlen($string); $i++) {
            $temp = $string[$i];
            switch (true) {
                case is_numeric($temp):
                    $expression = new ExpressionNum();
                    break;
                default:
                    $expression = new ExpressionCharater();
            }
            echo $expression->interpreter($temp);
        }
    }
}
$obj = new Interpreter();
$obj->execute('12345abc');
Ejemplo n.º 14
0
Archivo: afl.php Proyecto: xk0der/AFL
 private static function processProgram(&$code)
 {
     $interpreter = new Interpreter();
     AFL::$output = $interpreter->run($code);
 }
Ejemplo n.º 15
0
<?php

namespace Zeyon\Zpp;

include_once __DIR__ . '/compiler.php';
include_once __DIR__ . '/interpreter.php';
header('Content-type: text/plain');
ini_set('max_execution_time', 5);
$parser = new Parser();
$interpreter = new Interpreter();
//print_r($parser -> parse(zCompiler::removeExcess('if($test){} else $x = [123, key: "hello"+12/5];')));
//exit;
$zcode_array = [['_T'], ['_L', 127], ['_AD', ['test1' => 'gestezt', 2 => null, 'test3' => null], [2, 'test3']], ['_EXTR']];
$zcode_loop = [['_RG', 'i'], ['_Z'], ['_ASGN_POP'], ['_VG', 'i'], ['_L', 100], ['_LT_SKP', 7], ['_LOOP', [['_RG', 'i'], ['_INC']], 3]];
$zcode_foreach = [['_RG', 'a'], ['_A', range(0, 100)], ['_ASGN_POP'], ['_VG', 'a'], ['_FOR', $zcode_loop]];
/*
Für alle artihmetischen/bitwise operatoren:
ADD_POP

FÜR alle vergleichsoperatoren:
EQ_SKP

- POP am Ende eines Codeblocks automatisch entfernen
- POP und SKP mit möglichen funktionen mergen
*/
$benchmark = microtime(true);
var_dump($interpreter->exec($zcode_foreach));
echo "\n", number_format(microtime(true) - $benchmark, 5), " - ", memory_get_peak_usage(true), "\n";
Ejemplo n.º 16
0
    function afterMicroStep($interpreter)
    {
        print "MyMonitor.afterMicroStep()\n";
    }
    function beforeTakingTransitions($interpreter, $transitions)
    {
        print "MyMonitor.beforeTakingTransitions()\n";
    }
}
$monitor = new MyMonitor();
// run interpreter in blocking mode
$interpreter = Interpreter::fromURL('https://raw.githubusercontent.com/tklab-tud/uscxml/master/test/uscxml/test-invoked.scxml');
$interpreter->addMonitor($monitor);
$interpreter->interpret();
// interleave interpreter execution with this thread
$interpreter = Interpreter::fromURL('https://raw.githubusercontent.com/tklab-tud/uscxml/master/test/uscxml/test-invoked.scxml');
$parentQueue = new ParentQueue();
$interpreter->setParentQueue($parentQueue);
while ($interpreter->step() > 0) {
    $event = $parentQueue->pop();
    print "Name: " . $event->getName() . "\n";
    print "Type: " . $event->getType() . "\n";
    print "Origin: " . $event->getOrigin() . "\n";
    print "OriginType: " . $event->getOriginType() . "\n";
    print "Content " . strlen($event->getContent()) . " bytes: \n'" . $event->getContent() . "'\n";
    $namelist = $event->getNameList();
    print "Namelist " . $namelist->size() . " elements: \n";
    $keys = $event->getNameListKeys();
    for ($i = 0; $i < $keys->size(); $i++) {
        print $keys->get($i) . "\t" . Data::toJSON($namelist->get($keys->get($i))) . "\n";
    }
Ejemplo n.º 17
0
 $sqlstmtGetFeeds = "SELECT `id`, `source`, `link` FROM `feeds`;";
 // Select all the news feeds
 if ($sqlrsltGetFeeds = $conn->query($sqlstmtGetFeeds)) {
     // Get SQL results
     // If successful return
     $sqlrsltGetFeeds->data_seek(0);
     // Pushes the result cursor to the beginning
     while ($feed = $sqlrsltGetFeeds->fetch_assoc()) {
         // Foreach feed found in the table,
         $domdocFeed = new DOMDocument();
         // Class to handle the feed
         libxml_use_internal_errors(true);
         // Turns off the screeching errors that aren't my fault
         if ($domdocFeed->load($feed['link'])) {
             // If successful loading the feed
             $intrprtrFeed = new Interpreter();
             // Create an interpreter
             $intrprtrFeed->feed = $feed['id'];
             $intrprtrFeed->source = $feed['source'];
             // Set the source
             $artclFeed = $intrprtrFeed->interpret($domdocFeed);
             // Interpret the article
             foreach ($artclFeed as $artclArticle) {
                 // Foreach article
                 if (!$artclArticle->exists($conn)) {
                     // If it's new
                     if ($artclArticle->publish($conn)) {
                         // Add to database
                         if (difference($referenceArticle, $artclArticle) > 0.2) {
                             if (push($secure, $artclArticle)) {
                                 // And push
                return "九";
        }
    }
}
class ExpressionCharater extends Expression
{
    public function interpreter($str)
    {
        return strtoupper($str);
    }
}
class Interpreter
{
    public function execute($string)
    {
        $expression = null;
        for ($i = 0; $i < strlen($string); $i++) {
            $temp = $string[$i];
            switch (true) {
                case is_numeric($temp):
                    $expression = new ExpressionNum();
                    break;
                default:
                    $expression = new ExpressionCharater();
            }
            echo $expression->interpreter($temp);
        }
    }
}
$obj = new Interpreter();
$obj->execute("12345abc");