Beispiel #1
0
 protected function init()
 {
     /*
     start           -> value
     
     obj             -> obj_start        obj_content         obj_end
     obj_content     -> obj_pair         obj_morecontent                     | e
     obj_morecontent -> concat           obj_pair            obj_morecontent | e
     obj_pair        -> string           assignment          value
     
     arr             -> arr_start        arr_content         arr_end            
     arr_content     -> value            arr_morecontent                     | e
     arr_morecontent -> concat           value               arr_morecontent | e
     
     value           -> string | number | obj | arr | bool
     bool            -> true | false
     */
     $start = new Symbol("V_START");
     $obj = new Symbol("V_OBJ");
     $value = new Symbol("V_VALUE");
     $obj_content = new Symbol("V_OBJ_CONTENT");
     $obj_morecontent = new Symbol("V_OBJ_MORECONTENT");
     $obj_pair = new Symbol("V_PAIR");
     $arr = new Symbol("V_ARR");
     $arr_content = new Symbol("V_ARR_CONTENT");
     $arr_morecontent = new Symbol("V_ARR_MORECONTENT");
     $bool = new Symbol("V_BOOL");
     $start->consists(array($value));
     $obj->consists(array(new Terminal("V_OBJ_START"), $obj_content, new Terminal("V_OBJ_END")));
     $obj_content->consists(array($obj_pair, $obj_morecontent));
     $obj_content->consists(array(new Terminal("V_e")));
     $obj_morecontent->consists(array(new Terminal("V_CONCAT"), $obj_pair, $obj_morecontent));
     $obj_morecontent->consists(array(new Terminal("V_e")));
     $obj_pair->consists(array(new Terminal("V_STRING"), new Terminal("V_ASSIGNMENT"), $value));
     $arr->consists(array(new Terminal("V_ARR_START"), $arr_content, new Terminal("V_ARR_END")));
     $arr_content->consists(array($value, $arr_morecontent));
     $arr_content->consists(array(new Terminal("V_e")));
     $arr_morecontent->consists(array(new Terminal("V_CONCAT"), $value, $arr_morecontent));
     $arr_morecontent->consists(array(new Terminal("V_e")));
     $value->consists(array(new Terminal("V_STRING")));
     $value->consists(array(new Terminal("V_NUMBER")));
     $value->consists(array($bool));
     $value->consists(array($obj));
     $value->consists(array($arr));
     $bool->consists(array(new Terminal("V_TRUE")));
     $bool->consists(array(new Terminal("V_FALSE")));
     $this->registerSymbol($start);
     $this->registerSymbol($obj);
     $this->registerSymbol($obj_content);
     $this->registerSymbol($obj_morecontent);
     $this->registerSymbol($obj_pair);
     $this->registerSymbol($arr);
     $this->registerSymbol($arr_content);
     $this->registerSymbol($arr_morecontent);
     $this->registerSymbol($value);
     $this->registerSymbol($bool);
 }
Beispiel #2
0
 public function next()
 {
     $buffer = '';
     for ($this->position = 0; $this->position < count($this->input); $this->position++) {
         $char = $this->input[$this->position];
         $code = ord($char);
         if ($code <= 0x20) {
             // whitespace & control characters
             continue;
         } elseif ($code >= 0x30 && $code <= 0x39) {
             // digits
             $buffer .= $char;
             $next = $this->peek(function ($ord) {
                 return $ord >= 0x30 && $ord <= 0x39;
             });
             if ($next) {
                 // digit continued
                 continue;
             } else {
                 (yield ['symbol' => Symbol::INTEGER(), 'value' => (int) $buffer]);
                 $buffer = '';
             }
         } elseif ($code === 0x2a || $code === 0x2b || $code === 0x2d || $code === 0x2f) {
             // operators + - * /
             (yield ['symbol' => Symbol::OPERATOR(), 'value' => $char]);
         } elseif ($code === 0x28) {
             (yield ['symbol' => Symbol::LPAREN(), 'value' => $char]);
         } elseif ($code === 0x29) {
             (yield ['symbol' => Symbol::RPAREN(), 'value' => $char]);
         } else {
             throw new SyntaxException("Syntax error on position {$this->position}: unexpected token '{$char}'!");
         }
     }
 }
 $fswpm .= char2token($first);
 $fbswml .= '&lt;sign lane="' . char2lane($first) . '"&gt;<br>';
 for ($i = 0; $i < count($chars); $i++) {
     //first 3 are symbol
     $sbsw = $chars[$i];
     $i++;
     $sbsw .= $chars[$i];
     $i++;
     $sbsw .= $chars[$i];
     //next 2 are coordinates
     $i++;
     $sx = hex2num($chars[$i]);
     $i++;
     $sy = hex2num($chars[$i]);
     //center coordinates on symbol
     $sym = new Symbol($sbsw);
     $scx = round($sx + $sym->getWidth() / 2);
     $scy = round($sy + $sym->getHeight() / 2);
     //now to determine degrees
     //convoluted for easy...
     $sd = $scx < 0 ? round(rad2deg(atan2($scx, -$scy))) + 360 : round(rad2deg(atan2($scx, -$scy)));
     //      $sd = round(rad2deg(atan2(-$scy, -$scx)));
     //now to determine length
     $sl = round(sqrt(pow($scx, 2) + pow($scy, 2)));
     $fswcm .= bsw2utf($sbsw, 1) . $sx . ',' . $sy;
     if (count($chars) == 5) {
         $fswpm .= bsw2utf($sbsw, 1) . '0°0';
     } else {
         $fswpm .= bsw2utf($sbsw, 1) . $sd . '°' . $sl;
     }
     $fbswml .= '&nbsp;&nbsp;&lt;sym x="' . $sx . '" y="' . $sy . '"&gt;' . bsw2key($sbsw) . '&lt;/sym&gt;<br>';
Beispiel #4
0
function SCM_atom($s)
{
    $x = $s->car;
    if (!Object::is_cons($x)) {
        return Symbol::new_instance('#t');
    } else {
        return Symbol::new_instance('#f');
    }
}
Beispiel #5
0
 public function groupBy(Symbol $symbol)
 {
     $info = $symbol->annotate();
     return $info['name'] . $info['arguments'];
 }
Beispiel #6
0
 public function Compile($sexp)
 {
     //$this->Emit(new StringExpression("// " . Expression::Render($sexp)));
     if ($sexp instanceof Symbol) {
         $this->Emit(new ReturnCE(new StringExpression("@\$env->environment['" . addslashes($sexp->name) . "'];")));
         return;
     } elseif (!is_array($sexp)) {
         $this->Emit(new ReturnCE(new CompiledExpression($sexp)));
         return;
     }
     $lambda = $sexp[0];
     $args = array_slice($sexp, 1);
     if (is_array($lambda)) {
         $evald = $this->Compile($lambda);
         //echo Expression::Render($lambda) . " ~~> " . Expression::Render($evald) . "\n";
         $lambda = $evald;
     }
     if ($lambda instanceof Symbol && ($val = @$this->environment[$lambda->name]) !== NULL) {
         $lambda = $val;
     }
     $phpName = NULL;
     if ($lambda instanceof Symbol) {
         $phpName = ($in = @self::$_internalNames[$lambda->name]) === NULL ? str_replace('-', '_', $lambda->name) : $in;
     }
     if ($lambda instanceof Macro) {
         $list = NULL;
         foreach ($lambda->expressions as $e) {
             // macro-expansion-time
             $applied = $lambda->arguments === NULL ? $e : $this->Apply($e, $lambda->arguments, $args);
             //echo Expression::Render($e) . " =APPLY=> " . Expression::Render($applied) . "\n";
             $expanded = $this->Evaluate($applied);
             //echo Expression::Render($applied) . " =MACROEXPAND=> " . Expression::Render($expanded) . "\n";
         }
         return $this->Compile($expanded);
     }
     if ($lambda instanceof Symbol) {
         // special forms (non-evaluated parameters)
         $specialForm = "lizp_special_form_{$phpName}";
         if (function_exists($specialForm)) {
             $this->Emit(new ReturnCE(new FunctionCallCE($specialForm, array("env", new CompiledExpression($args)))));
             return;
         }
     }
     // We evaluate the parameters
     $paramNames = array();
     $params = array();
     $expandNext = FALSE;
     $rand = rand(1, 1000000);
     foreach ($args as $i => $v) {
         if ($v instanceof AtSign) {
             $expandNext = TRUE;
             continue;
         }
         $this->Compile($v);
         $this->Emit(new LoadCE("param_{$rand}_{$i}"));
         if ($expandNext && is_array($r)) {
             $params = array_merge($params, $r);
         } else {
             $params[] = "\$param_{$rand}_{$i}";
             //r;
             $paramNames[] = "param_{$rand}_{$i}";
             //r;
         }
         $expandNext = FALSE;
     }
     if ($lambda instanceof Lambda) {
         $r = NULL;
         foreach ($lambda->expressions as $e) {
             $args = array();
             foreach ($params as $i) {
                 if (is_array($i)) {
                     $i = array(Symbol::Make('quote'), $i);
                 }
                 $args[] = $i;
             }
             //$params = $args;
             $applied = $lambda->arguments === NULL ? $e : $this->Apply($e, $lambda->arguments, $params);
             //echo Expression::Render($e) . " -APPLY-> " . Expression::Render($applied) . "\n";
             // $r =
             $this->Compile($applied);
             //echo Expression::Render($applied) . " -EVAL-> " . Expression::Render($r) . "\n";
         }
         return;
         // $r
     }
     if ($lambda instanceof Symbol) {
         // internal functions / php functions
         $internalFn = "lizp_internal_fn_{$phpName}";
         if (($isInternal = function_exists($internalFn)) || function_exists($phpName)) {
             if ($isInternal) {
                 $this->Emit(new ReturnCE(new FunctionCallCE($internalFn, array("env", new StringExpression("array(" . implode(', ', $params) . ")")))));
                 return;
             }
             $this->Emit(new ReturnCE(new FunctionCallCE($phpName, $paramNames)));
             $this->Emit(new StringExpression('if (is_array($r) && count($r) == 0) $r = NULL;'));
             return;
         }
     }
     $this->Emit("/* Unable to evaluate Expression: " . Expression::Render($sexp) . " because function name evaluates to " . Expression::Render($lambda) . " */");
 }
Beispiel #7
0
/** @api */
function symbol($name)
{
    return Symbol::get($name);
}
Beispiel #8
0
function lizp_special_form_defmacro($env, $args)
{
    if (!@$args[0] instanceof Symbol || !(is_array(@$args[1]) || @$args[1] === NULL || @$args[1] === FALSE)) {
        throw new Exception("Syntax Error: (DEFMACRO <id> (<params>*) <expr>*)");
    }
    $lambda = new Macro();
    $lambda->arguments = empty($args[1]) ? NULL : $args[1];
    $lambda->expressions = array_slice($args, 2);
    $env->environment[$args[0]->name] = $lambda;
    return Symbol::Make($args[0]->name);
}
Beispiel #9
0
function lizp_internal_fn_map($env, $args)
{
    if (count($args) !== 2 || !($args[0] instanceof Lambda || $args[0] instanceof Symbol) || !is_array($args[1]) && $args[1] !== NULL) {
        throw new Exception("syntax: (MAP <lambda> <list>)");
    }
    $r = array();
    foreach ((array) $args[1] as $i => $v) {
        $r[] = $env->Evaluate(array($args[0], array(Symbol::Make('quote'), $v), array(Symbol::Make('quote'), $i)));
    }
    return empty($r) ? NULL : $r;
}
Beispiel #10
0
 /**
  * 要素解析
  */
 private static function parse_object(&$tokens)
 {
     $token = array_shift($tokens);
     if ($token == '(') {
         return self::parse_list($tokens);
     } elseif (is_numeric($token)) {
         return Number::new_instance($token);
     } elseif (preg_match('/^".*"$/', $token)) {
         return String::new_instance($token);
     } else {
         return Symbol::new_instance($token);
     }
 }
Beispiel #11
0
 public function get()
 {
     $statement = $database->select(RelatedStat::table())->select("SUM(?) AS total_wt, SUM(?) AS total_ct, COUNT(DISTINCT ?) AS runs, ?", $inc->wallTime, $inc->count, $inc->runId, $inc->childSymbolId, Symbol::columns()->name)->leftJoin('? ON ? = ?', Symbol::table(), Symbol::columns()->id, $inc->childSymbolId)->where('? = ?', $inc->parentSymbolId, $symbol->id)->groupBy($inc->childSymbolId)->order('total_wt DESC')->limit(50);
 }
Beispiel #12
0
 private function step(&$tokenStream, Symbol $symbol, &$parseTreeBranch)
 {
     $returnValue = false;
     $this->depth++;
     $alternatives = $symbol->getConsistence();
     $altChangedSth = false;
     //iterating over alternatives
     foreach ($alternatives as $alt) {
         //iterating over symbols and terminals an alternative consists of
         $alternativeMatched = true;
         $first = true;
         foreach ($alt as $parseElement) {
             if ($this->debug) {
                 $this->debugOutput(str_repeat("&nbsp;&nbsp;&nbsp;", $this->depth) . $this->depth . " " . $parseElement->getName() . " " . get_class($parseElement));
             }
             if (is_a($parseElement, "Terminal")) {
                 if ($parseElement->getName() == "V_e") {
                     //alternative consists of epsilon, so alternative has matched, because alternative and therefore symbol has fullfilled it's destination
                     $alternativeMatched = true;
                     break;
                 } else {
                     if (count($tokenStream) == 0) {
                         if ($first) {
                             //having no more tokens, i say this alternative failes.but it's the first token to check, so let's see if epsilon is produced in another alternative
                             $alternativeMatched = false;
                             break;
                         } else {
                             //uh, I'm in the middle of something? breaking baaaaad.
                             throw new ParserException("I'm through with the Input-Band, i was expecting: " . $parseElement->getName() . ", not good!");
                         }
                     }
                     //peek on tokenstream, $tokenStream[0] matches terminal->name?
                     if ($parseElement->getName() == $tokenStream[0]['symbol']) {
                         if ($this->debug) {
                             $this->debugOutput(str_repeat("&nbsp;&nbsp;&nbsp;", $this->depth) . "&nbsp;&nbsp;&nbsp;FOUND! | " . $this->listTokenString($tokenStream));
                         }
                         //shift it out
                         $parseTreeBranch[] = array_shift($tokenStream);
                     } else {
                         if ($this->debug) {
                             $this->debugOutput(str_repeat("&nbsp;&nbsp;&nbsp;", $this->depth) . "&nbsp;&nbsp;&nbsp;not found! | " . $this->listTokenString($tokenStream));
                         }
                         //hmm, is first?
                         if ($first) {
                             //let's try another alternative
                             $alternativeMatched = false;
                             break;
                         } else {
                             //i ran in this one...not return, breaking bad
                             throw new ParserException("Unexpected Token: " . $tokenStream[0]['symbol'] . ", Expected: " . $parseElement->getName());
                         }
                     }
                 }
             } else {
                 if (is_a($parseElement, "Symbol")) {
                     //get symbol and pass it to new cycle of functioni
                     $mySymbol = $this->symbols[$parseElement->getName()];
                     $tmpParseTreeBranch = array();
                     $retVal = $this->step($tokenStream, $mySymbol, $tmpParseTreeBranch);
                     //got a symbol match or not? if yes, break alternative and switch to next one
                     if (!$retVal) {
                         if ($first) {
                             $alternativeMatched = false;
                             break;
                         } else {
                             //i ran in this one...not return, breaking bad
                             throw new ParserException("Expected: " . $parseElement->getName());
                         }
                     } else {
                         $parseTreeBranch[$parseElement->getName()] = $tmpParseTreeBranch;
                     }
                 }
             }
             $first = false;
         }
         if ($alternativeMatched) {
             //current alternative produced a complete match. no need to check other alternatives
             $returnValue = true;
             break;
         }
     }
     $this->depth--;
     return $returnValue;
 }
 /**
  * @param Symbol $symbol
  */
 public function setSymbol(Symbol $symbol)
 {
     $this->symbols[$symbol->symbol()] = $symbol;
 }
Beispiel #14
0
 public function __construct($text = '', $style = self::STYLE_DEFAULT)
 {
     parent::__construct($text, $style, static::ELEMENT_LABEL);
 }
Beispiel #15
0
 /**
  * __toString() should return string if the control symbol is not space delimited
  */
 public function testToString_returnsString_ifNotSpaceDelimited()
 {
     $symbol = new Symbol();
     $symbol->setSymbol('+');
     $symbol->setIsSpaceDelimited(false);
     $expected = '\\+';
     $actual = (string) $symbol;
     $this->assertEquals($expected, $actual);
     return;
 }
 public function __construct($bsw)
 {
     $this->bsw = $bsw;
     $this->lane = substr($bsw, 0, 3);
     $this->cluster = bsw2cluster($bsw);
     $this->seq = bsw2seq($bsw);
     /**
      * Step 1: break apart
      */
     $keys = array();
     $xs = array();
     // x position
     $ys = array();
     // y position
     $ws = array();
     // width
     $hs = array();
     // height
     $bsw = bsw2cluster($bsw);
     $chars = str_split($bsw, 3);
     $cnt = count($chars);
     if ($bsw != "") {
         for ($i = 0; $i < $cnt; $i++) {
             $char = $chars[$i];
             $i++;
             $fill = char2fill($chars[$i]);
             $i++;
             $rot = char2rot($chars[$i]);
             $key = $char . $fill . $rot;
             $keys[] = $key;
             $i++;
             $xs[] = hex2num($chars[$i]);
             $i++;
             $ys[] = hex2num($chars[$i]);
             $sym = new Symbol($key);
             $ws[] = $sym->getWidth();
             $hs[] = $sym->getHeight();
         }
         /**
          * Step 2: determing width, height, and center
          */
         $xMin = $xs[0];
         $xMax = $xMin + 2;
         $yMin = $ys[0];
         $yMax = $yMin + 2;
         $cxMin = 0;
         $cxMax = 0;
         $cyMin = 0;
         $cyMax = 0;
         $centering = 0;
         // centering count
     } else {
         //make up values
         $xMin = 0;
         $xMax = $xMin + 2;
         $yMin = 0;
         $yMax = $yMin + 2;
         $cxMin = 0;
         $cxMax = 0;
         $cyMin = 0;
         $cyMax = 0;
         $centering = 0;
         // centering count
     }
     foreach ($keys as $num => $key) {
         $base = substr($key, 0, 3);
         $W = $ws[$num];
         $H = $hs[$num];
         $X = $xs[$num];
         $Y = $ys[$num];
         if ($xMin > $X) {
             $xMin = $X;
         }
         if ($yMin > $Y) {
             $yMin = $Y;
         }
         if ($xMax < $X + $W) {
             $xMax = $X + $W;
         }
         if ($yMax < $Y + $H) {
             $yMax = $Y + $H;
         }
         //check for centering
         if (isHead($base) or isTrunk($base)) {
             if ($centering == 0) {
                 $cxMin = $X;
                 $cxMax = $X + $W;
                 $cyMin = $Y;
                 $cyMax = $Y + $H;
             } else {
                 if ($cxMin > $X) {
                     $cxMin = $X;
                 }
                 if ($cyMin > $Y) {
                     $cyMin = $Y;
                 }
                 if ($cxMax < $X + $W) {
                     $cxMax = $X + $W;
                 }
                 if ($cyMax < $Y + $H) {
                     $cyMax = $Y + $H;
                 }
             }
             $centering++;
         }
     }
     $this->width = $xMax - $xMin;
     $this->height = $yMax - $yMin;
     if ($centering) {
         $this->centerX = ($cxMin + $cxMax) / 2 - $xMin;
         $this->centerY = ($cyMin + $cyMax) / 2 - $yMin;
     } else {
         $this->centerX = ($xMin + $xMax) / 2;
         $this->centerY = ($yMin + $yMax) / 2;
     }
     //rebuild bsw with zero relative x and y
     $this->bsw = $this->lane;
     foreach ($keys as $num => $key) {
         $this->bsw .= key2bsw($key);
         $X = $xs[$num];
         $this->bsw .= num2hex($X - $xMin);
         //$this->centerX);
         $Y = $ys[$num];
         $this->bsw .= num2hex($Y - $yMin);
         //$this->centerY);
     }
     //already zero based
     //    $this->centerX -= $xMin;
     //    $this->centerY -= $yMin;
     if ($this->seq) {
         $this->bsw .= '0fd' . $this->seq;
     }
 }
Beispiel #17
0
 public static function Parse(&$s, &$position = NULL)
 {
     if ($position === NULL) {
         $pos = $position = 0;
     } else {
         $pos = $position;
     }
     $len = strlen($s);
     $tokens = array();
     $didClose = FALSE;
     $qStack = array();
     $qSymbol = Symbol::Make('quote');
     $qqSymbol = Symbol::Make('quasiquote');
     $append = FALSE;
     for (;;) {
         // append any expressions to our list
         if ($append !== FALSE) {
             while (count($qStack) > 0) {
                 $qChar = array_pop($qStack);
                 switch ($qChar) {
                     case "'":
                         $append = array($qSymbol, $append);
                         break;
                     case "`":
                         $append = is_array($append) ? array_merge(array($qqSymbol), $append) : array($qSymbol, $append);
                         break;
                 }
             }
             $tokens[] = $append;
             $append = FALSE;
         }
         // end reached?
         if ($pos >= $len) {
             break;
         }
         // closing?
         if ($s[$pos] == ')') {
             if ($position === 0) {
                 throw new Exception("Missing (!");
             }
             $didClose = TRUE;
             $pos++;
             break;
         }
         // consume whitespace
         if (preg_match('/\\s/', $s[$pos])) {
             $pos++;
             continue;
         }
         // consume comments
         if ($s[$pos] == ';') {
             if (($nl = strpos($s, "\n", $pos)) !== FALSE) {
                 $pos = $nl;
             }
             $pos++;
             continue;
         }
         // open paren
         if ($s[$pos] == '(') {
             $p = $pos + 1;
             $append = self::Parse($s, $p);
             $pos = $p;
             continue;
         }
         // quote and quasiquote
         if ($s[$pos] == "`" || $s[$pos] == "'") {
             array_push($qStack, $s[$pos]);
             $pos++;
             continue;
         }
         // tilde
         if ($s[$pos] == "~") {
             $append = new Tilde();
             $pos++;
             continue;
         }
         // at sign
         if ($s[$pos] == "@") {
             $append = new AtSign();
             $pos++;
             continue;
         }
         // from here on i'll need an actual substring,
         // because the regexp functions do not allow matching
         // at a specified offset only. :(
         $sub = substr($s, $pos);
         // consume strings
         if (preg_match('/^"((?:\\\\"|[^"])*)"/s', $sub, $m)) {
             $append = stripslashes($m[1]);
             $pos += strlen($m[1]) + 2;
             continue;
         }
         // consume integers
         if (preg_match('/^([+-]?[0-9]+)/s', $sub, $m)) {
             $append = (int) $m[1];
             $pos += strlen($m[1]);
             continue;
         }
         // consume symbols
         if (preg_match('/^([^0-9][^\\s\\(\\)\\[\\]\\{\\}]*)/s', $sub, $m)) {
             $sname = $m[1];
             $supper = strtoupper($sname);
             if ($supper == 'T') {
                 $append = TRUE;
             } elseif ($supper == 'NIL') {
                 $append = NULL;
             } else {
                 $symbol = new Symbol();
                 $symbol->name = $sname;
                 $append = $symbol;
             }
             $pos += strlen($sname);
             continue;
         }
         throw new Exception("Unexpected character at pos {$pos}: {$s[$pos]}");
     }
     if ($position !== 0 && !$didClose) {
         throw new Exception("Missing )!");
     }
     $position = $pos;
     return empty($tokens) ? NULL : $tokens;
 }
Beispiel #18
0
 /**
  * Creates a control symbol token from stream
  *
  * @param  Jstewmc\Stream  $stream  a stream of characters (the current character
  *     must be the backslash character, and the next character should be non-
  *     alphanumeric)
  * @return  Jstewmc\Rtf\Token\Control\Symbol|false
  * @throws  InvalidArgumentException  if the current character in $stream is
  *     not a backslash
  * @throws  InvalidArgumentException  if the next character in $stream is not
  *     a non-alphanumeric character
  * @since  0.1.0
  * @since  0.2.0  renamed from createFromSource() to createFromStream; replaced
  *     argument $characters, an array of characters, with $stream, an instance 
  *     of Jstewmc\STream
  */
 public static function createFromStream(\Jstewmc\Stream\Stream $stream)
 {
     $symbol = false;
     // if a current character exists
     if ($stream->current()) {
         // if the current character is a backslash
         if ($stream->current() === '\\') {
             // if the next character exists
             if ($stream->next() !== false) {
                 // if the now current character is not alphanumeric
                 if (!ctype_alnum($stream->current())) {
                     // create a new control symbol
                     $symbol = new Symbol($stream->current());
                     // if the current character is an apostrophe, get the symbol's parameter
                     if ($stream->current() === '\'') {
                         $parameter = $stream->next() . $stream->next();
                         $symbol->setParameter($parameter);
                     }
                     // if the next character is a space, the control symbol is space-delimited,
                     //     and we should set the flag; otherwise, it's not, and we should rollback
                     //     to leave the pointer on the last character in the token (i.e., the
                     //     symbol)
                     //
                     if ($stream->next() === ' ') {
                         $symbol->setIsSpaceDelimited(true);
                     } else {
                         $symbol->setIsSpaceDelimited(false);
                         $stream->previous();
                     }
                 } else {
                     throw new \InvalidArgumentException(__METHOD__ . "() expects the next element in parameter one, characters, to " . "be a non-alphanumeric character");
                 }
             } else {
                 // hmm, do nothing?
             }
         } else {
             throw new \InvalidArgumentException(__METHOD__ . "() expects the current element in parameter one, characters, to " . "be the backslash character");
         }
     }
     return $symbol;
 }
Beispiel #19
0
function symbol($name)
{
    return Symbol::pull($name);
}