Ejemplo n.º 1
0
function __lambda_15($tokens)
{
    return preg_pattern(metascanner::make_regex($tokens[0], $tokens[1]), $tokens[2], $tokens[3], $tokens[4]);
}
Ejemplo n.º 2
0
 function __construct()
 {
     parent::__construct(0);
     $ocb = mk_action('$context++; $state="code";');
     $ccb = mk_action('$context--; if ($context <= 0) $state = "rule";');
     $m1 = mk_action('$text = substr($text,1);');
     $m11 = mk_action('$text = substr($text,1,strlen($text)-2);');
     $go_rule = mk_action("\$state = 'rule';");
     $go_regex = mk_action("\$state = 'regex';");
     $test_reserved_word = mk_action("if (\$text=='ignore') \$type='ignore';");
     $nl = preg_pattern('([\\n\\r]+)', 'newline', 1, $go_regex);
     $cb = preg_pattern('(})', 'closebrace', 0, $go_rule);
     $ws = preg_pattern('(\\s+)', 'whitespace', 1, '');
     $cm = preg_pattern('(#[^\\n\\r]*)', 'comment', 1, '');
     $id = preg_pattern('(\\w+)', 'identifier', 0, $test_reserved_word);
     $dir = preg_pattern('(%(?:\\w+))', 'directive', 0, $m1);
     $div = preg_pattern('(%%)', 'divider', 0, $go_regex);
     $scope_tag = preg_pattern('(\\<(?:\\w+)>)', 'scope_tag', 0, $m11);
     $ob = preg_pattern('(\\{)', 'openbrace', 0, '');
     $regex = preg_pattern('(\\S+)', 'regex', 0, $go_rule);
     $modifier = preg_pattern('(/(?:[misxU]+))', 'modifier', 0, $m1);
     $openbrace_rule = preg_pattern('({)', 'openbrace', 0, $ocb);
     $this->add_state('code', array(preg_pattern('(\'(?:\\.|[^\'])*\')', 'sstring', 0, ''), preg_pattern('("(?:\\.|[^"])*")', 'dstring', 0, ''), preg_pattern('((?m)(?:#|//).*?$)', 'linecomment', 0, ''), preg_pattern('(/\\*.*?\\*/)', 'blockcomment', 0, ''), $openbrace_rule, preg_pattern('(})', 'closebrace', 0, $ccb), preg_pattern('([^\'"#/}{]+|.)', 'php', 0, '')));
     $this->add_state('INITIAL', array($dir, $div, $ws, $cm, $id));
     $this->add_state('regex', array($nl, $cb, $ws, $cm, $id, $scope_tag, $ob, $regex));
     $this->add_state('rule', array($nl, $cb, $ws, $cm, $id, $openbrace_rule, $modifier));
 }