Skip to content

Instantly share code, notes, and snippets.

@andyli
Created July 13, 2012 20:13
Show Gist options
  • Select an option

  • Save andyli/3107135 to your computer and use it in GitHub Desktop.

Select an option

Save andyli/3107135 to your computer and use it in GitHub Desktop.
Add haxe syntax to GeSHi
<?php
/*************************************************************************************
* haxe.php
* --------
* Author: Andy Li (andy@onthewings.net)
* John Liao (colorhook@gmail.com)
* Copyright: (c) 2012 onthewings (http://www.onthewings.net/)
* 2010 colorhook (http://colorhook.com/)
* Release Version: 1.1.0.0
* Date Started: 2010/10/05
*
* Haxe language file for GeSHi.
* Haxe version: 2.10
*************************************************************************************
*
* 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' => 'Haxe',
'COMMENT_SINGLE' => array(1 => '//'),
'COMMENT_MULTI' => array('/*' => '*/'),
'COMMENT_REGEXP' => array(
//Import and Package directives (Basic Support only)
2 => '/(?:(?<=import[\\n\\s])|(?<=using[\\n\\s])|(?<=package[\\n\\s]))[\\n\\s]*([a-zA-Z0-9_]+\\.)*([a-zA-Z0-9_]+|\*)(?=[\n\s;])/i',
// Haxe comments
3 => '#/\*\*(?![\*\/]).*\*/#sU',
),
'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
'QUOTEMARKS' => array("'", '"'),
'ESCAPE_CHAR' => '\\',
'KEYWORDS' => array(
1 => array(
//http://haxe.org/ref/keywords
'break', 'callback', 'case', 'cast', 'catch', 'class', 'continue', 'default', 'do', 'dynamic',
'else', 'enum', 'extends', 'extern', /*'false',*/ 'for', 'function', 'here', 'if',
'implements', 'import', 'in', 'inline', 'interface', 'never', 'new', /*'null',*/ 'override',
'package', 'private', 'public', 'return', 'static', 'super', 'switch', 'this', 'throw',
'trace', /*'true',*/ 'try', 'typedef', 'untyped', 'using', 'var', 'while',
'macro', '$type',
),
2 => array(
//primitive values
'null', 'false', 'true',
),
3 => array(
//global types
'Array', 'ArrayAccess', /*'Bool',*/ 'Class', 'Date', 'DateTools', 'Dynamic',
'EReg', 'Enum', 'EnumValue', /*'Float',*/ 'Hash', /*'Int',*/ 'IntHash', 'IntIter',
'Iterable', 'Iterator', 'Lambda', 'List', 'Math', 'Null', 'Reflect', 'Std',
/*'String',*/ 'StringBuf', 'StringTools', 'Sys', 'Type', /*'UInt',*/ 'ValueType',
/*'Void',*/ 'Xml', 'XmlType',
),
4 => array(
//primitive types
'Void', 'Bool', 'Int', 'Float', 'UInt', 'String',
),
5 => array(
//compiler switches
"#if", "#elseif", "#else", "#end", "#error",
),
),
'SYMBOLS' => array(
//http://haxe.org/manual/operators
'++', '--',
'%',
'*', '/',
'+', '-',
'<<', '>>', '>>>',
'|', '&', '^',
'==', '!=', '>', '>=', '<', '<=',
'...',
'&&',
'||',
'?', ':',
'=', '+=', '-=', '/=', '*=', '<<=', '>>=', '>>>=', '|=', '&=', '^=',
'(', ')', '[', ']', '{', '}', ';',
),
'CASE_SENSITIVE' => array(
GESHI_COMMENTS => false,
1 => true,
2 => true,
3 => true,
4 => true,
5 => true,
),
'STYLES' => array(
'KEYWORDS' => array(
1 => 'color: #6699cc; font-weight: bold;',
2 => 'color: #000066; font-weight: bold;',
3 => 'color: #03F; ',
4 => 'color: #000033; font-weight: bold;',
5 => 'color: #330000; font-weight: bold;',
),
'COMMENTS' => array(
1 => 'color: #666666; font-style: italic;',
2 => 'color: #006699;',
3 => 'color: #008000; font-style: italic; font-weight: bold;',
3 => 'color: #008000; font-style: italic; font-weight: bold;',
'MULTI' => 'color: #666666; font-style: italic;',
),
'ESCAPE_CHAR' => array(
0 => 'color: #000099; font-weight: bold;',
),
'BRACKETS' => array(
0 => 'color: #000000;',
),
'STRINGS' => array(
0 => 'color: #FF0000;',
),
'NUMBERS' => array(
0 => 'color: #cc66cc;',
),
'METHODS' => array(
1 => 'color: #006633;',
2 => 'color: #006633;',
),
'SYMBOLS' => array(
0 => 'color: #339933;',
),
'SCRIPT' => array(
),
'REGEXPS' => array(
)
),
'URLS' => array(
1 => '',
2 => '',
3 => '',
4 => '',
5 => '',
),
'OOLANG' => true,
'OBJECT_SPLITTERS' => array(
1 => '.',
),
'REGEXPS' => array(
),
'STRICT_MODE_APPLIES' => GESHI_NEVER,
'SCRIPT_DELIMITERS' => array(
),
'HIGHLIGHT_STRICT_BLOCK' => array(
),
);
?>
From ad2e9c2fd6eb7b813b1208da26ae6370f3814acd Mon Sep 17 00:00:00 2001
From: Andy Li <andy@onthewings.net>
Date: Sat, 14 Jul 2012 03:41:19 +0800
Subject: [PATCH] Added haxe(2.10) syntax file, passed langcheck.
---
src/geshi.php | 1 +
src/geshi/haxe.php | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 156 insertions(+), 0 deletions(-)
create mode 100644 src/geshi/haxe.php
diff --git a/src/geshi.php b/src/geshi.php
index b87299e..b685eb4 100644
--- a/src/geshi.php
+++ b/src/geshi.php
@@ -1481,6 +1481,7 @@ class GeSHi {
'gnuplot' => array('plt'),
'groovy' => array('groovy'),
'haskell' => array('hs'),
+ 'haxe' => array('hx'),
'html4strict' => array('html', 'htm'),
'ini' => array('ini', 'desktop'),
'java' => array('java'),
diff --git a/src/geshi/haxe.php b/src/geshi/haxe.php
new file mode 100644
index 0000000..8829dfd
--- /dev/null
+++ b/src/geshi/haxe.php
@@ -0,0 +1,155 @@
+<?php
+/*************************************************************************************
+ * haxe.php
+ * --------
+ * Author: Andy Li (andy@onthewings.net)
+ * John Liao (colorhook@gmail.com)
+ * Copyright: (c) 2012 onthewings (http://www.onthewings.net/)
+ * 2010 colorhook (http://colorhook.com/)
+ * Release Version: 1.1.0.0
+ * Date Started: 2010/10/05
+ *
+ * haXe language file for GeSHi.
+ * haxe version: 2.10
+ *************************************************************************************
+ *
+ * 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' => 'Haxe',
+ 'COMMENT_SINGLE' => array(1 => '//'),
+ 'COMMENT_MULTI' => array('/*' => '*/'),
+ 'COMMENT_REGEXP' => array(
+ //Import and Package directives (Basic Support only)
+ 2 => '/(?:(?<=import[\\n\\s])|(?<=using[\\n\\s])|(?<=package[\\n\\s]))[\\n\\s]*([a-zA-Z0-9_]+\\.)*([a-zA-Z0-9_]+|\*)(?=[\n\s;])/i',
+ // haXe comments
+ 3 => '#/\*\*(?![\*\/]).*\*/#sU'
+ ),
+ 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
+ 'QUOTEMARKS' => array("'", '"'),
+ 'ESCAPE_CHAR' => '\\',
+ 'KEYWORDS' => array(
+ 1 => array(
+ //http://haxe.org/ref/keywords
+ 'break', 'callback', 'case', 'cast', 'catch', 'class', 'continue', 'default', 'do', 'dynamic',
+ 'else', 'enum', 'extends', 'extern', /*'false',*/ 'for', 'function', 'here', 'if',
+ 'implements', 'import', 'in', 'inline', 'interface', 'never', 'new', /*'null',*/ 'override',
+ 'package', 'private', 'public', 'return', 'static', 'super', 'switch', 'this', 'throw',
+ 'trace', /*'true',*/ 'try', 'typedef', 'untyped', 'using', 'var', 'while',
+
+ 'macro',
+ ),
+ 2 => array(
+ 'null', 'false', 'true'
+ ),
+ 3 => array(
+ //global types
+ 'Array', 'ArrayAccess', /*'Bool',*/ 'Class', 'Date', 'DateTools', 'Dynamic',
+ 'EReg', 'Enum', 'EnumValue', /*'Float',*/ 'Hash', /*'Int',*/ 'IntHash', 'IntIter',
+ 'Iterable', 'Iterator', 'Lambda', 'List', 'Math', 'Null', 'Reflect', 'Std',
+ 'String', 'StringBuf', 'StringTools', 'Sys', 'Type', /*'UInt',*/ 'ValueType',
+ /*'Void',*/ 'Xml', 'XmlType',
+ ),
+ 4 => array(
+ 'Void', 'Bool', 'Int', 'Float', 'UInt'
+ )
+ ),
+ 'SYMBOLS' => array(
+ //http://haxe.org/manual/operators
+ '++', '--',
+ '%',
+ '*', '/',
+ '+', '-',
+ '<<', '>>', '>>>',
+ '|', '&', '^',
+ '==', '!=', '>', '>=', '<', '<=',
+ '...',
+ '&&',
+ '||',
+ '?', ':',
+ '=', '+=', '-=', '/=', '*=', '<<=', '>>=', '>>>=', '|=', '&=', '^=',
+
+
+ '(', ')', '[', ']', '{', '}', ';',
+ ),
+ 'CASE_SENSITIVE' => array(
+ GESHI_COMMENTS => false,
+ 1 => true,
+ 2 => true,
+ 3 => true,
+ 4 => true
+ ),
+ 'STYLES' => array(
+ 'KEYWORDS' => array(
+ 1 => 'color: #6699cc; font-weight: bold;',
+ 2 => 'color: #000066; font-weight: bold;',
+ 3 => 'color: #03F; ',
+ 4 => 'color: #000033; font-weight: bold;'
+ ),
+ 'COMMENTS' => array(
+ 1 => 'color: #666666; font-style: italic;',
+ 2 => 'color: #006699;',
+ 3 => 'color: #008000; font-style: italic; font-weight: bold;',
+ 3 => 'color: #008000; font-style: italic; font-weight: bold;',
+ 'MULTI' => 'color: #666666; font-style: italic;'
+ ),
+ 'ESCAPE_CHAR' => array(
+ 0 => 'color: #000099; font-weight: bold;'
+ ),
+ 'BRACKETS' => array(
+ 0 => 'color: #000000;'
+ ),
+ 'STRINGS' => array(
+ 0 => 'color: #FF0000;'
+ ),
+ 'NUMBERS' => array(
+ 0 => 'color: #cc66cc;'
+ ),
+ 'METHODS' => array(
+ 1 => 'color: #006633;',
+ 2 => 'color: #006633;'
+ ),
+ 'SYMBOLS' => array(
+ 0 => 'color: #339933;'
+ ),
+ 'SCRIPT' => array(
+ ),
+ 'REGEXPS' => array(
+ )
+ ),
+ 'URLS' => array(
+ 1 => '',
+ 2 => '',
+ 3 => '',
+ 4 => ''
+ ),
+ 'OOLANG' => true,
+ 'OBJECT_SPLITTERS' => array(
+ 1 => '.'
+ ),
+ 'REGEXPS' => array(
+ ),
+ 'STRICT_MODE_APPLIES' => GESHI_NEVER,
+ 'SCRIPT_DELIMITERS' => array(
+ ),
+ 'HIGHLIGHT_STRICT_BLOCK' => array(
+ )
+);
+
+?>
\ No newline at end of file
--
1.7.8.3
From 2158e32dbdf2415ebeae3230860ba458d3d48b55 Mon Sep 17 00:00:00 2001
From: Andy Li <andy@onthewings.net>
Date: Sat, 14 Jul 2012 04:04:52 +0800
Subject: [PATCH] Change 'haXe' to 'Haxe'. Added conditional compilation
macros as SYMBOLS.
---
src/geshi/haxe.php | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/geshi/haxe.php b/src/geshi/haxe.php
index 8829dfd..d0f833e 100644
--- a/src/geshi/haxe.php
+++ b/src/geshi/haxe.php
@@ -9,8 +9,8 @@
* Release Version: 1.1.0.0
* Date Started: 2010/10/05
*
- * haXe language file for GeSHi.
- * haxe version: 2.10
+ * Haxe language file for GeSHi.
+ * Haxe version: 2.10
*************************************************************************************
*
* This file is part of GeSHi.
@@ -38,8 +38,8 @@ $language_data = array (
'COMMENT_REGEXP' => array(
//Import and Package directives (Basic Support only)
2 => '/(?:(?<=import[\\n\\s])|(?<=using[\\n\\s])|(?<=package[\\n\\s]))[\\n\\s]*([a-zA-Z0-9_]+\\.)*([a-zA-Z0-9_]+|\*)(?=[\n\s;])/i',
- // haXe comments
- 3 => '#/\*\*(?![\*\/]).*\*/#sU'
+ // Haxe comments
+ 3 => '#/\*\*(?![\*\/]).*\*/#sU',
),
'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
'QUOTEMARKS' => array("'", '"'),
@@ -87,6 +87,8 @@ $language_data = array (
'(', ')', '[', ']', '{', '}', ';',
+
+ '#if', '#elseif', '#else', '#end',
),
'CASE_SENSITIVE' => array(
GESHI_COMMENTS => false,
--
1.7.8.3
From e3865e79a49668f4f573749206bd3458f90fb325 Mon Sep 17 00:00:00 2001
From: Andy Li <andy@onthewings.net>
Date: Sat, 14 Jul 2012 04:40:57 +0800
Subject: [PATCH] "String" should be primitive type too.
---
src/geshi/haxe.php | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/geshi/haxe.php b/src/geshi/haxe.php
index d0f833e..ed4acca 100644
--- a/src/geshi/haxe.php
+++ b/src/geshi/haxe.php
@@ -63,11 +63,12 @@ $language_data = array (
'Array', 'ArrayAccess', /*'Bool',*/ 'Class', 'Date', 'DateTools', 'Dynamic',
'EReg', 'Enum', 'EnumValue', /*'Float',*/ 'Hash', /*'Int',*/ 'IntHash', 'IntIter',
'Iterable', 'Iterator', 'Lambda', 'List', 'Math', 'Null', 'Reflect', 'Std',
- 'String', 'StringBuf', 'StringTools', 'Sys', 'Type', /*'UInt',*/ 'ValueType',
+ /*'String',*/ 'StringBuf', 'StringTools', 'Sys', 'Type', /*'UInt',*/ 'ValueType',
/*'Void',*/ 'Xml', 'XmlType',
),
4 => array(
- 'Void', 'Bool', 'Int', 'Float', 'UInt'
+ //primitive types
+ 'Void', 'Bool', 'Int', 'Float', 'UInt', 'String'
)
),
'SYMBOLS' => array(
--
1.7.8.3
From 4701ac1c54a43cb23cfc735e263d516361066399 Mon Sep 17 00:00:00 2001
From: Andy Li <andy@onthewings.net>
Date: Mon, 16 Jul 2012 20:36:14 +0800
Subject: [PATCH] Moved "#*" to keywords as suggested.
---
src/geshi/haxe.php | 42 ++++++++++++++++++++++++------------------
1 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/src/geshi/haxe.php b/src/geshi/haxe.php
index ed4acca..ea2fa19 100644
--- a/src/geshi/haxe.php
+++ b/src/geshi/haxe.php
@@ -53,10 +53,11 @@ $language_data = array (
'package', 'private', 'public', 'return', 'static', 'super', 'switch', 'this', 'throw',
'trace', /*'true',*/ 'try', 'typedef', 'untyped', 'using', 'var', 'while',
- 'macro',
+ 'macro', '$type',
),
2 => array(
- 'null', 'false', 'true'
+ //primitive values
+ 'null', 'false', 'true',
),
3 => array(
//global types
@@ -68,8 +69,12 @@ $language_data = array (
),
4 => array(
//primitive types
- 'Void', 'Bool', 'Int', 'Float', 'UInt', 'String'
- )
+ 'Void', 'Bool', 'Int', 'Float', 'UInt', 'String',
+ ),
+ 5 => array(
+ //compiler switches
+ "#if", "#elseif", "#else", "#end", "#error",
+ ),
),
'SYMBOLS' => array(
//http://haxe.org/manual/operators
@@ -88,48 +93,48 @@ $language_data = array (
'(', ')', '[', ']', '{', '}', ';',
-
- '#if', '#elseif', '#else', '#end',
),
'CASE_SENSITIVE' => array(
GESHI_COMMENTS => false,
1 => true,
2 => true,
3 => true,
- 4 => true
+ 4 => true,
+ 5 => true,
),
'STYLES' => array(
'KEYWORDS' => array(
1 => 'color: #6699cc; font-weight: bold;',
2 => 'color: #000066; font-weight: bold;',
3 => 'color: #03F; ',
- 4 => 'color: #000033; font-weight: bold;'
+ 4 => 'color: #000033; font-weight: bold;',
+ 5 => 'color: #330000; font-weight: bold;',
),
'COMMENTS' => array(
1 => 'color: #666666; font-style: italic;',
2 => 'color: #006699;',
3 => 'color: #008000; font-style: italic; font-weight: bold;',
3 => 'color: #008000; font-style: italic; font-weight: bold;',
- 'MULTI' => 'color: #666666; font-style: italic;'
+ 'MULTI' => 'color: #666666; font-style: italic;',
),
'ESCAPE_CHAR' => array(
- 0 => 'color: #000099; font-weight: bold;'
+ 0 => 'color: #000099; font-weight: bold;',
),
'BRACKETS' => array(
- 0 => 'color: #000000;'
+ 0 => 'color: #000000;',
),
'STRINGS' => array(
- 0 => 'color: #FF0000;'
+ 0 => 'color: #FF0000;',
),
'NUMBERS' => array(
- 0 => 'color: #cc66cc;'
+ 0 => 'color: #cc66cc;',
),
'METHODS' => array(
1 => 'color: #006633;',
- 2 => 'color: #006633;'
+ 2 => 'color: #006633;',
),
'SYMBOLS' => array(
- 0 => 'color: #339933;'
+ 0 => 'color: #339933;',
),
'SCRIPT' => array(
),
@@ -140,11 +145,12 @@ $language_data = array (
1 => '',
2 => '',
3 => '',
- 4 => ''
+ 4 => '',
+ 5 => '',
),
'OOLANG' => true,
'OBJECT_SPLITTERS' => array(
- 1 => '.'
+ 1 => '.',
),
'REGEXPS' => array(
),
@@ -152,7 +158,7 @@ $language_data = array (
'SCRIPT_DELIMITERS' => array(
),
'HIGHLIGHT_STRICT_BLOCK' => array(
- )
+ ),
);
?>
\ No newline at end of file
--
1.7.8.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment