PHP parser
(Modified Johannes Hoerburger's Perl parser)
# -*- coding: iso-8859-1 -*- """ MoinMoin - PHP Source Parser @copyright: 2006 by Johannes Hoerburger <jh@underground8.com> @copyright: 09.2006 by Eduard Baun <edy@edy-b.de> @license: GNU GPL. (Modified Johannes Hoerburger's Perl parser) """ from MoinMoin.util.ParserBase import ParserBase Dependencies = [] class Parser(ParserBase): parsername = "ColorizedPhp" extensions = ['.php','.phps'] Dependencies = [] def setupRules(self): ParserBase.setupRules(self) self.addRule("Comment","#.*$") self.addRule("Comment","//.*$") self.addRulePair("Comment","/[*]","[*]/") self.addRulePair("String",r"(?<!\\)\"",r"(?<!\\)\"") self.addRulePair("String",r"(?<!\\)\'",r"(?<!\\)\'") self.addRule("Char",r"'\\.'|'[^\\]'") self.addRule("Number",r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?") self.addRule("ID","[a-zA-Z_][0-9a-zA-Z_]*") self.addRule("SPChar",r"[~!%^&*()+=|\[\]:;,.<>/?{}-]") reserved_words = ['and','or','xor','__FILE__','exception','__LINE__','array','as','break','','case','class','const','continue','declare','default','die','do','echo','else','elseif','empty','enddeclare','endfor','endforeach','endif','endswitch','endwhile','eval','exit','extends','for','foreach','function','global','if','include','include_once','isset','list','new','print','require','require_once','return','static','switch','unset','use','var ','while','__FUNCTION__','__CLASS__','__METHOD__','final','php_user_filter','interface','implements','extends','public','private','protected','abstract','clone','try','catch','throw','cfunction','old_function'] self.addReserved(reserved_words) constant_words = ['true','false','null'] self.addConstant(constant_words)