| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 // Copyright (C) 2012 Jeffrey B. Arnold |  | 
| 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  * @fileoverview |  | 
| 18  * Registers a language handler for S, S-plus, and R source code. |  | 
| 19  * |  | 
| 20  * |  | 
| 21  * To use, include prettify.js and this file in your HTML page. |  | 
| 22  * Then put your code in an HTML tag like |  | 
| 23  *      <pre class="prettyprint lang-r"> code </pre> |  | 
| 24  * |  | 
| 25  * Language definition from |  | 
| 26  * http://cran.r-project.org/doc/manuals/R-lang.html. |  | 
| 27  * Many of the regexes are shared  with the pygments SLexer, |  | 
| 28  * http://pygments.org/. |  | 
| 29  * |  | 
| 30  * Original: https://raw.github.com/jrnold/prettify-lang-r-bugs/master/lang-r.js |  | 
| 31  * |  | 
| 32  * @author jeffrey.arnold@gmail.com |  | 
| 33  */ |  | 
| 34 PR['registerLangHandler']( |  | 
| 35     PR['createSimpleLexer']( |  | 
| 36         [ |  | 
| 37             [PR['PR_PLAIN'],       /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], |  | 
| 38             [PR['PR_STRING'],      /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"'
    ], |  | 
| 39             [PR['PR_STRING'],      /^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/, null, "'"
    ] |  | 
| 40         ], |  | 
| 41         [ |  | 
| 42             [PR['PR_COMMENT'],     /^#.*/], |  | 
| 43             [PR['PR_KEYWORD'],     /^(?:if|else|for|while|repeat|in|next|break|r
    eturn|switch|function)(?![A-Za-z0-9_.])/], |  | 
| 44             // hex numbes |  | 
| 45             [PR['PR_LITERAL'], /^0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/], |  | 
| 46             // Decimal numbers |  | 
| 47             [PR['PR_LITERAL'], /^[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9
    ]+)?[Li]?/], |  | 
| 48             // builtin symbols |  | 
| 49             [PR['PR_LITERAL'], /^(?:NULL|NA(?:_(?:integer|real|complex|character
    )_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|[0-9]+))(?![A-Za-z0-9_.])/], |  | 
| 50             // assignment, operators, and parens, etc. |  | 
| 51             [PR['PR_PUNCTUATION'], /^(?:<<?-|->>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|\*
    |\+|\^|\/|!|%.*?%|=|~|\$|@|:{1,3}|[\[\](){};,?])/], |  | 
| 52             // valid variable names |  | 
| 53             [PR['PR_PLAIN'], /^(?:[A-Za-z]+[A-Za-z0-9_.]*|\.[a-zA-Z_][0-9a-zA-Z\
    ._]*)(?![A-Za-z0-9_.])/], |  | 
| 54             // string backtick |  | 
| 55             [PR['PR_STRING'], /^`.+`/] |  | 
| 56         ]), |  | 
| 57     ['r', 's', 'R', 'S', 'Splus']); |  | 
| OLD | NEW | 
|---|