Advertisement
jachguate

Delphi Google prettify

Mar 15th, 2013
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Contributed by http://jachguate.wordpress.com
  2.  
  3. /**
  4.  * @fileoverview
  5.  * Registers a language handler for Delphi.
  6.  *
  7.  * To use, include prettify.js and this file in your HTML page.
  8.  * Then put your code in an HTML tag like
  9.  *      <pre class="prettyprint lang-delphi">(my Delphi code)</pre>
  10.  *
  11.  * @author http://jachguate.wordpress.com
  12.  */
  13.  
  14. PR.registerLangHandler(
  15.     PR.createSimpleLexer(
  16.         [ // shortcutStylePatterns
  17.           // 'single-line-string'
  18.           [PR.PR_STRING,        /^(?:\'(?:[^\'\r\n]|\\.)*(?:\'|$))/, null, '\''],
  19.           // Whitespace
  20.           [PR.PR_PLAIN,         /^\s+/, null, ' \r\n\t\xA0']
  21.         ],
  22.         [ // fallthroughStylePatterns
  23.           // A cStyleComments comment (* *) or {}
  24.           [PR.PR_COMMENT,       /^(?:\/\/[^\r\n]*)|\(\*[\s\S]*?(?:\*\)|$)|^\{[\s\S]*?(?:\}|$)/, null],
  25.           //updated to http://docwiki.embarcadero.com/RADStudio/XE3/en/Fundamental_Syntactic_Elements#Reserved_Words
  26.           //directives not included
  27.           [PR.PR_KEYWORD,       /^(?:AND|ARRAY|AS|ASM|BEGIN|CASE|CLASS|CONST|CONSTRUCTOR|DESTRUCTOR|DISPINTERFACE|DIV|DO|DOWNTO|ELSE|END|EXCEPT|EXPORTS|FILE|FINALIZATION|FINALLY|FOR|FUNCTION|GOTO|IF|IMPLEMENTATION|IN|INHERITED|INITIALIZATION|INLINE|INTERFACE|IS|LABEL|LIBRARY|MOD|NIL|NOT|OBJECT|OF|OR|PACKED|PROCEDURE|PROGRAM|PROPERTY|RAISE|RECORD|REPEAT|RESOURCESTRING|SET|SHL|SHR|STRING|THEN|THREADVAR|TO|TRY|TYPE|UNIT|UNTIL|USES|VAR|WHILE|WITH|XOR)\b/i, null],
  28.           [PR.PR_LITERAL,       /^(?:true|false|self|nil)/i, null],
  29.           [PR.PR_PLAIN,         /^[a-z][a-z0-9]*/i, null],
  30.           // Literals .0, 0, 0.0 0E13
  31.           [PR.PR_LITERAL,       /^(?:\$[a-f0-9]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?)/i,  null, '0123456789'],
  32.           [PR.PR_PUNCTUATION,   /^.[^\s\w\.$@\'\/]*/, null],
  33.         ]),
  34.     ['delphi']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement