UNPKG

es2-code-prettify

Version:
52 lines (49 loc) 3.04 kB
/** * @license * Copyright (C) 2010 benoit@ryder.fr * * 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. */ /** * @fileoverview * Registers a language handler for VHDL '93. * * Based on the lexical grammar and keywords at * http://www.iis.ee.ethz.ch/~zimmi/download/vhdl93_syntax.html * * @author benoit@ryder.fr */ registerLangHandler( createSimpleLexer( [ // Whitespace [PR_PLAIN, RegExpProxy( "^[\\t\\n\\r \\xA0]+" ), null, '\t\n\r \xA0'] ], [ // String, character or bit string [PR_STRING, RegExpProxy( "^(?:[BOX]?\"(?:[^\\\"]|\"\")*\"|'.')", 'i' )], // Comment, from two dashes until end of line. [PR_COMMENT, RegExpProxy( "^--[^\\r\\n]*" )], [PR_KEYWORD, RegExpProxy( "^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\\w-]|$)", 'i' ), null], // Type, predefined or standard [PR_TYPE, RegExpProxy( "^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\\w-]|$)", 'i' ), null], // Predefined attributes [PR_TYPE, RegExpProxy( "^\\'(?:ACTIVE|ASCENDING|BASE|DELAYED|DRIVING|DRIVING_VALUE|EVENT|HIGH|IMAGE|INSTANCE_NAME|LAST_ACTIVE|LAST_EVENT|LAST_VALUE|LEFT|LEFTOF|LENGTH|LOW|PATH_NAME|POS|PRED|QUIET|RANGE|REVERSE_RANGE|RIGHT|RIGHTOF|SIMPLE_NAME|STABLE|SUCC|TRANSACTION|VAL|VALUE)(?=[^\\w-]|$)", 'i' ), null], // Number, decimal or based literal [PR_LITERAL, RegExpProxy( "^\\d+(?:_\\d+)*(?:#[\\w\\\\.]+#(?:[+\\-]?\\d+(?:_\\d+)*)?|(?:\\.\\d+(?:_\\d+)*)?(?:E[+\\-]?\\d+(?:_\\d+)*)?)", 'i' )], // Identifier, basic or extended [PR_PLAIN, RegExpProxy( "^(?:[a-z]\\w*|\\\\[^\\\\]*\\\\)", 'i' )], // Punctuation [PR_PUNCTUATION, RegExpProxy( "^[^\\w\\t\\n\\r \\xA0\\\"\\'][^\\w\\t\\n\\r \\xA0\\-\\\"\\']*" )] ]), ['vhdl', 'vhd']);