Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New language: CIL #1593

Merged
merged 31 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9234e4f
cil: add language
sbrl Oct 23, 2018
ba405d3
Add display title. I think this is how it works?
sbrl Oct 23, 2018
5a7a997
Rename prism.cil.js to prism-cil.js
sbrl Oct 23, 2018
094c252
Add CIL to components.json
sbrl Oct 23, 2018
05da1c6
Run gulp
sbrl Oct 23, 2018
4e850ea
[CIL] Update comments regex
sbrl Oct 24, 2018
c4267e0
CIL: Remove displayTitle from language definition
sbrl Oct 24, 2018
595d917
CIL: Reorder lines
sbrl Oct 24, 2018
6f77c0b
CIL: Move definition in components.json
sbrl Oct 24, 2018
a3ade2a
CIL: Update keywords list
sbrl Oct 24, 2018
7f19702
CIL: Improve number recognition regex
sbrl Oct 24, 2018
c9f9c33
CIL: Add additional punctuation
sbrl Oct 24, 2018
44206f0
CIL: Change function list
sbrl Oct 24, 2018
35616a1
CIL: Fix parse error
sbrl Oct 24, 2018
a76a28d
Rerun gulp
sbrl Oct 24, 2018
77d8318
Revert package-lock.json & prism.js
sbrl Oct 24, 2018
6676327
CIL: Use non-capturing groups
sbrl Oct 24, 2018
f07575c
Re-rerun gulp
sbrl Oct 24, 2018
00a0614
Add some tests
sbrl Oct 28, 2018
53f9376
Update keywords.test
sbrl Oct 29, 2018
6c11e5e
Add alias to directive
sbrl Oct 29, 2018
1b9a7b7
Improve prefix handling & pass tests
sbrl Nov 8, 2018
48f7f86
[CIL] Bugfix strings
sbrl Nov 9, 2018
0366685
[CIL] Add string test
sbrl Nov 9, 2018
706b0a8
[CIL] Fix directives by using a positive lookahead
sbrl Nov 9, 2018
03b4258
[CIL] Bugfix assembly references
sbrl Nov 9, 2018
882f5c9
[CIL] Add additional keywords
sbrl Nov 9, 2018
2758ec0
Re-run gulp
sbrl Nov 9, 2018
3eb0ed6
[CIL] Add char keyword
sbrl Nov 13, 2018
89f49eb
[CIL] Add tests for new keywords
sbrl Nov 13, 2018
57c1fbe
Merge branch 'master' into patch-1
sbrl Nov 28, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@
"require": "c",
"owner": "zeitgeist87"
},
"cil": {
"title": "CIL",
"owner": "sbrl"
},
"coffeescript": {
"title": "CoffeeScript",
"require": "javascript",
Expand Down
27 changes: 27 additions & 0 deletions components/prism-cil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Prism.languages.cil = {
'comment': /\/\/.*/,

'string': {
pattern: /(?:["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
sbrl marked this conversation as resolved.
Show resolved Hide resolved
greedy: true
},

'directive': {
pattern: /([^a-zA-Z0-9])\.[a-z]+\b/,
sbrl marked this conversation as resolved.
Show resolved Hide resolved
lookbehind: true,
alias: 'class-name'
},

// Actually an assembly reference
'variable': /\[\w+\]/,
sbrl marked this conversation as resolved.
Show resolved Hide resolved


'keyword': /\b(?:abstract|ansi|assembly|auto|autochar|beforefieldinit|bool|bstr|byvalstr|cil|class|currency|date|decimal|default|enum|error|explicit|extends|extern|famandassem|family|famorassem|final|float32|float64|hidebysig|iant|idispatch|import|initonly|instance|int|int16|int32|int64|int8|interface|iunknown|lpstr|lpstruct|lptstr|lpwstr|managed|nativeType|nested|newslot|objectref|pinvokeimpl|private|privatescope|public|reqsecobj|rtspecialname|sealed|sequential|serializable|specialname|static|string|struct|syschar|tbstr|unicode|unmanagedexp|unsigned|value|variant|virtual|void)\b/,

'function': /\b(?:(?:constrained|unaligned|volatile|readonly|tail|no)\.)?(?:conv\.(?:[iu][1248]?|ovf\.[iu][1248]?(?:\.un)?|r\.un|r4|r8)|ldc\.(?:i4(?:\.[0-9]+|\.[mM]1|\.s)?|i8|r4|r8)|ldelem(?:\.[iu][1248]?|\.r[48]|\.ref|a)?|ldind\.(?:[iu][1248]?|r[48]|ref)|stelem\.?(?:i[1248]?|r[48]|ref)?|stind\.(i[1248]?|r[48]|ref)?|end(?:fault|filter|finally)|ldarg(?:\.[0-3s]|a(?:\.s)?)?|ldloc(?:\.[0-9]+|\.s)?|sub(?:\.ovf(?:\.un)?)?|mul(?:\.ovf(?:\.un)?)?|add(?:\.ovf(?:\.un)?)?|stloc(?:\.[0-3s])?|refany(?:type|val)|blt(?:\.un)?(?:\.s)?|ble(?:\.un)?(?:\.s)?|bgt(?:\.un)?(?:\.s)?|bge(?:\.un)?(?:\.s)?|unbox(?:\.any)?|init(?:blk|obj)|call(?:i|virt)?|brfalse(?:\.s)?|bne\.un(?:\.s)?|ldloca(?:\.s)?|brzero(?:\.s)?|brtrue(?:\.s)?|brnull(?:\.s)?|brinst(?:\.s)?|starg(?:\.s)?|leave(?:\.s)?|shr(?:\.un)?|rem(?:\.un)?|div(?:\.un)?|clt(?:\.un)?|alignment|ldvirtftn|castclass|beq(?:\.s)?|mkrefany|localloc|ckfinite|rethrow|ldtoken|ldsflda|cgt\.un|arglist|switch|stsfld|sizeof|newobj|newarr|ldsfld|ldnull|ldflda|isinst|throw|stobj|stloc|stfld|ldstr|ldobj|ldlen|ldftn|ldfld|cpobj|cpblk|break|br\.s|xor|shl|ret|pop|not|nop|neg|jmp|dup|clt|cgt|ceq|box|and|or|br)\b/,

'boolean': /\b(?:true|false)\b/,
'number': /\b-?(?:0x[0-9a-fA-F]+|[0-9]+)(?:\.[0-9a-fA-F]+)?\b/i,

'punctuation': /[{}[\];(),:=]|IL_[0-9A-Za-z]+/
}
1 change: 1 addition & 0 deletions components/prism-cil.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/prism-css.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (!Prism.plugins.toolbar) {
}

// The languages map is built automatically with gulp
var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","arff":"ARFF","asciidoc":"AsciiDoc","asm6502":"6502 Assembly","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","autoit":"AutoIt","shell":"Shell","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","csp":"Content-Security-Policy","css-extras":"CSS Extras","django":"Django/Jinja2","erb":"ERB","fsharp":"F#","gedcom":"GEDCOM","glsl":"GLSL","gml":"GameMaker Language","graphql":"GraphQL","http":"HTTP","hpkp":"HTTP Public-Key-Pins","hsts":"HTTP Strict-Transport-Security","ichigojam":"IchigoJam","inform7":"Inform 7","json":"JSON","jsonp":"JSONP","latex":"LaTeX","livescript":"LiveScript","lolcode":"LOLCODE","markup-templating":"Markup templating","matlab":"MATLAB","mel":"MEL","n4js":"N4JS","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","opencl":"OpenCL","parigp":"PARI/GP","objectpascal":"Object Pascal","php":"PHP","php-extras":"PHP Extras","plsql":"PL/SQL","powershell":"PowerShell","properties":".properties","protobuf":"Protocol Buffers","q":"Q (kdb+ database)","jsx":"React JSX","tsx":"React TSX","renpy":"Ren'py","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","soy":"Soy (Closure Template)","tap":"TAP","tt2":"Template Toolkit 2","typescript":"TypeScript","vbnet":"VB.Net","vhdl":"VHDL","vim":"vim","visual-basic":"Visual Basic","wasm":"WebAssembly","wiki":"Wiki markup","xeoracube":"XeoraCube","xojo":"Xojo (REALbasic)","xquery":"XQuery","yaml":"YAML"}/*]*/;
var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","arff":"ARFF","asciidoc":"AsciiDoc","asm6502":"6502 Assembly","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","autoit":"AutoIt","shell":"Shell","basic":"BASIC","csharp":"C#","cpp":"C++","cil":"CIL","coffeescript":"CoffeeScript","csp":"Content-Security-Policy","css-extras":"CSS Extras","django":"Django/Jinja2","erb":"ERB","fsharp":"F#","gedcom":"GEDCOM","glsl":"GLSL","gml":"GameMaker Language","graphql":"GraphQL","http":"HTTP","hpkp":"HTTP Public-Key-Pins","hsts":"HTTP Strict-Transport-Security","ichigojam":"IchigoJam","inform7":"Inform 7","json":"JSON","jsonp":"JSONP","latex":"LaTeX","livescript":"LiveScript","lolcode":"LOLCODE","markup-templating":"Markup templating","matlab":"MATLAB","mel":"MEL","n4js":"N4JS","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","opencl":"OpenCL","parigp":"PARI/GP","objectpascal":"Object Pascal","php":"PHP","php-extras":"PHP Extras","plsql":"PL/SQL","powershell":"PowerShell","properties":".properties","protobuf":"Protocol Buffers","q":"Q (kdb+ database)","jsx":"React JSX","tsx":"React TSX","renpy":"Ren'py","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","soy":"Soy (Closure Template)","tap":"TAP","tt2":"Template Toolkit 2","typescript":"TypeScript","vbnet":"VB.Net","vhdl":"VHDL","vim":"vim","visual-basic":"Visual Basic","wasm":"WebAssembly","wiki":"Wiki markup","xeoracube":"XeoraCube","xojo":"Xojo (REALbasic)","xquery":"XQuery","yaml":"YAML"}/*]*/;
Prism.plugins.toolbar.registerButton('show-language', function(env) {
var pre = env.element.parentNode;
if (!pre || !/pre/i.test(pre.nodeName)) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tests/languages/cil/asm_reference.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[mscorlib]

--------------------------------------------------------

[
[ "variable", "[mscorlib]" ]
]

--------------------------------------------------------

Tests assembly references
14 changes: 14 additions & 0 deletions tests/languages/cil/boolean.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

true
false

----------------------------------------------------

[
["boolean", "true"],
["boolean", "false"]
]

----------------------------------------------------

Tests booleans.
11 changes: 11 additions & 0 deletions tests/languages/cil/comment.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// this is a test

--------------------------------------------------------

[
[ "comment", "// this is a test" ]
]

--------------------------------------------------------

Tests comments
Loading