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

Xeora Language implementation #1239

Merged
merged 10 commits into from
Dec 6, 2017
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
5 changes: 5 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,11 @@ var components = {
"title": "Xojo (REALbasic)",
"owner": "Golmote"
},
"xeora": {
"title": "Xeora",
"require": "markup",
"owner": "xeora"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please set the owner to you Github username "freakmaxi".

Once this is changed I think we're good to go!

},
"yaml": {
"title": "YAML",
"owner": "hason"
Expand Down
114 changes: 114 additions & 0 deletions components/prism-xeora.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
(function(Prism) {
Prism.languages.xeora = Prism.languages.extend('markup', {
'constant': {
pattern: /\$(?:DomainContents|PageRenderDuration)\$/,
inside: {
'punctuation': {
pattern: /\$/
}
}
},
'variable': {
pattern: /\$@?(?:#+|[-+*~=^])?[\w.]+\$/,
inside: {
'punctuation': {
pattern: /[$.]/
},
'operator': {
pattern: /#+|[-+*~=^@]/
}
}
},
'function-inline': {
pattern: /\$F:[-\w.]+\?[-\w.]+(?:,(?:\|?(?:[-#.^+*~]*(?:[\w+][^$]*)|=(?:[\S+][^$]*)|@[-#]*(?:\w+.)[\w+.]+)?)*)?\$/,
inside: {
'variable': {
pattern: /(?:[,|])@?(?:#+|[-+*~=^])?[\w.]+/,
inside: {
'punctuation': {
pattern: /[,.|]/
},
'operator': {
pattern: /#+|[-+*~=^@]/
}
}
},
'punctuation': {
pattern: /\$\w:|[$:?.,|]/
}
},
alias: 'function'
},
'function-block': {
pattern: /\$XF:{[-\w.]+\?[-\w.]+(?:,(?:\|?(?:[-#.^+*~]*(?:[\w+][^$]*)|=(?:[\S+][^$]*)|@[-#]*(?:\w+.)[\w+.]+)?)*)?}:XF\$/,
inside: {
'punctuation': {
pattern: /[$:{}?.,|]/
}
},
alias: 'function'
},
'directive-inline': {
pattern: /\$\w(?:#\d+\+?)?(?:\[[-\w.]+])?:[-\/\w.]+\$/,
inside: {
'punctuation': {
pattern: /\$(?:\w:|C(?:\[|#\d))?|[:{[\]]/,
inside: {
'tag': {
pattern: /#\d/
}
}
}
},
alias: 'function'
},
'directive-block-open': {
pattern: /\$\w+:{|\$\w(?:#\d+\+?)?(?:\[[-\w.]+])?:[-\w.]+:{(![A-Z]+)?/,
inside: {
'punctuation': {
pattern: /\$(?:\w:|C(?:\[|#\d))?|[:{[\]]/,
inside: {
'tag': {
pattern: /#\d/
}
}
},
'attribute': {
pattern: /![A-Z]+$/,
inside: {
'punctuation': {
pattern: /!/
}
},
alias: 'keyword'
}
},
alias: 'function'
},
'directive-block-separator': {
pattern: /}:[-\w.]+:{/,
inside: {
'punctuation': {
pattern: /[:{}]/
}
},
alias: 'function'
},
'directive-block-close': {
pattern: /}:[-\w.]+\$/,
inside: {
'punctuation': {
pattern: /[:{}$]/
}
},
alias: 'function'
}
});

Prism.languages.insertBefore('inside', 'punctuation', {
'variable': Prism.languages.xeora['function-inline'].inside['variable']
}, Prism.languages.xeora["function-block"]);

Prism.languages.xeoracube = Prism.languages.xeora;

}(Prism));
1 change: 1 addition & 0 deletions components/prism-xeora.min.js

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

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

<h2>Special Constants</h2>
<pre><code>$DomainContents$
$PageRenderDuration$</code></pre>

<h2>Operators &amp; Variables</h2>
<pre><code>$SearchKey$
$^SearchKey$
$~SearchKey$
$-SearchKey$
$+SearchKey$
$=SearchKey$
$#SearchKey$
$##SearchKey$

$*SearchKey$

[email protected]$
$@#SearchObject.SearchProperty$
[email protected]$</code></pre>

<h2>Controls</h2>
<pre><code>$C:ControlID$
$C:ControlID:{ &lt;!-- Something --&gt; }:ControlID$
$C:ControlID:{ &lt;!-- Something --&gt; }:ControlID:{ &lt;!-- Something (Alternative) --&gt; }:ControlID$

Control with Parent
$C[Control1]:Control2$
$C[Control2]:Control3:{ &lt;!-- Something --&gt; }:Control3$
$C[Control2]:Control3:{ &lt;!-- Something --&gt; }:Control3:{ &lt;!-- Something (Alternative) --&gt; }:Control3$

Control with Parent & Leveling
$C#1[ParentControlID]:ControlID:{ &lt;!-- Something --&gt; }:ControlID$

All Control Tags has leveling specification;
$C:LoopControl1:{
$#FirstLoopSQLField1$

$C:ControlID:{ &lt;!-- Something --&gt; }:ControlID$

$C:LoopControl2:{
$##FirstLoopSQLField1$
$#SecondLoopSQLField1$

$C#1:ControlID:{ &lt;!-- Something --&gt; }:ControlID$
}:LoopControl2$
}:LoopControl1$

XML setup on a Control in Controls.xml
&lt;Control id="[ControlID]"&gt;
&lt;Type&gt;[ControlType]&lt;/Type&gt;

&lt;Bind&gt;[ThemeID|AddonID]?[ControlClass].[FunctionName],SomeOperatorTags(seperated with |)&lt;/Bind&gt;

&lt;BlockIDsToUpdate localupdate="True|False"&gt;
&lt;BlockID&gt;[BlockID]&lt;/BlockID&gt;
&lt;BlockID&gt;[BlockID]&lt;/BlockID&gt;
&lt;BlockID&gt;[BlockID]&lt;/BlockID&gt;
&lt;/BlockIDsToUpdate&gt;

&lt;DefaultButtonID&gt;[ControlID]&lt;/DefaultButtonID&gt;

&lt;Text&gt;[TextBox, Password value or Button Text]&lt;/Text&gt;

&lt;Content&gt;[Textarea Content]&lt;/Content&gt;

&lt;Source&gt;[Image URL]&lt;/Source&gt;

&lt;Url&gt;[Link URL]&lt;/Url&gt;

&lt;Attributes&gt;
&lt;Attribute key="[HTMLAttributeKey]"&gt;[AttributeValue]&lt;/Attributes&gt;
&lt;/Attributes&gt;
&lt;/Control&gt;</code></pre>

<h2>Directives</h2>
<pre><code>$T:TemplateID$
$L:TranslationID$
$P:TemplateID$</code></pre>

<h2>Executable Functions</h2>
<pre><code>$F:AddonLib1?GlobalControls.PrintOutSums$
$F:AddonLib1?GlobalControls.PrintOut,~FormField$
$F:AddonLib1?GlobalControls.SumNumbers,~FormField|=5$</code></pre>

<h2>Client Side Function Binding</h2>
<pre><code>$XF:{AddonLib1?GlobalControls.SumNumbers,~FormField|=5}:XF$</code></pre>

<h2>Inline Statements</h2>
<pre><code>$S:StatementID:{ &lt;!-- C# Code --&gt; }:StatementID$
$S:StatementID:{!NOCACHE &lt;!-- C# Code --&gt; }:StatementID$

$S:Statement1:{
int intvalue1 = 5;
int intvalue2 = Integer.Parse("0" + $~FormValue$);

return intvalue1 * intvalue2;
}:Statement1$</code></pre>

<h2>Request Blocks</h2>
<pre><code>$H:RequestBlockID:{ &lt;!-- Something --&gt; }:RequestBlockID$
$H:RequestBlockID:{!RENDERONREQUEST &lt;!-- Something --&gt; }:RequestBlockID$</code></pre>

<h2>Cache Block</h2>
<pre><code>$PC:{ &lt;!-- Page Content Part --&gt; }:PC$</code></pre>

<h2>Message Handling Block</h2>
<pre><code>$MB:{ &lt;!-- Message Output Content --&gt; }:MB$
$MB:{
$#Message$
$#MessageType$
}:MB$</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","arduino":"cpp","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","flow":"javascript","glsl":"clike","go":"clike","groovy":"clike","haml":"ruby","handlebars":"markup","haxe":"clike","java":"clike","jolie":"clike","kotlin":"clike","less":"css","markdown":"markup","n4js":"javascript","nginx":"clike","objectivec":"c","opencl":"cpp","parser":"markup","php":"clike","php-extras":"php","processing":"clike","protobuf":"clike","pug":"javascript","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","arduino":"cpp","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","flow":"javascript","glsl":"clike","go":"clike","groovy":"clike","haml":"ruby","handlebars":"markup","haxe":"clike","java":"clike","jolie":"clike","kotlin":"clike","less":"css","markdown":"markup","n4js":"javascript","nginx":"clike","objectivec":"c","opencl":"cpp","parser":"markup","php":"clike","php-extras":"php","processing":"clike","protobuf":"clike","pug":"javascript","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","xeora":"markup","wiki":"markup"}/*]*/;

var lang_data = {};

Expand Down
15 changes: 15 additions & 0 deletions tests/languages/xeora/constant_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$DomainContents$
$PageRenderDuration$

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

[
["constant", [
["punctuation", "$"], "DomainContents", ["punctuation", "$"]]],
["constant", [
["punctuation", "$"], "PageRenderDuration", ["punctuation", "$"]]]
]

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

Checks for constants.
12 changes: 12 additions & 0 deletions tests/languages/xeora/directive-block-close_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
}:Control3$

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

[
["directive-block-close", [
["punctuation", "}"], ["punctuation", ":"], "Control3", ["punctuation", "$"]]]
]

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

Checks for directive-block-closes.
30 changes: 30 additions & 0 deletions tests/languages/xeora/directive-block-open_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$C:Control2:{
$C#1:Control2:{
$C[ParentControl]:Control2:{
$C#1[ParentControl]:Control2:{
$S:Statement:{!NOCACHE
$H:HttpRequest:{!RENDERONREQUEST
$C:Control2:{!MESSAGETEMPLATE

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

[
["directive-block-open", [
["punctuation", ["$C:"]], "Control2", ["punctuation", [":"]], ["punctuation", ["{"]]]],
["directive-block-open", [
["punctuation", ["$C", ["tag", "#1"]]], ["punctuation", [":"]], "Control2", ["punctuation", [":"]], ["punctuation", ["{"]]]],
["directive-block-open", [
["punctuation", ["$C["]], "ParentControl", ["punctuation", ["]"]], ["punctuation", [":"]], "Control2", ["punctuation", [":"]], ["punctuation", ["{"]]]],
["directive-block-open", [
["punctuation", ["$C", ["tag", "#1"]]], ["punctuation", ["["]], "ParentControl", ["punctuation", ["]"]], ["punctuation", [":"]], "Control2", ["punctuation", [":"]], ["punctuation", ["{"]]]],
["directive-block-open", [
["punctuation", ["$S:"]], "Statement", ["punctuation", [":"]], ["punctuation", ["{"]], ["attribute", [["punctuation", "!"], "NOCACHE"]]]],
["directive-block-open", [
["punctuation", ["$H:"]], "HttpRequest", ["punctuation", [":"]], ["punctuation", ["{"]], ["attribute", [["punctuation", "!"], "RENDERONREQUEST"]]]],
["directive-block-open", [
["punctuation", ["$C:"]], "Control2", ["punctuation", [":"]], ["punctuation", ["{"]], ["attribute", [["punctuation", "!"], "MESSAGETEMPLATE"]]]]
]

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

Checks for directive-block-opens.
17 changes: 17 additions & 0 deletions tests/languages/xeora/directive-block-separator_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
}:Control3:{

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

[
["directive-block-separator", [
["punctuation", "}"],
["punctuation", ":"],
"Control3",
["punctuation", ":"],
["punctuation", "{"]
]]
]

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

Checks for functions.
21 changes: 21 additions & 0 deletions tests/languages/xeora/directive-inline_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
$C:Control2$
$C#1:Control2$
$C[ParentControl]:Control2$
$C#1[ParentControl]:Control2$

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

[
["directive-inline", [
["punctuation", ["$C:"]], "Control2", ["punctuation", ["$"]]]],
["directive-inline", [
["punctuation", ["$C", ["tag", "#1"]]], ["punctuation", [":"]], "Control2", ["punctuation", ["$"]]]],
["directive-inline", [
["punctuation", ["$C["]], "ParentControl", ["punctuation", ["]"]], ["punctuation", [":"]], "Control2", ["punctuation", ["$"]]]],
["directive-inline", [
["punctuation", ["$C", ["tag", "#1"]]], ["punctuation", ["["]], "ParentControl", ["punctuation", ["]"]], ["punctuation", [":"]], "Control2", ["punctuation", ["$"]]]]
]

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

Checks for directive-inlines.
Loading