47 const PATT_REAL =
'/^[0-9]*\.[0-9]+|^[0-9]+\.[0-9]*/';
68 $this->parser = new \Erebot\Styling\Parser($vars);
80 return $this->parser->getResult();
94 while ($this->position < $this->length) {
96 $subject = substr($this->formula, $this->position);
99 if (isset($operators[$c])) {
100 $this->parser->doParse($operators[$c], $c);
106 if (preg_match(self::PATT_REAL, $subject, $matches)) {
107 $this->position += strlen($matches[0]);
108 $this->parser->doParse(
116 if (preg_match(self::PATT_INTEGER, $subject, $matches)) {
117 $this->position += strlen($matches[0]);
118 $this->parser->doParse(
126 if (strpos(
" \t", $c) !==
false) {
132 if (preg_match(self::PATT_VAR_NAME, $subject, $matches)) {
133 $this->position += strlen($matches[0]);
134 $this->parser->doParse(
142 $this->parser->doParse(
149 $this->parser->doParse(0, 0);
$length
Length of the formula.
Provides styling (formatting) features.
__construct($formula, array $vars)
const PATT_INTEGER
Allow stuff such as "1234".
A lexer (tokenizer) for variables used in styling templates.
$parser
Parser for the formula.
const PATT_VAR_NAME
Pattern for variable names.
const PATT_REAL
Allow stuff such as "1.23", "1." or ".23".
$position
Current position in the formula.
$formula
Formula to be tokenized.
tokenize()
This method does the actual work.