Attachment 'javascript-1.0.0.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3 	MoinMoin - Javascript Core 1.5 Source Parser
   4 		(Modified from the original Java Source Parser)
   5 
   6 	@version: 1.0.0
   7 	@copyright: 2006 by Chun-Kwong Wong <chunkwong.wong@gmail.com>
   8 	@license: GNU GPL
   9 """
  10 
  11 from MoinMoin.util.ParserBase import ParserBase
  12 
  13 Dependencies = []
  14 
  15 class Parser(ParserBase):
  16 	parsername = "ColorizedJavascript"
  17 	extensions = ['.js']
  18 	Dependencies = []
  19 
  20 	def setupRules(self):
  21 		ParserBase.setupRules(self)
  22 
  23 		self.addRulePair("Comment", "/[*]", "[*]/")
  24 		self.addRule("Comment", "//.*$")
  25 		self.addRulePair("String", '"', r'$|[^\\](\\\\)*"')
  26 		self.addRule("Char", r"'\\.'|'[^\\]'")
  27 		self.addRule("Number", r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?")
  28 		self.addRule("ID", "[a-zA-Z_][0-9a-zA-Z_]*")
  29 		self.addRule("SPChar", r"[~!%^&*()+=|\[\]:;,.<>/?{}-]")
  30 
  31 		reserved_words = ['import', 'export',
  32 			'function', 'return', 'Arguments',
  33 			'if', 'else',
  34 			'new', 'delete', 'this', 'with',
  35 			'for', 'in', 'while', 'do',
  36 			'switch', 'case',
  37 			'default', 'break', 'continue',
  38 			'try', 'catch', 'throw',
  39 			'typeof', 'instanceof',
  40 			'eval', 'void',
  41 			'escape', 'unescape',
  42 			'isNaN', 'isFinite',
  43 			'decodeURI', 'decodeURIComponent',
  44 			'encodeURI', 'encodeURIComponent',
  45 			'parseFloat', 'parseInt']
  46 		special_words = ['const', 'var', 'Number', 'String']
  47 		constant_words = ['true', 'false',
  48 			'null', 'undefined',
  49 			'NaN', 'Infinity']
  50 
  51 		self.addReserved(reserved_words)
  52 		self.addConstant(constant_words)
  53 
  54 		self.addWords(special_words, 'special')

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2006-10-16 07:34:40, 1.5 KB) [[attachment:javascript-1.0.0.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.