Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bsmith-n4 committed May 29, 2017
1 parent 07a6806 commit 98867cf
Show file tree
Hide file tree
Showing 12 changed files with 263 additions and 5 deletions.
5 changes: 5 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ var components = {
"title": "Monkey",
"owner": "Golmote"
},
"n4js":{
"title": "N4JS",
"require": "javascript",
"owner": "bsmith-n4"
},
"nasm": {
"title": "NASM",
"owner": "rbmj"
Expand Down
2 changes: 1 addition & 1 deletion components/prism-css-extras.min.js

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

14 changes: 14 additions & 0 deletions components/prism-n4js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Prism.languages.n4js = Prism.languages.extend('javascript', {
// Keywords from N4JS language spec: https://numberfour.github.io/n4js/spec/N4JSSpec.html
'keyword': /\b(any|Array|boolean|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|module|new|null|number|package|private|protected|public|return|set|static|string|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/
});

Prism.languages.insertBefore('n4js', 'function', {
// Annotations in N4JS spec: https://numberfour.github.io/n4js/spec/N4JSSpec.html#_annotations
'annotation': {
pattern: /(@+\w+)/,
alias: 'operator'
}
});

Prism.languages.n4jsd=Prism.languages.n4js;
1 change: 1 addition & 0 deletions components/prism-n4js.min.js

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

29 changes: 29 additions & 0 deletions examples/prism-n4js.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<h1>N4JS</h1>
<p>To use this language, use the class "language-n4js".</p>

<h2>Full example</h2>
<pre><code>//Creating a simple Web User Interface in HTML

import { TaskManager } from "TaskManager"
import {Application, Response } from "express";
import express from "express";
import { Todo } from "model"

export class WebUI {

private app: Application;

@Inject
private manager: TaskManager;

public start() {

this.app = express();

this.app.get('/', async (req, res) => {
let page = await this.renderHomePage();
res.send(page);
});
}
}
</code></pre>
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
}

// The dependencies map is built automatically with gulp
var lang_dependencies = /*languages_placeholder[*/{"javascript":"clike","actionscript":"javascript","aspnet":"markup","bison":"c","c":"clike","csharp":"clike","cpp":"c","coffeescript":"javascript","crystal":"ruby","css-extras":"css","d":"clike","dart":"clike","django":"markup","fsharp":"clike","glsl":"clike","go":"clike","groovy":"clike","haml":"ruby","handlebars":"markup","haxe":"clike","jade":"javascript","java":"clike","jolie":"clike","kotlin":"clike","less":"css","markdown":"markup","nginx":"clike","objectivec":"c","parser":"markup","php":"clike","php-extras":"php","processing":"clike","protobuf":"clike","qore":"clike","jsx":["markup","javascript"],"reason":"clike","ruby":"clike","sass":"css","scss":"css","scala":"java","smarty":"markup","swift":"clike","textile":"markup","twig":"markup","typescript":"javascript","vbnet":"basic","wiki":"markup"}/*]*/;
var lang_dependencies = /*languages_placeholder[*/{"javascript":"clike","actionscript":"javascript","aspnet":"markup","bison":"c","c":"clike","csharp":"clike","cpp":"c","coffeescript":"javascript","crystal":"ruby","css-extras":"css","d":"clike","dart":"clike","django":"markup","fsharp":"clike","glsl":"clike","go":"clike","groovy":"clike","haml":"ruby","handlebars":"markup","haxe":"clike","jade":"javascript","java":"clike","jolie":"clike","kotlin":"clike","less":"css","markdown":"markup","n4js":"javascript","nginx":"clike","objectivec":"c","parser":"markup","php":"clike","php-extras":"php","processing":"clike","protobuf":"clike","qore":"clike","jsx":["markup","javascript"],"reason":"clike","ruby":"clike","sass":"css","scss":"css","scala":"java","smarty":"markup","swift":"clike","textile":"markup","twig":"markup","typescript":"javascript","vbnet":"basic","wiki":"markup"}/*]*/;

var lang_data = {};

Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.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","asciidoc":"AsciiDoc","aspnet":"ASP.NET (C#)","autoit":"AutoIt","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","django":"Django/Jinja2","fsharp":"F#","glsl":"GLSL","graphql":"GraphQL","http":"HTTP","inform7":"Inform 7","json":"JSON","latex":"LaTeX","livescript":"LiveScript","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","properties":".properties","protobuf":"Protocol Buffers","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vbnet":"VB.Net","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","xojo":"Xojo (REALbasic)","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","asciidoc":"AsciiDoc","aspnet":"ASP.NET (C#)","autoit":"AutoIt","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","django":"Django/Jinja2","fsharp":"F#","glsl":"GLSL","graphql":"GraphQL","http":"HTTP","inform7":"Inform 7","json":"JSON","latex":"LaTeX","livescript":"LiveScript","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","n4js":"N4JS","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","properties":".properties","protobuf":"Protocol Buffers","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vbnet":"VB.Net","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","xojo":"Xojo (REALbasic)","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.

53 changes: 53 additions & 0 deletions tests/languages/n4js/annotation_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@Inject
@Internal
@Undefined
@StringBased
@Final
@GenerateInjector
@WithParentInjector
@Spec
@Override
@Promisifiable
@Promisify
@This
@N4JS
@IgnoreImplementation
@Global
@ProvidedByRuntime
@TestAPI
@Polyfill
@StaticPolyfill
@StaticPolyfillAware
@StaticPolyfillModule
@Transient

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

[
["annotation", "@Inject"],
["annotation", "@Internal"],
["annotation", "@Undefined"],
["annotation", "@StringBased"],
["annotation", "@Final"],
["annotation", "@GenerateInjector"],
["annotation", "@WithParentInjector"],
["annotation", "@Spec"],
["annotation", "@Override"],
["annotation", "@Promisifiable"],
["annotation", "@Promisify"],
["annotation", "@This"],
["annotation", "@N4JS"],
["annotation", "@IgnoreImplementation"],
["annotation", "@Global"],
["annotation", "@ProvidedByRuntime"],
["annotation", "@TestAPI"],
["annotation", "@Polyfill"],
["annotation", "@StaticPolyfill"],
["annotation", "@StaticPolyfillAware"],
["annotation", "@StaticPolyfillModule"],
["annotation", "@Transient"]
]

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

Test for annotations.
121 changes: 121 additions & 0 deletions tests/languages/n4js/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
any
Array
boolean
break
case
catch
class;
const
constructor
continue
debugger
declare
default
delete
do
else
enum
export
extends;
false
finally
for
from
function
get
if
implements;
import
in
instanceof;
interface;
let
module
new;
null
number
package
private
protected
public
return
set
static
string
super
switch
this
throw
true
try
typeof
var
void
while
with
yield

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

[
["keyword", "any"],
["keyword", "Array"],
["keyword", "boolean"],
["keyword", "break"],
["keyword", "case"],
["keyword", "catch"],
["keyword", "class"], ["punctuation", ";"],
["keyword", "const"],
["keyword", "constructor"],
["keyword", "continue"],
["keyword", "debugger"],
["keyword", "declare"],
["keyword", "default"],
["keyword", "delete"],
["keyword", "do"],
["keyword", "else"],
["keyword", "enum"],
["keyword", "export"],
["keyword", "extends"], ["punctuation", ";"],
["keyword", "false"],
["keyword", "finally"],
["keyword", "for"],
["keyword", "from"],
["keyword", "function"],
["keyword", "get"],
["keyword", "if"],
["keyword", "implements"], ["punctuation", ";"],
["keyword", "import"],
["keyword", "in"],
["keyword", "instanceof"], ["punctuation", ";"],
["keyword", "interface"], ["punctuation", ";"],
["keyword", "let"],
["keyword", "module"],
["keyword", "new"], ["punctuation", ";"],
["keyword", "null"],
["keyword", "number"],
["keyword", "package"],
["keyword", "private"],
["keyword", "protected"],
["keyword", "public"],
["keyword", "return"],
["keyword", "set"],
["keyword", "static"],
["keyword", "string"],
["keyword", "super"],
["keyword", "switch"],
["keyword", "this"],
["keyword", "throw"],
["keyword", "true"],
["keyword", "try"],
["keyword", "typeof"],
["keyword", "var"],
["keyword", "void"],
["keyword", "while"],
["keyword", "with"],
["keyword", "yield"]
]

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

Tests N4JS keywords.
35 changes: 35 additions & 0 deletions tests/languages/n4js/type-annotation_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
: any
: boolean
: enum
: function
: Function
: int
: null
: number
: object
: Object
: string
: symbol
: undefined

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

[
["type-annotation", ": any"],
["type-annotation", ": boolean"],
["type-annotation", ": enum"],
["type-annotation", ": function"],
["type-annotation", ": Function"],
["type-annotation", ": int"],
["type-annotation", ": null"],
["type-annotation", ": number"],
["type-annotation", ": object"],
["type-annotation", ": Object"],
["type-annotation", ": string"],
["type-annotation", ": symbol"],
["type-annotation", ": undefined"]
]

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

Test for type annotations.

0 comments on commit 98867cf

Please sign in to comment.