1/** 2 * @license 3 * Copyright (C) 2012 Jeffrey Arnold 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18/** 19 * @fileoverview 20 * Support for R documentation (Rd) files 21 * 22 * Minimal highlighting or Rd files, basically just highlighting 23 * macros. It does not try to identify verbatim or R-like regions of 24 * macros as that is too complicated for a lexer. Descriptions of the 25 * Rd format can be found 26 * http://cran.r-project.org/doc/manuals/R-exts.html and 27 * http://developer.r-project.org/parseRd.pdf. 28 * 29 * @author Jeffrey Arnold 30 */ 31PR['registerLangHandler']( 32 PR['createSimpleLexer']( 33 [ 34 // whitespace 35 [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 36 // all comments begin with '%' 37 [PR['PR_COMMENT'], /^%[^\r\n]*/, null, '%'] 38 ], 39 [// special macros with no args 40 [PR['PR_LITERAL'], /^\\(?:cr|l?dots|R|tab)\b/], 41 // macros 42 [PR['PR_KEYWORD'], /^\\[a-zA-Z@]+/], 43 // highlighted as macros, since technically they are 44 [PR['PR_KEYWORD'], /^#(?:ifn?def|endif)/ ], 45 // catch escaped brackets 46 [PR['PR_PLAIN'], /^\\[{}]/], 47 // punctuation 48 [PR['PR_PUNCTUATION'], /^[{}()\[\]]+/] 49 ]), 50 ['Rd', 'rd']); 51