tim laqua dot com Thoughts and Code from Tim Laqua

7Mar/090

GeSHi Language file for MDX Syntax Highlighting

For years now, it's bothered me that there was no syntax highlighting for MDX in GeSHi - so I put a language file together for MDX. To use this file: download it, unzip it, and put the mdx.php file in to your GeSHi languages folder (for WordPress wp-syntax, this is themes/wp-syntax/geshi/geshi) - it's the folder with all the languagename.php files in it.

Let me know if it doesn't catch something or if you have suggestions for how to highlight keywords differently.

Download: geshi-mdx.zip

You can also copy and paste the following in to a new file and name it mdx.php - then place it in the appropriate folder:

<?php
/*************************************************************************************
 * mdx.php
 * -------
 * Author: Tim Laqua (t.laqua@gmail.com)
 * Copyright: (c) 2009 Tim Laqua (http://timlaqua.com/)
 * Release Version: <none>
 * Date Started: 2009/03/07
 *
 * MDX language file for GeSHi.
 *
 * CHANGES
 * -------
 * 2009/03/07 (1.0.0)
 *  -  First Release
 *
 *************************************************************************************
 *
 *     This file is part of GeSHi.
 *
 *   GeSHi is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   GeSHi is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with GeSHi; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 ************************************************************************************/
 
$language_data = array (
    'LANG_NAME' => 'MDX',
    'COMMENT_SINGLE' => array(1 =>'//', 2 => '--'),
    'COMMENT_MULTI' => array('/*' => '*/'),
    'CASE_KEYWORDS' => 0,
    'COMMENT_REGEXP' => array(
        3 => '/\[[a-z0-9 %]+\]/i'
        ),	
    'QUOTEMARKS' => array("'", '"', '`'),
    'ESCAPE_CHAR' => '\\',
    'KEYWORDS' => array(
        1 => array(
			'WHERE', 'WITH', 'COLUMNS', 'ROWS','FROM', 'NON', 'EMPTY', 'AS', 'ON',
			// Scripting Statements
			'CALCULATE','CASE','EXISTING','FREEZE','IF','SCOPE',
 
			// Data Definition Statements
			'ALTER', 'CUBE','CREATE', 'ACTION','CELL CALCULATION',
			'GLOBAL','MEMBER','SESSION',
			'SET','SUBCUBE', 'DROP', 'SUBCUBE','REFRESH',
 
			// Data Manipulation Statements
			'CALL', 'CLEAR', 'CALCULATIONS', 'DRILLTHROUGH', 'SELECT', 'UPDATE'
 
            ),
		2 => array(
			// Array Functions
			'SetToArray'
            ),
		3 => array(
 
			// Hierarchy Functions
			'Hierarchy', 'Dimension', 'Dimensions'
            ),
		4 => array(
 
			// Level Functions
			'Level', 'Levels'
            ),
		5 => array(
 
			// Logical Functions
			'IsAncestor', 'IsEmpty', 'IsGeneration', 'IsLeaf', 'IsSibling'
            ),
		6 => array(
 
			// Member Functions
			'Ancestor','ClosingPeriod','Cousin','CurrentMember','DataMember','DefaultMember',
			'FirstChild','FirstSibling','Item','Lag','LastChild',
			'LastSibling','Lead','LinkMember',/*'Members',*/ 'NextMember',
			'OpeningPeriod','ParallelPeriod','Parent','PrevMember','StrToMember',
			'UnknownMember','ValidMeasure'
            ),
		7 => array(
 
			// Numeric Functions
			'Aggregate','Avg','CalculationCurrentPass','CalculationPassValue','CoalesceEmpty',
			'Correlation','Count','Covariance','CovarianceN','DistinctCount',
			'IIf','LinRegIntercept','LinRegPoint','LinRegR2','LinRegSlope',
			'LookupCube','Max','Median','Min','Ordinal',
			'Predict','Rank','RollupChildren','Stddev','StddevP',
			'StrToValue','Sum','Value','Var','Variance',
			'VarianceP','VarP'		
            ),
		8 => array(
 
			// Set Functions
			'AllCalculatedMembers','AllMembers','Ancestors','Ascendants','Axis',
			'BottomCount','BottomPercent','BottomSum','Children','Crossjoin',
			'CurrentOrdinal','Descendants','Distinct','DrilldownLevel','DrilldownLevelBottom',
			'DrilldownLevelTop','DrilldownMember','DrilldownMemberBottom','DrilldownMemberTop','DrillupLevel',
			'DrillupMember','Except','Exists','Extract','Filter',
			'Generate','Head','Hierarchize','Intersect','LastPeriods',
			'Members','Mtd','NameToSet','NonEmptyCrossjoin','Order',
			'PeriodsToDate','Qtd','Siblings','StripCalculatedMembers','StrToSet',
			'Subset','Tail','ToggleDrillState','TopCount','TopPercent',
			'TopSum','Union','Unorder','VisualTotals','Wtd',
			'Ytd'
            ),
		9 => array(
 
			// String Functions
			'CalculationPassValue', 'CoalesceEmpty', 'Generate', 'IIf', 'LookupCube',
			'MemberToStr', 'Name', 'Properties', 'SetToStr', 'TupleToStr', 'UniqueName',
			'UserName'
            ),
		10 => array(
 
			// Subcube Functions
			'This', 'Leaves'
            ),
		11 => array(
 
			// Tuple Functions
			'Current', 'Item', 'Root', 'StrToTuple'
            ),
		12 => array(
 
			// Other Functions
			'Error'
			)
        ),
    'SYMBOLS' => array(
		// Operators
        '(', ')', '=', '{', '}', ',', '+', '-', '*', '/', '^', //, '.'
		':','<','<=','<>', '>', '>=', 'AND', 'IS', 'NOT', 'OR', 'XOR', '|', '::='
        ),
    'CASE_SENSITIVE' => array(
        GESHI_COMMENTS => false,
        1 => false,
		2 => false
        ),
    'STYLES' => array(
        'KEYWORDS' => array(
            1 => 'color: #0000FF; font-weight: bold;',
			2 => 'color: #00FFFF;',
			3 => 'color: #00CCCC;',
			4 => 'color: #0000CC;',
			5 => 'color: #FF00FF;',
			6 => 'color: #AF0000;',
			7 => 'color: #CC00FF;',
			8 => 'color: #0000FF;',
			9 => 'color: #FF00FF;',
			10 => 'color: #0000FF;',
			11 => 'color: #0000FF;',
			12 => 'color: #0000FF;'
            ),
        'COMMENTS' => array(
            1 => 'color: #808080; font-style: italic;',
            2 => 'color: #808080; font-style: italic;',
            3 => 'color: #333333;',
            'MULTI' => 'color: #808080; font-style: italic;'
            ),
        'ESCAPE_CHAR' => array(
            0 => 'color: #000099; font-weight: bold;'
            ),
        'BRACKETS' => array(
            0 => 'color: #003300; font-weight: bold;'
            ),
        'STRINGS' => array(
            0 => 'color: #ff0000;'
            ),
        'NUMBERS' => array(
            0 => 'color: #cc66cc;'
            ),
        'METHODS' => array(
            1 => 'color: #004000;',
            2 => 'color: #004000;'
            ),
		'SYMBOLS' => array(
            0 => 'color: #66cc66;'
            ),
        'SCRIPT' => array(
            ),
        'REGEXPS' => array(
            0 => 'color: #000088;'
            )
         ),
    'URLS' => array(
        1 => ''
        ),
    'OOLANG' => true,
    'OBJECT_SPLITTERS' => array('.'
        ),
    'REGEXPS' => array(
        ),
    'STRICT_MODE_APPLIES' => GESHI_MAYBE,
    'SCRIPT_DELIMITERS' => array(
        ),
    'HIGHLIGHT_STRICT_BLOCK' => array(
        )
);
 
?>
Comments (0) Trackbacks (1)

Leave a comment