Skip to content

Commit

Permalink
Merge branch 'master' of github.com:c3d/highlight.js into xl
Browse files Browse the repository at this point in the history
Conflicts:
	AUTHORS.en.txt
	docs/css-classes-reference.rst
	src/test.html
  • Loading branch information
isagalaev committed Oct 8, 2014
2 parents 12d4958 + 9d386b6 commit 9fd579a
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 6 deletions.
1 change: 1 addition & 0 deletions AUTHORS.en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,4 @@ Contributors:
- Luke Holder <[email protected]>
- David Mohundro <[email protected]>
- Nicholas Blumhardt <[email protected]>
- Christophe de Dinechin <[email protected]>
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ New languages and styles:

- *Oxygene* by [Carlo Kok][]
- *Mathematica* by [Daniel Kvasnička][]
- *XL* by [Christophe de Dinechin][]
- *Autohotkey* by [Seongwon Lee][]
- *Atelier* family of styles in 10 variants by [Bram de Haan][]
- *Paraíso* styles by [Jan T. Sott][]
Expand Down
17 changes: 17 additions & 0 deletions docs/css-classes-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1219,3 +1219,20 @@ Puppet ("puppet", "pp")
* ``number``: number
* ``keyword``: classes and types
* ``constant``: dependencies

XL ("xl", "tao")
-----------

* ``keyword``: keywords defined in the default syntax file
* ``literal``: names entered in the compiler (true, false, nil)
* ``type``: basic types (integer, real, text, name, etc)
* ``built_in``: built-in functions (sin, exp, mod, etc)
* ``module``: names of frequently used Tao modules
* ``id``: names of frequently used Tao functions
* ``constant``: all-uppercase names such as HELLO
* ``variable``: Mixed-case names such as Hello (style convention)
* ``id``: Lower-case names such as hello
* ``string``: Text between single or double quote, long text << >>
* ``number``: Number values
* ``function``: Function or variable definition
* ``import``: Import clause
90 changes: 90 additions & 0 deletions src/languages/xl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
Language: XL
Author: Christophe de Dinechin <[email protected]>
Description: An extensible programming language, based on parse tree rewriting (http://xlr.sf.net)
*/

function(hljs) {
var XL_KEYWORDS = {
keyword: 'if then else do while until for loop import with is as where when by data constant',
literal: 'true false nil',
type: 'integer real text name boolean symbol infix prefix postfix block tree',
built_in: 'in mod rem and or xor not abs sign floor ceil sqrt sin cos tan asin acos atan exp expm1 log log2 log10 log1p pi at '
};

var BUILTIN_MODULES = {
className: 'module',
begin: 'ObjectLoader|Animate|MovieCredits|Slides|Filters|Shading|Materials|LensFlare|Mapping|VLCAudioVideo|StereoDecoder|PointCloud|NetworkAccess|RemoteControl|RegExp|ChromaKey|Snowfall|NodeJS|Speech|Charts',
relevance: 10
};

var TAO_BUILTINS = {
className: 'id',
begin: 'text_length|text_range|text_find|text_replace|contains|page|slide|basic_slide|title_slide|title|subtitle|fade_in|fade_out|fade_at|clear_color|color|line_color|line_width|texture_wrap|texture_transform|texture|scale_?x|scale_?y|scale_?z?|translate_?x|translate_?y|translate_?z?|rotate_?x|rotate_?y|rotate_?z?|rectangle|circle|ellipse|sphere|path|line_to|move_to|quad_to|curve_to|theme|background|contents|locally|time|mouse_?x|mouse_?y|mouse_buttons'
};

var XL_CONSTANT = {
className: 'constant',
begin: '[A-Z][A-Z_0-9]+',
relevance: 0
};
var XL_VARIABLE = {
className: 'variable',
begin: '([A-Z][a-z_0-9]+)+',
relevance: 0
};
var XL_ID = {
className: 'id',
begin: '[a-z][a-z_0-9]+',
relevance: 0
};

var DOUBLE_QUOTE_TEXT = {
className: 'string',
begin: '"', end: '"', illegal: '\\n'
};
var SINGLE_QUOTE_TEXT = {
className: 'string',
begin: '\'', end: '\'', illegal: '\\n'
};
var LONG_TEXT = {
className: 'string',
begin: '<<', end: '>>',
relevance: 10
};
var BASED_NUMBER = {
className: 'number',
begin: '[0-9]+#[0-9A-Z_]+(\\.[0-9-A-Z_]+)?#?([Ee][+-]?[0-9]+)?',
relevance: 10
};
var IMPORT = {
className: 'import',
begin: '\\bimport\\b', end: '$',
keywords: 'import',
contains: [DOUBLE_QUOTE_TEXT, BUILTIN_MODULES],
relevance: 5
};
var FUNCTION_DEFINITION = {
className: 'function',
begin: '[a-z].*->'
};
return {
aliases: ['tao'],
keywords: XL_KEYWORDS,
contains: [
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
DOUBLE_QUOTE_TEXT,
SINGLE_QUOTE_TEXT,
LONG_TEXT,
FUNCTION_DEFINITION,
BUILTIN_MODULES,
TAO_BUILTINS,
XL_CONSTANT,
XL_VARIABLE,
XL_ID,
BASED_NUMBER,
hljs.NUMBER_MODE
]
};
}
40 changes: 34 additions & 6 deletions src/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -3512,8 +3512,7 @@ <h2>Automatically detected languages</h2>
<tr>
<th>x86asm</th>
<td class="x86asm">
<pre>
<code>section .text
<pre><code>section .text
extern _MessageBoxA@16
%if __NASM_VERSION_ID__ >= 0x02030000
safeseh handler ; register handler as "safe handler"
Expand Down Expand Up @@ -3554,11 +3553,11 @@ <h2>Automatically detected languages</h2>
section .drectve info
db '/defaultlib:user32.lib /defaultlib:msvcrt.lib '
</code></pre>

<tr>
<th>Q/KDB+
<td class="q">
<pre><code>
select time, price by date,stock from quote where price=(max;price)fby stock
<pre><code>select time, price by date,stock from quote where price=(max;price)fby stock
data:raze value flip trade
select vwap:size wavg price by 5 xbar time.minute from aapl where date within (.z.d-10;.z.d)
f1:{[x;y;z] show (x;y+z);sum 1 2 3}
Expand All @@ -3569,8 +3568,6 @@ <h2>Automatically detected languages</h2>
mode:{where g=max g:count each group x} // mode function
</code></pre>



<tr>
<th>Monkey
<td class="monkey">
Expand Down Expand Up @@ -3863,6 +3860,37 @@ <h2>Automatically detected languages</h2>
}
</code></pre>

<th>XL
<td class="xl">
<pre><code>import SeasonsGreetingsTheme
import "myhelper.xl"
theme "SeasonsGreetings"
function X:real -> sin(X*0.5) + 16#0.002
page "A nice car",
// --------------------------------------
// Display car model on a pedestal
// --------------------------------------
clear_color 0, 0, 0, 1
hand_scale -> 0.3

// Display the background image
background -4000,
locally
disable_depth_test
corridor N:integer ->
locally
rotatez 60 * N
translatex 1000
rotatey 90
color "white"
texture "stars.png"
texture_wrap true, true
texture_transform
translate (time + N) * 0.02 mod 1, 0, 0
scale 0.2, 0.3, 0.3
rectangle 0, 0, 100000, 1154
</code></pre>

</table>


Expand Down

0 comments on commit 9fd579a

Please sign in to comment.