Added support for AQL (#2025)

This adds support for the AQL language.

https://www.arangodb.com/docs/stable/aql/
This commit is contained in:
Michael Schmidt 2019-09-02 20:08:04 +02:00 committed by GitHub
parent 8ccd258b19
commit 3fdb7d553d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 261 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -104,6 +104,10 @@
"title": "AppleScript",
"owner": "Golmote"
},
"aql": {
"title": "AQL",
"owner": "RunDevelopment"
},
"arduino": {
"title": "Arduino",
"require": "cpp",

23
components/prism-aql.js Normal file
View File

@ -0,0 +1,23 @@
Prism.languages.aql = {
'comment': /\/\/.*|\/\*[\s\S]*?\*\//,
'property': {
pattern: /([{,]\s*)(?:(?!\d)\w+|(["'´`])(?:(?!\2)[^\\\r\n]|\\.)*\2)(?=\s*:)/,
lookbehind: true,
greedy: true
},
'string': {
pattern: /(["'´`])(?:(?!\1)[^\\\r\n]|\\.)*\1/,
greedy: true
},
'variable': /@@?\w+/,
'keyword': /\b(?:AGGREGATE|ALL|AND|ANY|ASC|COLLECT|DESC|DISTINCT|FILTER|FOR|GRAPH|IN|INBOUND|INSERT|INTO|LET|LIKE|LIMIT|NONE|NOT|NULL|OR|OUTBOUND|REMOVE|REPLACE|RETURN|SHORTEST_PATH|SORT|UPDATE|UPSERT|WITH)\b/i,
'function': /(?!\d)\w+(?=\s*\()/,
'boolean': /(?:true|false)/i,
'range': {
pattern: /\.\./,
alias: 'operator'
},
'number': /(?:\B\.\d+|\b\d+(?:\.\d+)?)(?:e[+-]?\d+)?/i,
'operator': /\*\*|[=!]~|[!=<>]=?|&&|\|\||[-+*/%]/,
'punctuation': /::|[?.:,;()[\]{}]/
};

1
components/prism-aql.min.js vendored Normal file
View File

@ -0,0 +1 @@
Prism.languages.aql={comment:/\/\/.*|\/\*[\s\S]*?\*\//,property:{pattern:/([{,]\s*)(?:(?!\d)\w+|(["'´`])(?:(?!\2)[^\\\r\n]|\\.)*\2)(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(["'´`])(?:(?!\1)[^\\\r\n]|\\.)*\1/,greedy:!0},variable:/@@?\w+/,keyword:/\b(?:AGGREGATE|ALL|AND|ANY|ASC|COLLECT|DESC|DISTINCT|FILTER|FOR|GRAPH|IN|INBOUND|INSERT|INTO|LET|LIKE|LIMIT|NONE|NOT|NULL|OR|OUTBOUND|REMOVE|REPLACE|RETURN|SHORTEST_PATH|SORT|UPDATE|UPSERT|WITH)\b/i,function:/(?!\d)\w+(?=\s*\()/,boolean:/(?:true|false)/i,range:{pattern:/\.\./,alias:"operator"},number:/(?:\B\.\d+|\b\d+(?:\.\d+)?)(?:e[+-]?\d+)?/i,operator:/\*\*|[=!]~|[!=<>]=?|&&|\|\||[-+*/%]/,punctuation:/::|[?.:,;()[\]{}]/};

17
examples/prism-aql.html Normal file
View File

@ -0,0 +1,17 @@
<h2>Full example</h2>
<pre><code>FOR u IN users
FOR f IN friends
FILTER u.active == @active && f.active == true && u.id == f.userId
RETURN { "name" : u.name, "friends" : friends }
LET name = "Peter"
LET age = 42
RETURN { name, age }
FOR u IN users
FILTER u.status == "not active"
UPDATE u WITH { status: "inactive" } IN users
FOR i IN 1..100
INSERT { value: i } IN test
RETURN NEW</code></pre>

View File

@ -23,6 +23,7 @@
"abnf": "Augmented BackusNaur form",
"apacheconf": "Apache Configuration",
"apl": "APL",
"aql": "AQL",
"arff": "ARFF",
"asciidoc": "AsciiDoc",
"adoc": "AsciiDoc",

View File

@ -1 +1 @@
!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var i={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"Augmented BackusNaur form",apacheconf:"Apache Configuration",apl:"APL",arff:"ARFF",asciidoc:"AsciiDoc",adoc:"AsciiDoc",asm6502:"6502 Assembly",aspnet:"ASP.NET (C#)",autohotkey:"AutoHotkey",autoit:"AutoIt",shell:"Bash",basic:"BASIC",bnf:"BackusNaur form",rbnf:"Routing BackusNaur form",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",coffee:"CoffeeScript",cmake:"CMake",csp:"Content-Security-Policy","css-extras":"CSS Extras",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"Extended BackusNaur form",ejs:"EJS",erb:"ERB",fsharp:"F#","firestore-security-rules":"Firestore security rules",gcode:"G-code",gdscript:"GDScript",gedcom:"GEDCOM",glsl:"GLSL",gml:"GameMaker Language",gamemakerlanguage:"GameMaker Language",graphql:"GraphQL",hs:"Haskell",hcl:"HCL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",inform7:"Inform 7",javadoc:"JavaDoc",javadoclike:"JavaDoc-like",javastacktrace:"Java stack trace",jq:"JQ",jsdoc:"JSDoc","js-extras":"JS Extras","js-templates":"JS Templates",json:"JSON",jsonp:"JSONP",json5:"JSON5",latex:"LaTeX",tex:"TeX",context:"ConTeXt",lilypond:"LilyPond",ly:"LilyPond",emacs:"Lisp",elisp:"Lisp","emacs-lisp":"Lisp",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",nasm:"NASM",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",objectpascal:"Object Pascal",pcaxis:"PC-Axis",px:"PC-Axis",php:"PHP",phpdoc:"PHPDoc","php-extras":"PHP Extras",plsql:"PL/SQL",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",py:"Python",q:"Q (kdb+ database)",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rest:"reST (reStructuredText)",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session",soy:"Soy (Closure Template)","splunk-spl":"Splunk SPL",sql:"SQL",tap:"TAP",toml:"TOML",tt2:"Template Toolkit 2",trig:"TriG",ts:"TypeScript","t4-cs":"T4 Text Templates (C#)",t4:"T4 Text Templates (C#)","t4-vb":"T4 Text Templates (VB)","t4-templating":"T4 templating",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",vb:"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xeoracube:"XeoraCube",xojo:"Xojo (REALbasic)",xquery:"XQuery",yaml:"YAML",yml:"YAML"};Prism.plugins.toolbar.registerButton("show-language",function(e){var a=e.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var s,t=a.getAttribute("data-language")||i[e.language]||((s=e.language)?(s.substring(0,1).toUpperCase()+s.substring(1)).replace(/s(?=cript)/,"S"):s);if(t){var o=document.createElement("span");return o.textContent=t,o}}})}else console.warn("Show Languages plugin loaded before Toolbar plugin.")}();
!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var i={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"Augmented BackusNaur form",apacheconf:"Apache Configuration",apl:"APL",aql:"AQL",arff:"ARFF",asciidoc:"AsciiDoc",adoc:"AsciiDoc",asm6502:"6502 Assembly",aspnet:"ASP.NET (C#)",autohotkey:"AutoHotkey",autoit:"AutoIt",shell:"Bash",basic:"BASIC",bnf:"BackusNaur form",rbnf:"Routing BackusNaur form",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",coffee:"CoffeeScript",cmake:"CMake",csp:"Content-Security-Policy","css-extras":"CSS Extras",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"Extended BackusNaur form",ejs:"EJS",erb:"ERB",fsharp:"F#","firestore-security-rules":"Firestore security rules",gcode:"G-code",gdscript:"GDScript",gedcom:"GEDCOM",glsl:"GLSL",gml:"GameMaker Language",gamemakerlanguage:"GameMaker Language",graphql:"GraphQL",hs:"Haskell",hcl:"HCL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",inform7:"Inform 7",javadoc:"JavaDoc",javadoclike:"JavaDoc-like",javastacktrace:"Java stack trace",jq:"JQ",jsdoc:"JSDoc","js-extras":"JS Extras","js-templates":"JS Templates",json:"JSON",jsonp:"JSONP",json5:"JSON5",latex:"LaTeX",tex:"TeX",context:"ConTeXt",lilypond:"LilyPond",ly:"LilyPond",emacs:"Lisp",elisp:"Lisp","emacs-lisp":"Lisp",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",nasm:"NASM",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",objectpascal:"Object Pascal",pcaxis:"PC-Axis",px:"PC-Axis",php:"PHP",phpdoc:"PHPDoc","php-extras":"PHP Extras",plsql:"PL/SQL",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",py:"Python",q:"Q (kdb+ database)",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rest:"reST (reStructuredText)",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session",soy:"Soy (Closure Template)","splunk-spl":"Splunk SPL",sql:"SQL",tap:"TAP",toml:"TOML",tt2:"Template Toolkit 2",trig:"TriG",ts:"TypeScript","t4-cs":"T4 Text Templates (C#)",t4:"T4 Text Templates (C#)","t4-vb":"T4 Text Templates (VB)","t4-templating":"T4 templating",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",vb:"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xeoracube:"XeoraCube",xojo:"Xojo (REALbasic)",xquery:"XQuery",yaml:"YAML",yml:"YAML"};Prism.plugins.toolbar.registerButton("show-language",function(e){var a=e.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var s,t=a.getAttribute("data-language")||i[e.language]||((s=e.language)?(s.substring(0,1).toUpperCase()+s.substring(1)).replace(/s(?=cript)/,"S"):s);if(t){var o=document.createElement("span");return o.textContent=t,o}}})}else console.warn("Show Languages plugin loaded before Toolbar plugin.")}();

View File

@ -0,0 +1,16 @@
// single line
/*
multi
line
*/
----------------------------------------------------
[
["comment", "// single line"],
["comment", "/*\r\n multi\r\n line\r\n */"]
]
----------------------------------------------------
Checks for comments.

View File

@ -0,0 +1,25 @@
1
42
1.23
99.99
0.5
.5
4.87e103
4.87E103
----------------------------------------------------
[
["number", "1"],
["number", "42"],
["number", "1.23"],
["number", "99.99"],
["number", "0.5"],
["number", ".5"],
["number", "4.87e103"],
["number", "4.87E103"]
]
----------------------------------------------------
Checks for numbers.

View File

@ -0,0 +1,49 @@
+ - * / %
> >= <= < == != =
!~ =~
! && ||
[**]
..
1..100
----------------------------------------------------
[
["operator", "+"],
["operator", "-"],
["operator", "*"],
["operator", "/"],
["operator", "%"],
["operator", ">"],
["operator", ">="],
["operator", "<="],
["operator", "<"],
["operator", "=="],
["operator", "!="],
["operator", "="],
["operator", "!~"],
["operator", "=~"],
["operator", "!"],
["operator", "&&"],
["operator", "||"],
["punctuation", "["],
["operator", "**"],
["punctuation", "]"],
["range", ".."],
["number", "1"],
["range", ".."],
["number", "100"]
]
----------------------------------------------------
Checks for operators.

View File

@ -0,0 +1,60 @@
{ foo: … }
{ 'foo': … }
{ "foo": … }
{ `foo`: … }
{ ´foo´: … }
// not a property
LET opType = IS_NULL(OLD) ? "insert" : "update"
----------------------------------------------------
[
["punctuation", "{"],
["property", "foo"],
["punctuation", ":"],
" … ",
["punctuation", "}"],
["punctuation", "{"],
["property", "'foo'"],
["punctuation", ":"],
" … ",
["punctuation", "}"],
["punctuation", "{"],
["property", "\"foo\""],
["punctuation", ":"],
" … ",
["punctuation", "}"],
["punctuation", "{"],
["property", "`foo`"],
["punctuation", ":"],
" … ",
["punctuation", "}"],
["punctuation", "{"],
["property", "´foo´"],
["punctuation", ":"],
" … ",
["punctuation", "}"],
["comment", "// not a property"],
["keyword", "LET"],
" opType ",
["operator", "="],
["function", "IS_NULL"],
["punctuation", "("],
"OLD",
["punctuation", ")"],
["punctuation", "?"],
["string", "\"insert\""],
["punctuation", ":"],
["string", "\"update\""]
]
----------------------------------------------------
Checks for properties. (beware of ternary operators)

View File

@ -0,0 +1,35 @@
"yikes!"
"don't know"
"this is a \"quoted\" word"
"this is a longer string."
"the path separator on Windows is \\"
'yikes!'
'don\'t know'
'this is a "quoted" word'
'this is a longer string.'
'the path separator on Windows is \\'
´filter´
`sort`
----------------------------------------------------
[
["string", "\"yikes!\""],
["string", "\"don't know\""],
["string", "\"this is a \\\"quoted\\\" word\""],
["string", "\"this is a longer string.\""],
["string", "\"the path separator on Windows is \\\\\""],
["string", "'yikes!'"],
["string", "'don\\'t know'"],
["string", "'this is a \"quoted\" word'"],
["string", "'this is a longer string.'"],
["string", "'the path separator on Windows is \\\\'"],
["string", "´filter´"],
["string", "`sort`"]
]
----------------------------------------------------
Checks for strings.

View File

@ -0,0 +1,28 @@
FILTER u.id == @id && u.name == @name
FOR u IN @@collection
----------------------------------------------------
[
["keyword", "FILTER"],
" u",
["punctuation", "."],
"id ",
["operator", "=="],
["variable", "@id"],
["operator", "&&"],
" u",
["punctuation", "."],
"name ",
["operator", "=="],
["variable", "@name"],
["keyword", "FOR"],
" u ",
["keyword", "IN"],
["variable", "@@collection"]
]
----------------------------------------------------
Checks for variable binds.