Deprecated: Assigning the return value of new by reference is deprecated in /var/www/virtual/geshi.org/htdocs/wiki/inc/parser/xhtml.php on line 943
Table of Contents

Continuing Language File Creation

With that little aside out of the way, now we can continue defining the root context for the test language.

addKeywordGroup

You have already seen an example of this method, so here we will use it again to add support for highlighting types:

<?php
    $context->addKeywordGroup(array(
        'bool', 'boolean', 'float',  'int', 'integer', 'string', 'object'
    ), 'type', true, 'http://php.net/{FNAME}');
?>

There’s just one type missing - “double” - but that does not have documentation at php.net/double 1). I will leave it as an exercise for you to add another keyword group that handles that case.

You may also want to add a keyword group for the macros like __FILE__. They are case sensitive.

Other groups you could add include groups for constants like E_ERROR and for functions like strpos. Both groups are rather large and I have omitted them here. In the actual PHP files the keyword groups are split out to each dialect of PHP (php, php4 and php5) so that PHP4 does not highlight functions that it does not have.

addSymbolGroup

todo...

1) strange but true, see for yourself: http://php.net/double. You’d think it could be redirected to float, just like the keyword is an alias for float but evidently not.
 
lang/dev/tutorial/6.txt · Last modified: 2011/09/01 13:03
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki