| OLD | NEW |
| (Empty) |
| 1 // Copyright (C) 2009 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 | |
| 15 | |
| 16 | |
| 17 /** | |
| 18 * @fileoverview | |
| 19 * Registers a language handler for various flavors of basic. | |
| 20 * | |
| 21 * | |
| 22 * To use, include prettify.js and this file in your HTML page. | |
| 23 * Then put your code in an HTML tag like | |
| 24 * <pre class="prettyprint lang-vb"></pre> | |
| 25 * | |
| 26 * | |
| 27 * http://msdn.microsoft.com/en-us/library/aa711638(VS.71).aspx defines the | |
| 28 * visual basic grammar lexical grammar. | |
| 29 * | |
| 30 * @author mikesamuel@gmail.com | |
| 31 */ | |
| 32 | |
| 33 PR['registerLangHandler']( | |
| 34 PR['createSimpleLexer']( | |
| 35 [ | |
| 36 // Whitespace | |
| 37 [PR['PR_PLAIN'], /^[\t\n\r \xA0\u2028\u2029]+/, null, '\t\n\r \xA
0\u2028\u2029'], | |
| 38 // A double quoted string with quotes escaped by doubling them. | |
| 39 // A single character can be suffixed with C. | |
| 40 [PR['PR_STRING'], /^(?:[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u2
01C\u201D]{2})(?:[\"\u201C\u201D]c|$)|[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u
201C\u201D]{2})*(?:[\"\u201C\u201D]|$))/i, null, | |
| 41 '"\u201C\u201D'], | |
| 42 // A comment starts with a single quote and runs until the end of the | |
| 43 // line. | |
| 44 // VB6 apparently allows _ as an escape sequence for newlines though | |
| 45 // this is not a documented feature of VB.net. | |
| 46 // http://meta.stackoverflow.com/q/121497/137403 | |
| 47 [PR['PR_COMMENT'], /^[\'\u2018\u2019](?:_(?:\r\n?|[^\r]?)|[^\r\n_\u
2028\u2029])*/, null, '\'\u2018\u2019'] | |
| 48 ], | |
| 49 [ | |
| 50 [PR['PR_KEYWORD'], /^(?:AddHandler|AddressOf|Alias|And|AndAlso|Ansi|As|
Assembly|Auto|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|C
Dbl|CDec|Char|CInt|Class|CLng|CObj|Const|CShort|CSng|CStr|CType|Date|Decimal|Dec
lare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else|ElseIf|End|EndIf|Enum|E
rase|Error|Event|Exit|Finally|For|Friend|Function|Get|GetType|GoSub|GoTo|Handles
|If|Implements|Imports|In|Inherits|Integer|Interface|Is|Let|Lib|Like|Long|Loop|M
e|Mod|Module|MustInherit|MustOverride|MyBase|MyClass|Namespace|New|Next|Not|NotI
nheritable|NotOverridable|Object|On|Option|Optional|Or|OrElse|Overloads|Overrida
ble|Overrides|ParamArray|Preserve|Private|Property|Protected|Public|RaiseEvent|R
eadOnly|ReDim|RemoveHandler|Resume|Return|Select|Set|Shadows|Shared|Short|Single
|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TypeOf|Unicode
|Until|Variant|Wend|When|While|With|WithEvents|WriteOnly|Xor|EndIf|GoSub|Let|Var
iant|Wend)\b/i, null], | |
| 51 // A second comment form | |
| 52 [PR['PR_COMMENT'], /^REM\b[^\r\n\u2028\u2029]*/i], | |
| 53 // A boolean, numeric, or date literal. | |
| 54 [PR['PR_LITERAL'], | |
| 55 /^(?:True\b|False\b|Nothing\b|\d+(?:E[+\-]?\d+[FRD]?|[FRDSIL])?|(?:&H[
0-9A-F]+|&O[0-7]+)[SIL]?|\d*\.\d+(?:E[+\-]?\d+)?[FRD]?|#\s+(?:\d+[\-\/]\d+[\-\/]
\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)?|\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)\s+#)
/i], | |
| 56 // An identifier. Keywords can be turned into identifers | |
| 57 // with square brackets, and there may be optional type | |
| 58 // characters after a normal identifier in square brackets. | |
| 59 [PR['PR_PLAIN'], /^(?:(?:[a-z]|_\w)\w*(?:\[[%&@!#]+\])?|\[(?:[a-z]|_\w)
\w*\])/i], | |
| 60 // A run of punctuation | |
| 61 [PR['PR_PUNCTUATION'], | |
| 62 /^[^\w\t\n\r \"\'\[\]\xA0\u2018\u2019\u201C\u201D\u2028\u2029]+/], | |
| 63 // Square brackets | |
| 64 [PR['PR_PUNCTUATION'], /^(?:\[|\])/] | |
| 65 ]), | |
| 66 ['vb', 'vbs']); | |
| OLD | NEW |