1/** 2 * @license 3 * Copyright (C) 2013 Peter Kofler 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// Contributed by peter dot kofler at code minus cop dot org 19 20/** 21 * @fileoverview 22 * Registers a language handler for Basic. 23 * 24 * To use, include prettify.js and this file in your HTML page. 25 * Then put your code in an HTML tag like 26 * <pre class="prettyprint lang-basic">(my BASIC code)</pre> 27 * 28 * @author peter dot kofler at code minus cop dot org 29 */ 30 31PR.registerLangHandler( 32 PR.createSimpleLexer( 33 [ // shortcutStylePatterns 34 // "single-line-string" 35 [PR.PR_STRING, /^(?:"(?:[^\\"\r\n]|\\.)*(?:"|$))/, null, '"'], 36 // Whitespace 37 [PR.PR_PLAIN, /^\s+/, null, ' \r\n\t\xA0'] 38 ], 39 [ // fallthroughStylePatterns 40 // A line comment that starts with REM 41 [PR.PR_COMMENT, /^REM[^\r\n]*/, null], 42 [PR.PR_KEYWORD, /^\b(?:AND|CLOSE|CLR|CMD|CONT|DATA|DEF ?FN|DIM|END|FOR|GET|GOSUB|GOTO|IF|INPUT|LET|LIST|LOAD|NEW|NEXT|NOT|ON|OPEN|OR|POKE|PRINT|READ|RESTORE|RETURN|RUN|SAVE|STEP|STOP|SYS|THEN|TO|VERIFY|WAIT)\b/, null], 43 [PR.PR_PLAIN, /^[A-Z][A-Z0-9]?(?:\$|%)?/i, null], 44 // Literals .0, 0, 0.0 0E13 45 [PR.PR_LITERAL, /^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?/i, null, '0123456789'], 46 [PR.PR_PUNCTUATION, /^.[^\s\w\.$%"]*/, null] 47 // [PR.PR_PUNCTUATION, /^[-,:;!<>=\+^\/\*]+/] 48 ]), 49 ['basic','cbm']); 50