From 0201cedb3a449510082a6fc084702d62391f2555 Mon Sep 17 00:00:00 2001 From: murphy Date: Mon, 19 Oct 2009 17:40:34 +0000 Subject: Updated PHP scanner: added a test, improved HTML/PHP detection, cleanup. --- lib/coderay/scanners/php.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'lib/coderay/scanners/php.rb') diff --git a/lib/coderay/scanners/php.rb b/lib/coderay/scanners/php.rb index 46f879e..8949eff 100644 --- a/lib/coderay/scanners/php.rb +++ b/lib/coderay/scanners/php.rb @@ -1,11 +1,3 @@ -class XRegexp - def |(other) - Regexp.union(self, other) - end - def +(other) - /#{self}#{other}/ - end -end module CodeRay module Scanners @@ -17,6 +9,8 @@ module Scanners register_for :php file_extension 'php' + KINDS_NOT_LOC = HTML::KINDS_NOT_LOC + def setup @html_scanner = CodeRay.scanner :html, :tokens => @tokens, :keep_tokens => true, :keep_state => true end @@ -188,6 +182,8 @@ module Scanners \?> !xi + HTML_INDICATOR = / ]/i + IDENTIFIER = /[a-z_\x80-\xFF][a-z0-9_\x80-\xFF]*/i VARIABLE = /\$#{IDENTIFIER}/ @@ -209,11 +205,13 @@ module Scanners states = [:initial] if match?(RE::PHP_START) || # starts with