| // Copyright (C) 2009 Onno Hommes. |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| package prettify.lang; |
| |
| import prettify.parser.Prettify; |
| |
| import java.util.ArrayList; |
| import java.util.Arrays; |
| import java.util.List; |
| import java.util.regex.Pattern; |
| |
| /** |
| * This is similar to the lang-appollo.js in JavaScript Prettify. |
| * <p/> |
| * All comments are adapted from the JavaScript Prettify. |
| * <p/> |
| * <p/> |
| * Registers a language handler for the AGC/AEA Assembly Language as described |
| * at http://virtualagc.googlecode.com |
| * <p/> |
| * This file could be used by goodle code to allow syntax highlight for |
| * Virtual AGC SVN repository or if you don't want to commonize |
| * the header for the agc/aea html assembly listing. |
| * |
| * @author ohommes@alumni.cmu.edu |
| */ |
| public class LangPascal extends Lang { |
| |
| public LangPascal() { |
| List<List<Object>> _shortcutStylePatterns = new ArrayList<List<Object>>(); |
| List<List<Object>> _fallthroughStylePatterns = new ArrayList<List<Object>>(); |
| |
| // 'single-line-string' |
| _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^(?:\\'(?:[^\\\\\\'\\r\\n]|\\\\.)*(?:\\'|$))"), null, "'"})); |
| // Whitespace |
| _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^\\s+"), null, " \r\n\t" + Character.toString((char) 0xA0)})); |
| |
| // A cStyleComments comment (* *) or {} |
| _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^\\(\\*[\\s\\S]*?(?:\\*\\)|$)|^\\{[\\s\\S]*?(?:\\}|$)"), null})); |
| _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:ABSOLUTE|AND|ARRAY|ASM|ASSEMBLER|BEGIN|CASE|CONST|CONSTRUCTOR|DESTRUCTOR|DIV|DO|DOWNTO|ELSE|END|EXTERNAL|FOR|FORWARD|FUNCTION|GOTO|IF|IMPLEMENTATION|IN|INLINE|INTERFACE|INTERRUPT|LABEL|MOD|NOT|OBJECT|OF|OR|PACKED|PROCEDURE|PROGRAM|RECORD|REPEAT|SET|SHL|SHR|THEN|TO|TYPE|UNIT|UNTIL|USES|VAR|VIRTUAL|WHILE|WITH|XOR)\\b", Pattern.CASE_INSENSITIVE), null})); |
| _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:true|false|self|nil)", Pattern.CASE_INSENSITIVE), null})); |
| _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[a-z][a-z0-9]*", Pattern.CASE_INSENSITIVE), null})); |
| // Literals .0, 0, 0.0 0E13 |
| _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:\\$[a-f0-9]+|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+\\-]?\\d+)?)", Pattern.CASE_INSENSITIVE), null, "0123456789"})); |
| _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^.[^\\s\\w\\.$@\\'\\/]*"), null})); |
| |
| setShortcutStylePatterns(_shortcutStylePatterns); |
| setFallthroughStylePatterns(_fallthroughStylePatterns); |
| } |
| |
| public static List<String> getFileExtensions() { |
| return Arrays.asList(new String[]{"pascal"}); |
| } |
| } |