From 55b837f51290c56c08ce30cac1c0ca79635bab31 Mon Sep 17 00:00:00 2001 From: Cassie Jones Date: Thu, 20 Feb 2020 18:44:07 +0100 Subject: [PATCH 1/3] Add support for LLVM IR LLVM IR has tons of keywords, has prefixed variables, and is relatively unstable, so it makes sense to consider everything outside of a small set of exceptions to be keywords. --- components.js | 2 +- components.json | 4 + components/prism-llvm.js | 12 ++ components/prism-llvm.min.js | 1 + examples/prism-llvm.html | 23 ++++ plugins/show-language/prism-show-language.js | 1 + .../show-language/prism-show-language.min.js | 2 +- tests/languages/llvm/attributes.test | 47 +++++++ tests/languages/llvm/example-iterative.test | 113 +++++++++++++++++ tests/languages/llvm/example-recursive.test | 87 +++++++++++++ .../llvm/langref-module-example.test | 115 ++++++++++++++++++ 11 files changed, 405 insertions(+), 2 deletions(-) create mode 100644 components/prism-llvm.js create mode 100644 components/prism-llvm.min.js create mode 100644 examples/prism-llvm.html create mode 100644 tests/languages/llvm/attributes.test create mode 100644 tests/languages/llvm/example-iterative.test create mode 100644 tests/languages/llvm/example-recursive.test create mode 100644 tests/languages/llvm/langref-module-example.test diff --git a/components.js b/components.js index 9d8ca0e43f..4a5b2806e3 100644 --- a/components.js +++ b/components.js @@ -1,2 +1,2 @@ -var components = {"core":{"meta":{"path":"components/prism-core.js","option":"mandatory"},"core":"Core"},"themes":{"meta":{"path":"themes/{id}.css","link":"index.html?theme={id}","exclusive":true},"prism":{"title":"Default","option":"default"},"prism-dark":"Dark","prism-funky":"Funky","prism-okaidia":{"title":"Okaidia","owner":"ocodia"},"prism-twilight":{"title":"Twilight","owner":"remybach"},"prism-coy":{"title":"Coy","owner":"tshedor"},"prism-solarizedlight":{"title":"Solarized Light","owner":"hectormatos2011 "},"prism-tomorrow":{"title":"Tomorrow Night","owner":"Rosey"}},"languages":{"meta":{"path":"components/prism-{id}","noCSS":true,"examplesPath":"examples/prism-{id}","addCheckAll":true},"markup":{"title":"Markup","alias":["html","xml","svg","mathml"],"aliasTitles":{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML"},"option":"default"},"css":{"title":"CSS","option":"default","modify":"markup"},"clike":{"title":"C-like","option":"default"},"javascript":{"title":"JavaScript","require":"clike","modify":"markup","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"abnf":{"title":"Augmented Backus–Naur form","owner":"RunDevelopment"},"actionscript":{"title":"ActionScript","require":"javascript","modify":"markup","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"antlr4":{"title":"ANTLR4","alias":"g4","owner":"RunDevelopment"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"aql":{"title":"AQL","owner":"RunDevelopment"},"arduino":{"title":"Arduino","require":"cpp","owner":"eisbehr-"},"arff":{"title":"ARFF","owner":"Golmote"},"asciidoc":{"alias":"adoc","title":"AsciiDoc","owner":"Golmote"},"asm6502":{"title":"6502 Assembly","owner":"kzurawel"},"aspnet":{"title":"ASP.NET (C#)","require":["markup","csharp"],"owner":"nauzilus"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"bash":{"title":"Bash","alias":"shell","aliasTitles":{"shell":"Shell"},"owner":"zeitgeist87"},"basic":{"title":"BASIC","owner":"Golmote"},"batch":{"title":"Batch","owner":"Golmote"},"bbcode":{"title":"BBcode","owner":"RunDevelopment"},"bison":{"title":"Bison","require":"c","owner":"Golmote"},"bnf":{"title":"Backus–Naur form","alias":"rbnf","aliasTitles":{"rbnf":"Routing Backus–Naur form"},"owner":"RunDevelopment"},"brainfuck":{"title":"Brainfuck","owner":"Golmote"},"brightscript":{"title":"BrightScript","owner":"RunDevelopment"},"bro":{"title":"Bro","owner":"wayward710"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"concurnas":{"title":"Concurnas","alias":"conc","owner":"jasontatton"},"csharp":{"title":"C#","require":"clike","alias":["cs","dotnet"],"owner":"mvalipour"},"cpp":{"title":"C++","require":"c","owner":"zeitgeist87"},"cil":{"title":"CIL","owner":"sbrl"},"coffeescript":{"title":"CoffeeScript","require":"javascript","alias":"coffee","owner":"R-osey"},"cmake":{"title":"CMake","owner":"mjrogozinski"},"clojure":{"title":"Clojure","owner":"troglotit"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"css-extras":{"title":"CSS Extras","require":"css","modify":"css","owner":"milesj"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"dax":{"title":"DAX","owner":"peterbud"},"diff":{"title":"Diff","owner":"uranusjr"},"django":{"title":"Django/Jinja2","require":"markup-templating","alias":"jinja2","owner":"romanvm"},"dns-zone-file":{"title":"DNS zone file","owner":"RunDevelopment","alias":"dns-zone"},"docker":{"title":"Docker","alias":"dockerfile","owner":"JustinBeckwith"},"ebnf":{"title":"Extended Backus–Naur form","owner":"RunDevelopment"},"eiffel":{"title":"Eiffel","owner":"Conaclos"},"ejs":{"title":"EJS","require":["javascript","markup-templating"],"owner":"RunDevelopment"},"elixir":{"title":"Elixir","owner":"Golmote"},"elm":{"title":"Elm","owner":"zwilias"},"etlua":{"title":"Embedded Lua templating","require":["lua","markup-templating"],"owner":"RunDevelopment"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"excel-formula":{"title":"Excel Formula","alias":["xlsx","xls"],"owner":"RunDevelopment"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"factor":{"title":"Factor","owner":"catb0t"},"firestore-security-rules":{"title":"Firestore security rules","require":"clike","owner":"RunDevelopment"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"ftl":{"title":"FreeMarker Template Language","require":"markup-templating","owner":"RunDevelopment"},"gcode":{"title":"G-code","owner":"RunDevelopment"},"gdscript":{"title":"GDScript","owner":"RunDevelopment"},"gedcom":{"title":"GEDCOM","owner":"Golmote"},"gherkin":{"title":"Gherkin","owner":"hason"},"git":{"title":"Git","owner":"lgiraudel"},"glsl":{"title":"GLSL","require":"clike","owner":"Golmote"},"gml":{"title":"GameMaker Language","alias":"gamemakerlanguage","require":"clike","owner":"LiarOnce"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"graphql":{"title":"GraphQL","owner":"Golmote"},"groovy":{"title":"Groovy","require":"clike","owner":"robfletcher"},"haml":{"title":"Haml","require":"ruby","optional":["css","css-extras","coffeescript","erb","javascript","less","markdown","scss","textile"],"owner":"Golmote"},"handlebars":{"title":"Handlebars","require":"markup-templating","owner":"Golmote"},"haskell":{"title":"Haskell","alias":"hs","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","owner":"Golmote"},"hcl":{"title":"HCL","owner":"outsideris"},"http":{"title":"HTTP","optional":["css","javascript","json","markup"],"owner":"danielgtaylor"},"hpkp":{"title":"HTTP Public-Key-Pins","owner":"ScottHelme"},"hsts":{"title":"HTTP Strict-Transport-Security","owner":"ScottHelme"},"ichigojam":{"title":"IchigoJam","owner":"BlueCocoa"},"icon":{"title":"Icon","owner":"Golmote"},"inform7":{"title":"Inform 7","owner":"Golmote"},"ini":{"title":"Ini","owner":"aviaryan"},"io":{"title":"Io","owner":"AlesTsurko"},"j":{"title":"J","owner":"Golmote"},"java":{"title":"Java","require":"clike","owner":"sherblot"},"javadoc":{"title":"JavaDoc","require":["markup","java","javadoclike"],"modify":"java","optional":"scala","owner":"RunDevelopment"},"javadoclike":{"title":"JavaDoc-like","modify":["java","javascript","php"],"owner":"RunDevelopment"},"javastacktrace":{"title":"Java stack trace","owner":"RunDevelopment"},"jolie":{"title":"Jolie","require":"clike","owner":"thesave"},"jq":{"title":"JQ","owner":"RunDevelopment"},"jsdoc":{"title":"JSDoc","require":["javascript","javadoclike"],"modify":"javascript","optional":["actionscript","coffeescript"],"owner":"RunDevelopment"},"js-extras":{"title":"JS Extras","require":"javascript","modify":"javascript","optional":["actionscript","coffeescript","flow","n4js","typescript"],"owner":"RunDevelopment"},"js-templates":{"title":"JS Templates","require":"javascript","modify":"javascript","optional":["css","css-extras","graphql","markdown","markup"],"owner":"RunDevelopment"},"json":{"title":"JSON","owner":"CupOfTea696"},"jsonp":{"title":"JSONP","require":"json","owner":"RunDevelopment"},"json5":{"title":"JSON5","require":"json","owner":"RunDevelopment"},"julia":{"title":"Julia","owner":"cdagnino"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","require":"clike","owner":"Golmote"},"latex":{"title":"LaTeX","alias":["tex","context"],"aliasTitles":{"tex":"TeX","context":"ConTeXt"},"owner":"japborst"},"latte":{"title":"Latte","require":["clike","markup-templating","php"],"owner":"nette"},"less":{"title":"Less","require":"css","optional":"css-extras","owner":"Golmote"},"lilypond":{"title":"LilyPond","require":"scheme","alias":"ly","owner":"RunDevelopment"},"liquid":{"title":"Liquid","owner":"cinhtau"},"lisp":{"title":"Lisp","alias":["emacs","elisp","emacs-lisp"],"owner":"JuanCaicedo"},"livescript":{"title":"LiveScript","owner":"Golmote"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"makefile":{"title":"Makefile","owner":"Golmote"},"markdown":{"title":"Markdown","require":"markup","alias":"md","owner":"Golmote"},"markup-templating":{"title":"Markup templating","require":"markup","owner":"Golmote"},"matlab":{"title":"MATLAB","owner":"Golmote"},"mel":{"title":"MEL","owner":"Golmote"},"mizar":{"title":"Mizar","owner":"Golmote"},"monkey":{"title":"Monkey","owner":"Golmote"},"moonscript":{"title":"MoonScript","alias":"moon","owner":"RunDevelopment"},"n1ql":{"title":"N1QL","owner":"TMWilds"},"n4js":{"title":"N4JS","require":"javascript","optional":"jsdoc","alias":"n4jsd","owner":"bsmith-n4"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","owner":"stephanmax"},"nasm":{"title":"NASM","owner":"rbmj"},"neon":{"title":"NEON","owner":"nette"},"nginx":{"title":"nginx","owner":"westonganger","require":"clike"},"nim":{"title":"Nim","owner":"Golmote"},"nix":{"title":"Nix","owner":"Golmote"},"nsis":{"title":"NSIS","owner":"idleberg"},"objectivec":{"title":"Objective-C","require":"c","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"c","modify":["c","cpp"],"owner":"Milania1"},"oz":{"title":"Oz","owner":"Golmote"},"parigp":{"title":"PARI/GP","owner":"Golmote"},"parser":{"title":"Parser","require":"markup","owner":"Golmote"},"pascal":{"title":"Pascal","alias":"objectpascal","aliasTitles":{"objectpascal":"Object Pascal"},"owner":"Golmote"},"pascaligo":{"title":"Pascaligo","owner":"DefinitelyNotAGoat"},"pcaxis":{"title":"PC-Axis","alias":"px","owner":"RunDevelopment"},"perl":{"title":"Perl","owner":"Golmote"},"php":{"title":"PHP","require":["clike","markup-templating"],"owner":"milesj"},"phpdoc":{"title":"PHPDoc","require":["php","javadoclike"],"modify":"php","owner":"RunDevelopment"},"php-extras":{"title":"PHP Extras","require":"php","modify":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"powerquery":{"title":"PowerQuery","alias":["pq","mscript"],"owner":"peterbud"},"powershell":{"title":"PowerShell","owner":"nauzilus"},"processing":{"title":"Processing","require":"clike","owner":"Golmote"},"prolog":{"title":"Prolog","owner":"Golmote"},"properties":{"title":".properties","owner":"Golmote"},"protobuf":{"title":"Protocol Buffers","require":"clike","owner":"just-boris"},"pug":{"title":"Pug","require":["markup","javascript"],"optional":["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],"owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","optional":["c","cpp","fortran"],"owner":"Golmote"},"python":{"title":"Python","alias":"py","owner":"multipetros"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qml":{"title":"QML","require":"javascript","owner":"RunDevelopment"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"jsx":{"title":"React JSX","require":["markup","javascript"],"optional":["jsdoc","js-extras","js-templates"],"owner":"vkbansal"},"tsx":{"title":"React TSX","require":["jsx","typescript"]},"renpy":{"title":"Ren'py","owner":"HyuchiaDiego"},"reason":{"title":"Reason","require":"clike","owner":"Golmote"},"regex":{"title":"Regex","modify":["actionscript","coffeescript","flow","javascript","typescript","vala"],"owner":"RunDevelopment"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"robotframework":{"title":"Robot Framework","alias":"robot","owner":"RunDevelopment"},"ruby":{"title":"Ruby","require":"clike","alias":"rb","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","optional":["groovy","lua","sql"],"owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","optional":"css-extras","owner":"MoOx"},"scala":{"title":"Scala","require":"java","owner":"jozic"},"scheme":{"title":"Scheme","owner":"bacchus123"},"shell-session":{"title":"Shell session","require":"bash","owner":"RunDevelopment"},"smalltalk":{"title":"Smalltalk","owner":"Golmote"},"smarty":{"title":"Smarty","require":"markup-templating","owner":"Golmote"},"solidity":{"title":"Solidity (Ethereum)","require":"clike","owner":"glachaud"},"solution-file":{"title":"Solution file","alias":"sln","owner":"RunDevelopment"},"soy":{"title":"Soy (Closure Template)","require":"markup-templating","owner":"Golmote"},"sparql":{"title":"SPARQL","require":"turtle","owner":"Triply-Dev","alias":"rq"},"splunk-spl":{"title":"Splunk SPL","owner":"RunDevelopment"},"sqf":{"title":"SQF: Status Quo Function (Arma 3)","require":"clike","owner":"RunDevelopment"},"sql":{"title":"SQL","owner":"multipetros"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","require":"clike","owner":"chrischares"},"tap":{"title":"TAP","owner":"isaacs","require":"yaml"},"tcl":{"title":"Tcl","owner":"PeterChaplin"},"textile":{"title":"Textile","require":"markup","optional":"css","owner":"Golmote"},"toml":{"title":"TOML","owner":"RunDevelopment"},"tt2":{"title":"Template Toolkit 2","require":["clike","markup-templating"],"owner":"gflohr"},"turtle":{"title":"Turtle","alias":"trig","aliasTitles":{"trig":"TriG"},"owner":"jakubklimek"},"twig":{"title":"Twig","require":"markup","owner":"brandonkelly"},"typescript":{"title":"TypeScript","require":"javascript","optional":"js-templates","alias":"ts","owner":"vkbansal"},"t4-cs":{"title":"T4 Text Templates (C#)","require":["t4-templating","csharp"],"alias":"t4","owner":"RunDevelopment"},"t4-vb":{"title":"T4 Text Templates (VB)","require":["t4-templating","visual-basic"],"owner":"RunDevelopment"},"t4-templating":{"title":"T4 templating","owner":"RunDevelopment"},"vala":{"title":"Vala","require":"clike","owner":"TemplarVolk"},"vbnet":{"title":"VB.Net","require":"basic","owner":"Bigsby"},"velocity":{"title":"Velocity","require":"markup","owner":"Golmote"},"verilog":{"title":"Verilog","owner":"a-rey"},"vhdl":{"title":"VHDL","owner":"a-rey"},"vim":{"title":"vim","owner":"westonganger"},"visual-basic":{"title":"Visual Basic","alias":"vb","owner":"Golmote"},"wasm":{"title":"WebAssembly","owner":"Golmote"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"xeora":{"title":"Xeora","require":"markup","alias":"xeoracube","aliasTitles":{"xeoracube":"XeoraCube"},"owner":"freakmaxi"},"xojo":{"title":"Xojo (REALbasic)","owner":"Golmote"},"xquery":{"title":"XQuery","require":"markup","owner":"Golmote"},"yaml":{"title":"YAML","alias":"yml","owner":"hason"},"zig":{"title":"Zig","owner":"RunDevelopment"}},"plugins":{"meta":{"path":"plugins/{id}/prism-{id}","link":"plugins/{id}/"},"line-highlight":{"title":"Line Highlight","description":"Highlights specific lines and/or line ranges."},"line-numbers":{"title":"Line Numbers","description":"Line number at the beginning of code lines.","owner":"kuba-kubula"},"show-invisibles":{"title":"Show Invisibles","description":"Show hidden characters such as tabs and line breaks.","optional":["autolinker","data-uri-highlight"]},"autolinker":{"title":"Autolinker","description":"Converts URLs and emails in code to clickable links. Parses Markdown links in comments."},"wpd":{"title":"WebPlatform Docs","description":"Makes tokens link to WebPlatform.org documentation. The links open in a new tab."},"custom-class":{"title":"Custom Class","description":"This plugin allows you to prefix Prism's default classes (.comment can become .namespace--comment) or replace them with your defined ones (like .editor__comment). You can even add new classes.","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","description":"Fetch external files and highlight them with Prism. Used on the Prism website itself.","noCSS":true},"show-language":{"title":"Show Language","description":"Display the highlighted language in code blocks (inline code does not show the label).","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","description":"Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","description":"Adds special CSS classes for each keyword matched in the code. For example, the keyword if will have the class keyword-if as well. You can have fine grained control over the appearance of each keyword by providing your own CSS rules.","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","description":"Removes the initial line feed in code blocks.","owner":"Golmote","noCSS":true},"inline-color":{"title":"Inline color","description":"Adds a small inline preview for colors in style sheets.","require":"css-extras","owner":"RunDevelopment"},"previewers":{"title":"Previewers","description":"Previewers for angles, colors, gradients, easing and time.","require":"css-extras","owner":"Golmote"},"autoloader":{"title":"Autoloader","description":"Automatically loads the needed languages to highlight the code blocks.","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","description":"Prevents custom markup from being dropped out during highlighting.","owner":"Golmote","optional":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","description":"Display a command line with a prompt and, optionally, the output/response from the commands.","owner":"chriswells0"},"unescaped-markup":{"title":"Unescaped Markup","description":"Write markup without having to escape anything."},"normalize-whitespace":{"title":"Normalize Whitespace","description":"Supports multiple operations to normalize whitespace in code blocks.","owner":"zeitgeist87","optional":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","description":"Highlights data-URI contents.","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","description":"Attach a toolbar for plugins to easily register buttons on the top of a code block.","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","description":"Add a button that copies the code block to the clipboard when clicked.","owner":"mAAdhaTTah","require":"toolbar","noCSS":true},"download-button":{"title":"Download Button","description":"A button in the toolbar of a code block adding a convenient way to download a code file.","owner":"Golmote","require":"toolbar","noCSS":true},"match-braces":{"title":"Match braces","description":"Highlights matching braces.","owner":"RunDevelopment"},"diff-highlight":{"title":"Diff Highlight","description":"Highlights the code inside diff blocks.","owner":"RunDevelopment","require":"diff"},"filter-highlight-all":{"title":"Filter highlightAll","description":"Filters the elements the highlightAll and highlightAllUnder methods actually highlight.","owner":"RunDevelopment","noCSS":true}}}; +var components = {"core":{"meta":{"path":"components/prism-core.js","option":"mandatory"},"core":"Core"},"themes":{"meta":{"path":"themes/{id}.css","link":"index.html?theme={id}","exclusive":true},"prism":{"title":"Default","option":"default"},"prism-dark":"Dark","prism-funky":"Funky","prism-okaidia":{"title":"Okaidia","owner":"ocodia"},"prism-twilight":{"title":"Twilight","owner":"remybach"},"prism-coy":{"title":"Coy","owner":"tshedor"},"prism-solarizedlight":{"title":"Solarized Light","owner":"hectormatos2011 "},"prism-tomorrow":{"title":"Tomorrow Night","owner":"Rosey"}},"languages":{"meta":{"path":"components/prism-{id}","noCSS":true,"examplesPath":"examples/prism-{id}","addCheckAll":true},"markup":{"title":"Markup","alias":["html","xml","svg","mathml"],"aliasTitles":{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML"},"option":"default"},"css":{"title":"CSS","option":"default","modify":"markup"},"clike":{"title":"C-like","option":"default"},"javascript":{"title":"JavaScript","require":"clike","modify":"markup","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"abnf":{"title":"Augmented Backus–Naur form","owner":"RunDevelopment"},"actionscript":{"title":"ActionScript","require":"javascript","modify":"markup","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"antlr4":{"title":"ANTLR4","alias":"g4","owner":"RunDevelopment"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"aql":{"title":"AQL","owner":"RunDevelopment"},"arduino":{"title":"Arduino","require":"cpp","owner":"eisbehr-"},"arff":{"title":"ARFF","owner":"Golmote"},"asciidoc":{"alias":"adoc","title":"AsciiDoc","owner":"Golmote"},"asm6502":{"title":"6502 Assembly","owner":"kzurawel"},"aspnet":{"title":"ASP.NET (C#)","require":["markup","csharp"],"owner":"nauzilus"},"autohotkey":{"title":"AutoHotkey","owner":"aviaryan"},"autoit":{"title":"AutoIt","owner":"Golmote"},"bash":{"title":"Bash","alias":"shell","aliasTitles":{"shell":"Shell"},"owner":"zeitgeist87"},"basic":{"title":"BASIC","owner":"Golmote"},"batch":{"title":"Batch","owner":"Golmote"},"bbcode":{"title":"BBcode","owner":"RunDevelopment"},"bison":{"title":"Bison","require":"c","owner":"Golmote"},"bnf":{"title":"Backus–Naur form","alias":"rbnf","aliasTitles":{"rbnf":"Routing Backus–Naur form"},"owner":"RunDevelopment"},"brainfuck":{"title":"Brainfuck","owner":"Golmote"},"brightscript":{"title":"BrightScript","owner":"RunDevelopment"},"bro":{"title":"Bro","owner":"wayward710"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"concurnas":{"title":"Concurnas","alias":"conc","owner":"jasontatton"},"csharp":{"title":"C#","require":"clike","alias":["cs","dotnet"],"owner":"mvalipour"},"cpp":{"title":"C++","require":"c","owner":"zeitgeist87"},"cil":{"title":"CIL","owner":"sbrl"},"coffeescript":{"title":"CoffeeScript","require":"javascript","alias":"coffee","owner":"R-osey"},"cmake":{"title":"CMake","owner":"mjrogozinski"},"clojure":{"title":"Clojure","owner":"troglotit"},"crystal":{"title":"Crystal","require":"ruby","owner":"MakeNowJust"},"csp":{"title":"Content-Security-Policy","owner":"ScottHelme"},"css-extras":{"title":"CSS Extras","require":"css","modify":"css","owner":"milesj"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"dax":{"title":"DAX","owner":"peterbud"},"diff":{"title":"Diff","owner":"uranusjr"},"django":{"title":"Django/Jinja2","require":"markup-templating","alias":"jinja2","owner":"romanvm"},"dns-zone-file":{"title":"DNS zone file","owner":"RunDevelopment","alias":"dns-zone"},"docker":{"title":"Docker","alias":"dockerfile","owner":"JustinBeckwith"},"ebnf":{"title":"Extended Backus–Naur form","owner":"RunDevelopment"},"eiffel":{"title":"Eiffel","owner":"Conaclos"},"ejs":{"title":"EJS","require":["javascript","markup-templating"],"owner":"RunDevelopment"},"elixir":{"title":"Elixir","owner":"Golmote"},"elm":{"title":"Elm","owner":"zwilias"},"etlua":{"title":"Embedded Lua templating","require":["lua","markup-templating"],"owner":"RunDevelopment"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"excel-formula":{"title":"Excel Formula","alias":["xlsx","xls"],"owner":"RunDevelopment"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"factor":{"title":"Factor","owner":"catb0t"},"firestore-security-rules":{"title":"Firestore security rules","require":"clike","owner":"RunDevelopment"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"ftl":{"title":"FreeMarker Template Language","require":"markup-templating","owner":"RunDevelopment"},"gcode":{"title":"G-code","owner":"RunDevelopment"},"gdscript":{"title":"GDScript","owner":"RunDevelopment"},"gedcom":{"title":"GEDCOM","owner":"Golmote"},"gherkin":{"title":"Gherkin","owner":"hason"},"git":{"title":"Git","owner":"lgiraudel"},"glsl":{"title":"GLSL","require":"clike","owner":"Golmote"},"gml":{"title":"GameMaker Language","alias":"gamemakerlanguage","require":"clike","owner":"LiarOnce"},"go":{"title":"Go","require":"clike","owner":"arnehormann"},"graphql":{"title":"GraphQL","owner":"Golmote"},"groovy":{"title":"Groovy","require":"clike","owner":"robfletcher"},"haml":{"title":"Haml","require":"ruby","optional":["css","css-extras","coffeescript","erb","javascript","less","markdown","scss","textile"],"owner":"Golmote"},"handlebars":{"title":"Handlebars","require":"markup-templating","owner":"Golmote"},"haskell":{"title":"Haskell","alias":"hs","owner":"bholst"},"haxe":{"title":"Haxe","require":"clike","owner":"Golmote"},"hcl":{"title":"HCL","owner":"outsideris"},"http":{"title":"HTTP","optional":["css","javascript","json","markup"],"owner":"danielgtaylor"},"hpkp":{"title":"HTTP Public-Key-Pins","owner":"ScottHelme"},"hsts":{"title":"HTTP Strict-Transport-Security","owner":"ScottHelme"},"ichigojam":{"title":"IchigoJam","owner":"BlueCocoa"},"icon":{"title":"Icon","owner":"Golmote"},"inform7":{"title":"Inform 7","owner":"Golmote"},"ini":{"title":"Ini","owner":"aviaryan"},"io":{"title":"Io","owner":"AlesTsurko"},"j":{"title":"J","owner":"Golmote"},"java":{"title":"Java","require":"clike","owner":"sherblot"},"javadoc":{"title":"JavaDoc","require":["markup","java","javadoclike"],"modify":"java","optional":"scala","owner":"RunDevelopment"},"javadoclike":{"title":"JavaDoc-like","modify":["java","javascript","php"],"owner":"RunDevelopment"},"javastacktrace":{"title":"Java stack trace","owner":"RunDevelopment"},"jolie":{"title":"Jolie","require":"clike","owner":"thesave"},"jq":{"title":"JQ","owner":"RunDevelopment"},"jsdoc":{"title":"JSDoc","require":["javascript","javadoclike"],"modify":"javascript","optional":["actionscript","coffeescript"],"owner":"RunDevelopment"},"js-extras":{"title":"JS Extras","require":"javascript","modify":"javascript","optional":["actionscript","coffeescript","flow","n4js","typescript"],"owner":"RunDevelopment"},"js-templates":{"title":"JS Templates","require":"javascript","modify":"javascript","optional":["css","css-extras","graphql","markdown","markup"],"owner":"RunDevelopment"},"json":{"title":"JSON","owner":"CupOfTea696"},"jsonp":{"title":"JSONP","require":"json","owner":"RunDevelopment"},"json5":{"title":"JSON5","require":"json","owner":"RunDevelopment"},"julia":{"title":"Julia","owner":"cdagnino"},"keyman":{"title":"Keyman","owner":"mcdurdin"},"kotlin":{"title":"Kotlin","require":"clike","owner":"Golmote"},"latex":{"title":"LaTeX","alias":["tex","context"],"aliasTitles":{"tex":"TeX","context":"ConTeXt"},"owner":"japborst"},"latte":{"title":"Latte","require":["clike","markup-templating","php"],"owner":"nette"},"less":{"title":"Less","require":"css","optional":"css-extras","owner":"Golmote"},"lilypond":{"title":"LilyPond","require":"scheme","alias":"ly","owner":"RunDevelopment"},"liquid":{"title":"Liquid","owner":"cinhtau"},"lisp":{"title":"Lisp","alias":["emacs","elisp","emacs-lisp"],"owner":"JuanCaicedo"},"livescript":{"title":"LiveScript","owner":"Golmote"},"llvm":{"title":"LLVM IR","owner":"porglezomp"},"lolcode":{"title":"LOLCODE","owner":"Golmote"},"lua":{"title":"Lua","owner":"Golmote"},"makefile":{"title":"Makefile","owner":"Golmote"},"markdown":{"title":"Markdown","require":"markup","alias":"md","owner":"Golmote"},"markup-templating":{"title":"Markup templating","require":"markup","owner":"Golmote"},"matlab":{"title":"MATLAB","owner":"Golmote"},"mel":{"title":"MEL","owner":"Golmote"},"mizar":{"title":"Mizar","owner":"Golmote"},"monkey":{"title":"Monkey","owner":"Golmote"},"moonscript":{"title":"MoonScript","alias":"moon","owner":"RunDevelopment"},"n1ql":{"title":"N1QL","owner":"TMWilds"},"n4js":{"title":"N4JS","require":"javascript","optional":"jsdoc","alias":"n4jsd","owner":"bsmith-n4"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","owner":"stephanmax"},"nasm":{"title":"NASM","owner":"rbmj"},"neon":{"title":"NEON","owner":"nette"},"nginx":{"title":"nginx","owner":"westonganger","require":"clike"},"nim":{"title":"Nim","owner":"Golmote"},"nix":{"title":"Nix","owner":"Golmote"},"nsis":{"title":"NSIS","owner":"idleberg"},"objectivec":{"title":"Objective-C","require":"c","owner":"uranusjr"},"ocaml":{"title":"OCaml","owner":"Golmote"},"opencl":{"title":"OpenCL","require":"c","modify":["c","cpp"],"owner":"Milania1"},"oz":{"title":"Oz","owner":"Golmote"},"parigp":{"title":"PARI/GP","owner":"Golmote"},"parser":{"title":"Parser","require":"markup","owner":"Golmote"},"pascal":{"title":"Pascal","alias":"objectpascal","aliasTitles":{"objectpascal":"Object Pascal"},"owner":"Golmote"},"pascaligo":{"title":"Pascaligo","owner":"DefinitelyNotAGoat"},"pcaxis":{"title":"PC-Axis","alias":"px","owner":"RunDevelopment"},"perl":{"title":"Perl","owner":"Golmote"},"php":{"title":"PHP","require":["clike","markup-templating"],"owner":"milesj"},"phpdoc":{"title":"PHPDoc","require":["php","javadoclike"],"modify":"php","owner":"RunDevelopment"},"php-extras":{"title":"PHP Extras","require":"php","modify":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"powerquery":{"title":"PowerQuery","alias":["pq","mscript"],"owner":"peterbud"},"powershell":{"title":"PowerShell","owner":"nauzilus"},"processing":{"title":"Processing","require":"clike","owner":"Golmote"},"prolog":{"title":"Prolog","owner":"Golmote"},"properties":{"title":".properties","owner":"Golmote"},"protobuf":{"title":"Protocol Buffers","require":"clike","owner":"just-boris"},"pug":{"title":"Pug","require":["markup","javascript"],"optional":["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],"owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","optional":["c","cpp","fortran"],"owner":"Golmote"},"python":{"title":"Python","alias":"py","owner":"multipetros"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qml":{"title":"QML","require":"javascript","owner":"RunDevelopment"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"jsx":{"title":"React JSX","require":["markup","javascript"],"optional":["jsdoc","js-extras","js-templates"],"owner":"vkbansal"},"tsx":{"title":"React TSX","require":["jsx","typescript"]},"renpy":{"title":"Ren'py","owner":"HyuchiaDiego"},"reason":{"title":"Reason","require":"clike","owner":"Golmote"},"regex":{"title":"Regex","modify":["actionscript","coffeescript","flow","javascript","typescript","vala"],"owner":"RunDevelopment"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"robotframework":{"title":"Robot Framework","alias":"robot","owner":"RunDevelopment"},"ruby":{"title":"Ruby","require":"clike","alias":"rb","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","optional":["groovy","lua","sql"],"owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","optional":"css-extras","owner":"MoOx"},"scala":{"title":"Scala","require":"java","owner":"jozic"},"scheme":{"title":"Scheme","owner":"bacchus123"},"shell-session":{"title":"Shell session","require":"bash","owner":"RunDevelopment"},"smalltalk":{"title":"Smalltalk","owner":"Golmote"},"smarty":{"title":"Smarty","require":"markup-templating","owner":"Golmote"},"solidity":{"title":"Solidity (Ethereum)","require":"clike","owner":"glachaud"},"solution-file":{"title":"Solution file","alias":"sln","owner":"RunDevelopment"},"soy":{"title":"Soy (Closure Template)","require":"markup-templating","owner":"Golmote"},"sparql":{"title":"SPARQL","require":"turtle","owner":"Triply-Dev","alias":"rq"},"splunk-spl":{"title":"Splunk SPL","owner":"RunDevelopment"},"sqf":{"title":"SQF: Status Quo Function (Arma 3)","require":"clike","owner":"RunDevelopment"},"sql":{"title":"SQL","owner":"multipetros"},"stylus":{"title":"Stylus","owner":"vkbansal"},"swift":{"title":"Swift","require":"clike","owner":"chrischares"},"tap":{"title":"TAP","owner":"isaacs","require":"yaml"},"tcl":{"title":"Tcl","owner":"PeterChaplin"},"textile":{"title":"Textile","require":"markup","optional":"css","owner":"Golmote"},"toml":{"title":"TOML","owner":"RunDevelopment"},"tt2":{"title":"Template Toolkit 2","require":["clike","markup-templating"],"owner":"gflohr"},"turtle":{"title":"Turtle","alias":"trig","aliasTitles":{"trig":"TriG"},"owner":"jakubklimek"},"twig":{"title":"Twig","require":"markup","owner":"brandonkelly"},"typescript":{"title":"TypeScript","require":"javascript","optional":"js-templates","alias":"ts","owner":"vkbansal"},"t4-cs":{"title":"T4 Text Templates (C#)","require":["t4-templating","csharp"],"alias":"t4","owner":"RunDevelopment"},"t4-vb":{"title":"T4 Text Templates (VB)","require":["t4-templating","visual-basic"],"owner":"RunDevelopment"},"t4-templating":{"title":"T4 templating","owner":"RunDevelopment"},"vala":{"title":"Vala","require":"clike","owner":"TemplarVolk"},"vbnet":{"title":"VB.Net","require":"basic","owner":"Bigsby"},"velocity":{"title":"Velocity","require":"markup","owner":"Golmote"},"verilog":{"title":"Verilog","owner":"a-rey"},"vhdl":{"title":"VHDL","owner":"a-rey"},"vim":{"title":"vim","owner":"westonganger"},"visual-basic":{"title":"Visual Basic","alias":"vb","owner":"Golmote"},"wasm":{"title":"WebAssembly","owner":"Golmote"},"wiki":{"title":"Wiki markup","require":"markup","owner":"Golmote"},"xeora":{"title":"Xeora","require":"markup","alias":"xeoracube","aliasTitles":{"xeoracube":"XeoraCube"},"owner":"freakmaxi"},"xojo":{"title":"Xojo (REALbasic)","owner":"Golmote"},"xquery":{"title":"XQuery","require":"markup","owner":"Golmote"},"yaml":{"title":"YAML","alias":"yml","owner":"hason"},"zig":{"title":"Zig","owner":"RunDevelopment"}},"plugins":{"meta":{"path":"plugins/{id}/prism-{id}","link":"plugins/{id}/"},"line-highlight":{"title":"Line Highlight","description":"Highlights specific lines and/or line ranges."},"line-numbers":{"title":"Line Numbers","description":"Line number at the beginning of code lines.","owner":"kuba-kubula"},"show-invisibles":{"title":"Show Invisibles","description":"Show hidden characters such as tabs and line breaks.","optional":["autolinker","data-uri-highlight"]},"autolinker":{"title":"Autolinker","description":"Converts URLs and emails in code to clickable links. Parses Markdown links in comments."},"wpd":{"title":"WebPlatform Docs","description":"Makes tokens link to WebPlatform.org documentation. The links open in a new tab."},"custom-class":{"title":"Custom Class","description":"This plugin allows you to prefix Prism's default classes (.comment can become .namespace--comment) or replace them with your defined ones (like .editor__comment). You can even add new classes.","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","description":"Fetch external files and highlight them with Prism. Used on the Prism website itself.","noCSS":true},"show-language":{"title":"Show Language","description":"Display the highlighted language in code blocks (inline code does not show the label).","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","description":"Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","description":"Adds special CSS classes for each keyword matched in the code. For example, the keyword if will have the class keyword-if as well. You can have fine grained control over the appearance of each keyword by providing your own CSS rules.","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","description":"Removes the initial line feed in code blocks.","owner":"Golmote","noCSS":true},"inline-color":{"title":"Inline color","description":"Adds a small inline preview for colors in style sheets.","require":"css-extras","owner":"RunDevelopment"},"previewers":{"title":"Previewers","description":"Previewers for angles, colors, gradients, easing and time.","require":"css-extras","owner":"Golmote"},"autoloader":{"title":"Autoloader","description":"Automatically loads the needed languages to highlight the code blocks.","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","description":"Prevents custom markup from being dropped out during highlighting.","owner":"Golmote","optional":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","description":"Display a command line with a prompt and, optionally, the output/response from the commands.","owner":"chriswells0"},"unescaped-markup":{"title":"Unescaped Markup","description":"Write markup without having to escape anything."},"normalize-whitespace":{"title":"Normalize Whitespace","description":"Supports multiple operations to normalize whitespace in code blocks.","owner":"zeitgeist87","optional":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","description":"Highlights data-URI contents.","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","description":"Attach a toolbar for plugins to easily register buttons on the top of a code block.","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","description":"Add a button that copies the code block to the clipboard when clicked.","owner":"mAAdhaTTah","require":"toolbar","noCSS":true},"download-button":{"title":"Download Button","description":"A button in the toolbar of a code block adding a convenient way to download a code file.","owner":"Golmote","require":"toolbar","noCSS":true},"match-braces":{"title":"Match braces","description":"Highlights matching braces.","owner":"RunDevelopment"},"diff-highlight":{"title":"Diff Highlight","description":"Highlights the code inside diff blocks.","owner":"RunDevelopment","require":"diff"},"filter-highlight-all":{"title":"Filter highlightAll","description":"Filters the elements the highlightAll and highlightAllUnder methods actually highlight.","owner":"RunDevelopment","noCSS":true}}}; if (typeof module !== 'undefined' && module.exports) { module.exports = components; } \ No newline at end of file diff --git a/components.json b/components.json index f8a2d1e8eb..9d14518c4b 100644 --- a/components.json +++ b/components.json @@ -602,6 +602,10 @@ "title": "LiveScript", "owner": "Golmote" }, + "llvm": { + "title": "LLVM IR", + "owner": "porglezomp" + }, "lolcode": { "title": "LOLCODE", "owner": "Golmote" diff --git a/components/prism-llvm.js b/components/prism-llvm.js new file mode 100644 index 0000000000..b7f53a768a --- /dev/null +++ b/components/prism-llvm.js @@ -0,0 +1,12 @@ +(function(Prism) { + Prism.languages.llvm = { + 'comment': /;.*/, + 'string': /"[^"]*"/, + 'variable': /[%@!#](?:(?:[-a-zA-Z$._]|\\[a-fA-F0-9]{2})(?:[-a-zA-Z$._0-9]|\\[a-fA-F0-9]{2})*|[0-9]+)/, + 'label': /(?:[-a-zA-Z$._]|\\[a-fA-F0-9]{2})(?:[-a-zA-Z$._0-9]|\\[a-fA-F0-9]{2})*:/, + 'type': /\b(?:void|label|token|metadata|float|double|half)\b/, + 'keyword': /[a-z_][a-z_0-9]*/, + 'number': /[+-]?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?|0x[0-9A-Fa-f]+/, + 'punctuation': /[{}[\];(),.!*=<>]/, + }; +}(Prism)); diff --git a/components/prism-llvm.min.js b/components/prism-llvm.min.js new file mode 100644 index 0000000000..e3250d75b6 --- /dev/null +++ b/components/prism-llvm.min.js @@ -0,0 +1 @@ +Prism.languages.llvm={comment:/;.*/,string:/"[^"]*"/,variable:/[%@!#](?:(?:[-a-zA-Z$._]|\\[a-fA-F0-9]{2})(?:[-a-zA-Z$._0-9]|\\[a-fA-F0-9]{2})*|[0-9]+)/,label:/(?:[-a-zA-Z$._]|\\[a-fA-F0-9]{2})(?:[-a-zA-Z$._0-9]|\\[a-fA-F0-9]{2})*:/,type:/\b(?:void|label|token|metadata|float|double|half)\b/,keyword:/[a-z_][a-z_0-9]*/,number:/[+-]?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?|0x[0-9A-Fa-f]+/,punctuation:/[{}[\];(),.!*=<>]/}; \ No newline at end of file diff --git a/examples/prism-llvm.html b/examples/prism-llvm.html new file mode 100644 index 0000000000..d6b39f0f35 --- /dev/null +++ b/examples/prism-llvm.html @@ -0,0 +1,23 @@ +

Full Example

+

+; Declare the string constant as a global constant.
+@.str = private unnamed_addr constant [13 x i8] c"hello world\0A\00"
+
+; External declaration of the puts function
+declare i32 @puts(i8* nocapture) nounwind
+
+; Definition of main function
+define i32 @main() {   ; i32()*
+entry:
+  ; Convert [13 x i8]* to i8*...
+  %cast210 = getelementptr [13 x i8], [13 x i8]* @.str, i64 0, i64 0
+
+  ; Call puts function to write out the string to stdout.
+  call i32 @puts(i8* %cast210)
+  ret i32 0
+}
+
+; Named metadata
+!0 = !{i32 42, null, !"string"}
+!foo = !{!0}
+
diff --git a/plugins/show-language/prism-show-language.js b/plugins/show-language/prism-show-language.js index 450361a7c8..d83dfa39d3 100644 --- a/plugins/show-language/prism-show-language.js +++ b/plugins/show-language/prism-show-language.js @@ -96,6 +96,7 @@ "emacs": "Lisp", "elisp": "Lisp", "emacs-lisp": "Lisp", + "llvm": "LLVM IR", "lolcode": "LOLCODE", "md": "Markdown", "markup-templating": "Markup templating", diff --git a/plugins/show-language/prism-show-language.min.js b/plugins/show-language/prism-show-language.min.js index d8e7e2ce56..2be04bbd5c 100644 --- a/plugins/show-language/prism-show-language.min.js +++ b/plugins/show-language/prism-show-language.min.js @@ -1 +1 @@ -!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var r={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"Augmented Backus–Naur form",antlr4:"ANTLR4",g4:"ANTLR4",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",bbcode:"BBcode",bnf:"Backus–Naur form",rbnf:"Routing Backus–Naur form",conc:"Concurnas",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",coffee:"CoffeeScript",cmake:"CMake",csp:"Content-Security-Policy","css-extras":"CSS Extras",dax:"DAX",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"Extended Backus–Naur form",ejs:"EJS",etlua:"Embedded Lua templating",erb:"ERB","excel-formula":"Excel Formula",xlsx:"Excel Formula",xls:"Excel Formula",fsharp:"F#","firestore-security-rules":"Firestore security rules",ftl:"FreeMarker Template Language",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",moon:"MoonScript",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",nasm:"NASM",neon:"NEON",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",powerquery:"PowerQuery",pq:"PowerQuery",mscript:"PowerQuery",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",py:"Python",q:"Q (kdb+ database)",qml:"QML",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rest:"reST (reStructuredText)",robotframework:"Robot Framework",robot:"Robot Framework",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session",solidity:"Solidity (Ethereum)","solution-file":"Solution file",sln:"Solution file",soy:"Soy (Closure Template)",sparql:"SPARQL",rq:"SPARQL","splunk-spl":"Splunk SPL",sqf:"SQF: Status Quo Function (Arma 3)",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")||r[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.")}(); \ No newline at end of file +!function(){if("undefined"!=typeof self&&self.Prism&&self.document)if(Prism.plugins.toolbar){var r={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"Augmented Backus–Naur form",antlr4:"ANTLR4",g4:"ANTLR4",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",bbcode:"BBcode",bnf:"Backus–Naur form",rbnf:"Routing Backus–Naur form",conc:"Concurnas",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",coffee:"CoffeeScript",cmake:"CMake",csp:"Content-Security-Policy","css-extras":"CSS Extras",dax:"DAX",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"Extended Backus–Naur form",ejs:"EJS",etlua:"Embedded Lua templating",erb:"ERB","excel-formula":"Excel Formula",xlsx:"Excel Formula",xls:"Excel Formula",fsharp:"F#","firestore-security-rules":"Firestore security rules",ftl:"FreeMarker Template Language",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",llvm:"LLVM IR",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",moon:"MoonScript",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",nasm:"NASM",neon:"NEON",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",powerquery:"PowerQuery",pq:"PowerQuery",mscript:"PowerQuery",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",py:"Python",q:"Q (kdb+ database)",qml:"QML",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rest:"reST (reStructuredText)",robotframework:"Robot Framework",robot:"Robot Framework",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session",solidity:"Solidity (Ethereum)","solution-file":"Solution file",sln:"Solution file",soy:"Soy (Closure Template)",sparql:"SPARQL",rq:"SPARQL","splunk-spl":"Splunk SPL",sqf:"SQF: Status Quo Function (Arma 3)",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")||r[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.")}(); \ No newline at end of file diff --git a/tests/languages/llvm/attributes.test b/tests/languages/llvm/attributes.test new file mode 100644 index 0000000000..219e1818e5 --- /dev/null +++ b/tests/languages/llvm/attributes.test @@ -0,0 +1,47 @@ +; Target-independent attributes: +attributes #0 = { alwaysinline alignstack=4 } + +; Target-dependent attributes: +attributes #1 = { "no-sse" } + +; Function @f has attributes: alwaysinline, alignstack=4, and "no-sse". +define void @f() #0 #1 { ... } + +---------------------------------------------------- + +[ + ["comment", "; Target-independent attributes:"], + ["keyword", "attributes"], + ["variable", "#0"], + ["punctuation", "="], + ["punctuation", "{"], + ["keyword", "alwaysinline"], + ["keyword", "alignstack"], + ["punctuation", "="], + ["number", "4"], + ["punctuation", "}"], + ["comment", "; Target-dependent attributes:"], + ["keyword", "attributes"], + ["variable", "#1"], + ["punctuation", "="], + ["punctuation", "{"], + ["string", "\"no-sse\""], + ["punctuation", "}"], + ["comment", "; Function @f has attributes: alwaysinline, alignstack=4, and \"no-sse\"."], + ["keyword", "define"], + ["type", "void"], + ["variable", "@f"], + ["punctuation", "("], + ["punctuation", ")"], + ["variable", "#0"], + ["variable", "#1"], + ["punctuation", "{"], + ["punctuation", "."], + ["punctuation", "."], + ["punctuation", "."], + ["punctuation", "}"] +] + +---------------------------------------------------- + +Tests the attribute "#id" syntax. diff --git a/tests/languages/llvm/example-iterative.test b/tests/languages/llvm/example-iterative.test new file mode 100644 index 0000000000..ccef121c80 --- /dev/null +++ b/tests/languages/llvm/example-iterative.test @@ -0,0 +1,113 @@ +define i32 @add(i32 %a, i32 %b) { +entry: + br label %tailrecurse + +tailrecurse: + %a.tr = phi i32 [ %a, %entry ], [ %tmp2, %recurse ] + %b.tr = phi i32 [ %b, %entry ], [ %tmp3, %recurse ] + %tmp1 = icmp eq i32 %a.tr, 0 + br i1 %tmp1, label %done, label %recurse + +recurse: + %tmp2 = sub i32 %a.tr, 1 + %tmp3 = add i32 %b.tr, 1 + br label %tailrecurse + +done: + ret i32 %b.tr +} + +---------------------------------------------------- + +[ + ["keyword", "define"], + ["keyword", "i32"], + ["variable", "@add"], + ["punctuation", "("], + ["keyword", "i32"], + ["variable", "%a"], + ["punctuation", ","], + ["keyword", "i32"], + ["variable", "%b"], + ["punctuation", ")"], + ["punctuation", "{"], + ["label", "entry:"], + ["keyword", "br"], + ["type", "label"], + ["variable", "%tailrecurse"], + ["label", "tailrecurse:"], + ["variable", "%a.tr"], + ["punctuation", "="], + ["keyword", "phi"], + ["keyword", "i32"], + ["punctuation", "["], + ["variable", "%a"], + ["punctuation", ","], + ["variable", "%entry"], + ["punctuation", "]"], + ["punctuation", ","], + ["punctuation", "["], + ["variable", "%tmp2"], + ["punctuation", ","], + ["variable", "%recurse"], + ["punctuation", "]"], + ["variable", "%b.tr"], + ["punctuation", "="], + ["keyword", "phi"], + ["keyword", "i32"], + ["punctuation", "["], + ["variable", "%b"], + ["punctuation", ","], + ["variable", "%entry"], + ["punctuation", "]"], + ["punctuation", ","], + ["punctuation", "["], + ["variable", "%tmp3"], + ["punctuation", ","], + ["variable", "%recurse"], + ["punctuation", "]"], + ["variable", "%tmp1"], + ["punctuation", "="], + ["keyword", "icmp"], + ["keyword", "eq"], + ["keyword", "i32"], + ["variable", "%a.tr"], + ["punctuation", ","], + ["number", "0"], + ["keyword", "br"], + ["keyword", "i1"], + ["variable", "%tmp1"], + ["punctuation", ","], + ["type", "label"], + ["variable", "%done"], + ["punctuation", ","], + ["type", "label"], + ["variable", "%recurse"], + ["label", "recurse:"], + ["variable", "%tmp2"], + ["punctuation", "="], + ["keyword", "sub"], + ["keyword", "i32"], + ["variable", "%a.tr"], + ["punctuation", ","], + ["number", "1"], + ["variable", "%tmp3"], + ["punctuation", "="], + ["keyword", "add"], + ["keyword", "i32"], + ["variable", "%b.tr"], + ["punctuation", ","], + ["number", "1"], + ["keyword", "br"], + ["type", "label"], + ["variable", "%tailrecurse"], + ["label", "done:"], + ["keyword", "ret"], + ["keyword", "i32"], + ["variable", "%b.tr"], + ["punctuation", "}"] +] + +---------------------------------------------------- + +An iterative example program. diff --git a/tests/languages/llvm/example-recursive.test b/tests/languages/llvm/example-recursive.test new file mode 100644 index 0000000000..9ed7218e62 --- /dev/null +++ b/tests/languages/llvm/example-recursive.test @@ -0,0 +1,87 @@ +define i32 @add(i32 %a, i32 %b) { +entry: + %tmp1 = icmp eq i32 %a, 0 + br i1 %tmp1, label %done, label %recurse + +recurse: + %tmp2 = sub i32 %a, 1 + %tmp3 = add i32 %b, 1 + %tmp4 = call i32 @add(i32 %tmp2, i32 %tmp3) + ret i32 %tmp4 + +done: + ret i32 %b +} + +---------------------------------------------------- + +[ + ["keyword", "define"], + ["keyword", "i32"], + ["variable", "@add"], + ["punctuation", "("], + ["keyword", "i32"], + ["variable", "%a"], + ["punctuation", ","], + ["keyword", "i32"], + ["variable", "%b"], + ["punctuation", ")"], + ["punctuation", "{"], + ["label", "entry:"], + ["variable", "%tmp1"], + ["punctuation", "="], + ["keyword", "icmp"], + ["keyword", "eq"], + ["keyword", "i32"], + ["variable", "%a"], + ["punctuation", ","], + ["number", "0"], + ["keyword", "br"], + ["keyword", "i1"], + ["variable", "%tmp1"], + ["punctuation", ","], + ["type", "label"], + ["variable", "%done"], + ["punctuation", ","], + ["type", "label"], + ["variable", "%recurse"], + ["label", "recurse:"], + ["variable", "%tmp2"], + ["punctuation", "="], + ["keyword", "sub"], + ["keyword", "i32"], + ["variable", "%a"], + ["punctuation", ","], + ["number", "1"], + ["variable", "%tmp3"], + ["punctuation", "="], + ["keyword", "add"], + ["keyword", "i32"], + ["variable", "%b"], + ["punctuation", ","], + ["number", "1"], + ["variable", "%tmp4"], + ["punctuation", "="], + ["keyword", "call"], + ["keyword", "i32"], + ["variable", "@add"], + ["punctuation", "("], + ["keyword", "i32"], + ["variable", "%tmp2"], + ["punctuation", ","], + ["keyword", "i32"], + ["variable", "%tmp3"], + ["punctuation", ")"], + ["keyword", "ret"], + ["keyword", "i32"], + ["variable", "%tmp4"], + ["label", "done:"], + ["keyword", "ret"], + ["keyword", "i32"], + ["variable", "%b"], + ["punctuation", "}"] +] + +---------------------------------------------------- + +A recursive example program. diff --git a/tests/languages/llvm/langref-module-example.test b/tests/languages/llvm/langref-module-example.test new file mode 100644 index 0000000000..08d71439cc --- /dev/null +++ b/tests/languages/llvm/langref-module-example.test @@ -0,0 +1,115 @@ +; Declare the string constant as a global constant. +@.str = private unnamed_addr constant [13 x i8] c"hello world\0A\00" + +; External declaration of the puts function +declare i32 @puts(i8* nocapture) nounwind + +; Definition of main function +define i32 @main() { ; i32()* + ; Convert [13 x i8]* to i8*... + %cast210 = getelementptr [13 x i8], [13 x i8]* @.str, i64 0, i64 0 + + ; Call puts function to write out the string to stdout. + call i32 @puts(i8* %cast210) + ret i32 0 +} + +; Named metadata +!0 = !{i32 42, null, !"string"} +!foo = !{!0} + +---------------------------------------------------- + +[ + ["comment", "; Declare the string constant as a global constant."], + ["variable", "@.str"], + ["punctuation", "="], + ["keyword", "private"], + ["keyword", "unnamed_addr"], + ["keyword", "constant"], + ["punctuation", "["], + ["number", "13"], + ["keyword", "x"], + ["keyword", "i8"], + ["punctuation", "]"], + ["keyword", "c"], + ["string", "\"hello world\\0A\\00\""], + ["comment", "; External declaration of the puts function"], + ["keyword", "declare"], + ["keyword", "i32"], + ["variable", "@puts"], + ["punctuation", "("], + ["keyword", "i8"], + ["punctuation", "*"], + ["keyword", "nocapture"], + ["punctuation", ")"], + ["keyword", "nounwind"], + ["comment", "; Definition of main function"], + ["keyword", "define"], + ["keyword", "i32"], + ["variable", "@main"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["comment", "; i32()*"], + ["comment", "; Convert [13 x i8]* to i8*..."], + ["variable", "%cast210"], + ["punctuation", "="], + ["keyword", "getelementptr"], + ["punctuation", "["], + ["number", "13"], + ["keyword", "x"], + ["keyword", "i8"], + ["punctuation", "]"], + ["punctuation", ","], + ["punctuation", "["], + ["number", "13"], + ["keyword", "x"], + ["keyword", "i8"], + ["punctuation", "]"], + ["punctuation", "*"], + ["variable", "@.str"], + ["punctuation", ","], + ["keyword", "i64"], + ["number", "0"], + ["punctuation", ","], + ["keyword", "i64"], + ["number", "0"], + ["comment", "; Call puts function to write out the string to stdout."], + ["keyword", "call"], + ["keyword", "i32"], + ["variable", "@puts"], + ["punctuation", "("], + ["keyword", "i8"], + ["punctuation", "*"], + ["variable", "%cast210"], + ["punctuation", ")"], + ["keyword", "ret"], + ["keyword", "i32"], + ["number", "0"], + ["punctuation", "}"], + ["comment", "; Named metadata"], + ["variable", "!0"], + ["punctuation", "="], + ["punctuation", "!"], + ["punctuation", "{"], + ["keyword", "i32"], + ["number", "42"], + ["punctuation", ","], + ["keyword", "null"], + ["punctuation", ","], + ["punctuation", "!"], + ["string", "\"string\""], + ["punctuation", "}"], + ["variable", "!foo"], + ["punctuation", "="], + ["punctuation", "!"], + ["punctuation", "{"], + ["variable", "!0"], + ["punctuation", "}"] +] + +---------------------------------------------------- + +Tests the example included on the LangRef, at: +https://llvm.org/docs/LangRef.html#module-structure From 7368fd444e4e4f5e7b54948aaf2aabdfe5dc4125 Mon Sep 17 00:00:00 2001 From: Cassie Jones Date: Mon, 23 Mar 2020 14:17:21 -0400 Subject: [PATCH 2/3] Fix LLVM IR review requests --- components/prism-llvm.js | 19 +- components/prism-llvm.min.js | 2 +- tests/languages/llvm/attributes.test | 60 +++--- tests/languages/llvm/edge-cases.test | 11 ++ tests/languages/llvm/example-iterative.test | 172 +++++++++--------- tests/languages/llvm/example-recursive.test | 128 ++++++------- tests/languages/llvm/integers.test | 49 +++++ .../llvm/langref-module-example.test | 172 +++++++++--------- 8 files changed, 340 insertions(+), 273 deletions(-) create mode 100644 tests/languages/llvm/edge-cases.test create mode 100644 tests/languages/llvm/integers.test diff --git a/components/prism-llvm.js b/components/prism-llvm.js index b7f53a768a..f22be3f060 100644 --- a/components/prism-llvm.js +++ b/components/prism-llvm.js @@ -1,12 +1,19 @@ (function(Prism) { Prism.languages.llvm = { 'comment': /;.*/, - 'string': /"[^"]*"/, - 'variable': /[%@!#](?:(?:[-a-zA-Z$._]|\\[a-fA-F0-9]{2})(?:[-a-zA-Z$._0-9]|\\[a-fA-F0-9]{2})*|[0-9]+)/, - 'label': /(?:[-a-zA-Z$._]|\\[a-fA-F0-9]{2})(?:[-a-zA-Z$._0-9]|\\[a-fA-F0-9]{2})*:/, - 'type': /\b(?:void|label|token|metadata|float|double|half)\b/, - 'keyword': /[a-z_][a-z_0-9]*/, - 'number': /[+-]?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?|0x[0-9A-Fa-f]+/, + 'string': { + pattern: /"[^"]*"/, + greedy: true, + }, + 'boolean': /\b(?:true|false)\b/, + 'variable': /[%@!#](?:(?!\d)(?:[-$.\w]|\\[a-f\d]{2})+|\d+)/i, + 'label': /(?!\d)(?:[-$.\w]|\\[a-f\d]{2})+:/i, + 'type': { + pattern: /\b(?:double|float|fp128|half|i[1-9]\d*|label|metadata|ppc_fp128|token|void|x86_fp80|x86_mmx)\b/, + alias: 'class-name', + }, + 'keyword': /\b[a-z_][a-z_0-9]*\b/, + 'number': /[+-]?\b\d+(?:.\d+)?(?:[eE][+-]?\d+)?\b|\b0x[\dA-Fa-f]+\b|\b0xK[\dA-Fa-f]{20}\b|\b0x[ML][\dA-Fa-f]{32}\b|\b0xH[\dA-Fa-f]{4}\b/, 'punctuation': /[{}[\];(),.!*=<>]/, }; }(Prism)); diff --git a/components/prism-llvm.min.js b/components/prism-llvm.min.js index e3250d75b6..bca19fdb29 100644 --- a/components/prism-llvm.min.js +++ b/components/prism-llvm.min.js @@ -1 +1 @@ -Prism.languages.llvm={comment:/;.*/,string:/"[^"]*"/,variable:/[%@!#](?:(?:[-a-zA-Z$._]|\\[a-fA-F0-9]{2})(?:[-a-zA-Z$._0-9]|\\[a-fA-F0-9]{2})*|[0-9]+)/,label:/(?:[-a-zA-Z$._]|\\[a-fA-F0-9]{2})(?:[-a-zA-Z$._0-9]|\\[a-fA-F0-9]{2})*:/,type:/\b(?:void|label|token|metadata|float|double|half)\b/,keyword:/[a-z_][a-z_0-9]*/,number:/[+-]?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?|0x[0-9A-Fa-f]+/,punctuation:/[{}[\];(),.!*=<>]/}; \ No newline at end of file +Prism.languages.llvm={comment:/;.*/,string:{pattern:/"[^"]*"/,greedy:!0},boolean:/\b(?:true|false)\b/,variable:/[%@!#](?:(?!\d)(?:[-$.\w]|\\[a-f\d]{2})+|\d+)/i,label:/(?!\d)(?:[-$.\w]|\\[a-f\d]{2})+:/i,type:{pattern:/\b(?:double|float|fp128|half|i[1-9]\d*|label|metadata|ppc_fp128|token|void|x86_fp80|x86_mmx)\b/,alias:"class-name"},keyword:/\b[a-z_][a-z_0-9]*\b/,number:/[+-]?\b\d+(?:.\d+)?(?:[eE][+-]?\d+)?\b|\b0x[\dA-Fa-f]+\b|\b0xK[\dA-Fa-f]{20}\b|\b0x[ML][\dA-Fa-f]{32}\b|\b0xH[\dA-Fa-f]{4}\b/,punctuation:/[{}[\];(),.!*=<>]/}; \ No newline at end of file diff --git a/tests/languages/llvm/attributes.test b/tests/languages/llvm/attributes.test index 219e1818e5..055167e1b1 100644 --- a/tests/languages/llvm/attributes.test +++ b/tests/languages/llvm/attributes.test @@ -10,36 +10,36 @@ define void @f() #0 #1 { ... } ---------------------------------------------------- [ - ["comment", "; Target-independent attributes:"], - ["keyword", "attributes"], - ["variable", "#0"], - ["punctuation", "="], - ["punctuation", "{"], - ["keyword", "alwaysinline"], - ["keyword", "alignstack"], - ["punctuation", "="], - ["number", "4"], - ["punctuation", "}"], - ["comment", "; Target-dependent attributes:"], - ["keyword", "attributes"], - ["variable", "#1"], - ["punctuation", "="], - ["punctuation", "{"], - ["string", "\"no-sse\""], - ["punctuation", "}"], - ["comment", "; Function @f has attributes: alwaysinline, alignstack=4, and \"no-sse\"."], - ["keyword", "define"], - ["type", "void"], - ["variable", "@f"], - ["punctuation", "("], - ["punctuation", ")"], - ["variable", "#0"], - ["variable", "#1"], - ["punctuation", "{"], - ["punctuation", "."], - ["punctuation", "."], - ["punctuation", "."], - ["punctuation", "}"] + ["comment", "; Target-independent attributes:"], + ["keyword", "attributes"], + ["variable", "#0"], + ["punctuation", "="], + ["punctuation", "{"], + ["keyword", "alwaysinline"], + ["keyword", "alignstack"], + ["punctuation", "="], + ["number", "4"], + ["punctuation", "}"], + ["comment", "; Target-dependent attributes:"], + ["keyword", "attributes"], + ["variable", "#1"], + ["punctuation", "="], + ["punctuation", "{"], + ["string", "\"no-sse\""], + ["punctuation", "}"], + ["comment", "; Function @f has attributes: alwaysinline, alignstack=4, and \"no-sse\"."], + ["keyword", "define"], + ["type", "void"], + ["variable", "@f"], + ["punctuation", "("], + ["punctuation", ")"], + ["variable", "#0"], + ["variable", "#1"], + ["punctuation", "{"], + ["punctuation", "."], + ["punctuation", "."], + ["punctuation", "."], + ["punctuation", "}"] ] ---------------------------------------------------- diff --git a/tests/languages/llvm/edge-cases.test b/tests/languages/llvm/edge-cases.test new file mode 100644 index 0000000000..fe7d06e06f --- /dev/null +++ b/tests/languages/llvm/edge-cases.test @@ -0,0 +1,11 @@ +" ; " + +---------------------------------------------------- + +[ + ["string", "\" ; \""] +] + +---------------------------------------------------- + +Specific edge-cases diff --git a/tests/languages/llvm/example-iterative.test b/tests/languages/llvm/example-iterative.test index ccef121c80..da48891352 100644 --- a/tests/languages/llvm/example-iterative.test +++ b/tests/languages/llvm/example-iterative.test @@ -20,92 +20,92 @@ done: ---------------------------------------------------- [ - ["keyword", "define"], - ["keyword", "i32"], - ["variable", "@add"], - ["punctuation", "("], - ["keyword", "i32"], - ["variable", "%a"], - ["punctuation", ","], - ["keyword", "i32"], - ["variable", "%b"], - ["punctuation", ")"], - ["punctuation", "{"], - ["label", "entry:"], - ["keyword", "br"], - ["type", "label"], - ["variable", "%tailrecurse"], - ["label", "tailrecurse:"], - ["variable", "%a.tr"], - ["punctuation", "="], - ["keyword", "phi"], - ["keyword", "i32"], - ["punctuation", "["], - ["variable", "%a"], - ["punctuation", ","], - ["variable", "%entry"], - ["punctuation", "]"], - ["punctuation", ","], - ["punctuation", "["], - ["variable", "%tmp2"], - ["punctuation", ","], - ["variable", "%recurse"], - ["punctuation", "]"], - ["variable", "%b.tr"], - ["punctuation", "="], - ["keyword", "phi"], - ["keyword", "i32"], - ["punctuation", "["], - ["variable", "%b"], - ["punctuation", ","], - ["variable", "%entry"], - ["punctuation", "]"], - ["punctuation", ","], - ["punctuation", "["], - ["variable", "%tmp3"], - ["punctuation", ","], - ["variable", "%recurse"], - ["punctuation", "]"], - ["variable", "%tmp1"], - ["punctuation", "="], - ["keyword", "icmp"], - ["keyword", "eq"], - ["keyword", "i32"], - ["variable", "%a.tr"], - ["punctuation", ","], - ["number", "0"], - ["keyword", "br"], - ["keyword", "i1"], - ["variable", "%tmp1"], - ["punctuation", ","], - ["type", "label"], - ["variable", "%done"], - ["punctuation", ","], - ["type", "label"], - ["variable", "%recurse"], - ["label", "recurse:"], - ["variable", "%tmp2"], - ["punctuation", "="], - ["keyword", "sub"], - ["keyword", "i32"], - ["variable", "%a.tr"], - ["punctuation", ","], - ["number", "1"], - ["variable", "%tmp3"], - ["punctuation", "="], - ["keyword", "add"], - ["keyword", "i32"], - ["variable", "%b.tr"], - ["punctuation", ","], - ["number", "1"], - ["keyword", "br"], - ["type", "label"], - ["variable", "%tailrecurse"], - ["label", "done:"], - ["keyword", "ret"], - ["keyword", "i32"], - ["variable", "%b.tr"], - ["punctuation", "}"] + ["keyword", "define"], + ["type", "i32"], + ["variable", "@add"], + ["punctuation", "("], + ["type", "i32"], + ["variable", "%a"], + ["punctuation", ","], + ["type", "i32"], + ["variable", "%b"], + ["punctuation", ")"], + ["punctuation", "{"], + ["label", "entry:"], + ["keyword", "br"], + ["type", "label"], + ["variable", "%tailrecurse"], + ["label", "tailrecurse:"], + ["variable", "%a.tr"], + ["punctuation", "="], + ["keyword", "phi"], + ["type", "i32"], + ["punctuation", "["], + ["variable", "%a"], + ["punctuation", ","], + ["variable", "%entry"], + ["punctuation", "]"], + ["punctuation", ","], + ["punctuation", "["], + ["variable", "%tmp2"], + ["punctuation", ","], + ["variable", "%recurse"], + ["punctuation", "]"], + ["variable", "%b.tr"], + ["punctuation", "="], + ["keyword", "phi"], + ["type", "i32"], + ["punctuation", "["], + ["variable", "%b"], + ["punctuation", ","], + ["variable", "%entry"], + ["punctuation", "]"], + ["punctuation", ","], + ["punctuation", "["], + ["variable", "%tmp3"], + ["punctuation", ","], + ["variable", "%recurse"], + ["punctuation", "]"], + ["variable", "%tmp1"], + ["punctuation", "="], + ["keyword", "icmp"], + ["keyword", "eq"], + ["type", "i32"], + ["variable", "%a.tr"], + ["punctuation", ","], + ["number", "0"], + ["keyword", "br"], + ["type", "i1"], + ["variable", "%tmp1"], + ["punctuation", ","], + ["type", "label"], + ["variable", "%done"], + ["punctuation", ","], + ["type", "label"], + ["variable", "%recurse"], + ["label", "recurse:"], + ["variable", "%tmp2"], + ["punctuation", "="], + ["keyword", "sub"], + ["type", "i32"], + ["variable", "%a.tr"], + ["punctuation", ","], + ["number", "1"], + ["variable", "%tmp3"], + ["punctuation", "="], + ["keyword", "add"], + ["type", "i32"], + ["variable", "%b.tr"], + ["punctuation", ","], + ["number", "1"], + ["keyword", "br"], + ["type", "label"], + ["variable", "%tailrecurse"], + ["label", "done:"], + ["keyword", "ret"], + ["type", "i32"], + ["variable", "%b.tr"], + ["punctuation", "}"] ] ---------------------------------------------------- diff --git a/tests/languages/llvm/example-recursive.test b/tests/languages/llvm/example-recursive.test index 9ed7218e62..50b1573cde 100644 --- a/tests/languages/llvm/example-recursive.test +++ b/tests/languages/llvm/example-recursive.test @@ -16,70 +16,70 @@ done: ---------------------------------------------------- [ - ["keyword", "define"], - ["keyword", "i32"], - ["variable", "@add"], - ["punctuation", "("], - ["keyword", "i32"], - ["variable", "%a"], - ["punctuation", ","], - ["keyword", "i32"], - ["variable", "%b"], - ["punctuation", ")"], - ["punctuation", "{"], - ["label", "entry:"], - ["variable", "%tmp1"], - ["punctuation", "="], - ["keyword", "icmp"], - ["keyword", "eq"], - ["keyword", "i32"], - ["variable", "%a"], - ["punctuation", ","], - ["number", "0"], - ["keyword", "br"], - ["keyword", "i1"], - ["variable", "%tmp1"], - ["punctuation", ","], - ["type", "label"], - ["variable", "%done"], - ["punctuation", ","], - ["type", "label"], - ["variable", "%recurse"], - ["label", "recurse:"], - ["variable", "%tmp2"], - ["punctuation", "="], - ["keyword", "sub"], - ["keyword", "i32"], - ["variable", "%a"], - ["punctuation", ","], - ["number", "1"], - ["variable", "%tmp3"], - ["punctuation", "="], - ["keyword", "add"], - ["keyword", "i32"], - ["variable", "%b"], - ["punctuation", ","], - ["number", "1"], - ["variable", "%tmp4"], - ["punctuation", "="], - ["keyword", "call"], - ["keyword", "i32"], - ["variable", "@add"], - ["punctuation", "("], - ["keyword", "i32"], - ["variable", "%tmp2"], - ["punctuation", ","], - ["keyword", "i32"], - ["variable", "%tmp3"], - ["punctuation", ")"], - ["keyword", "ret"], - ["keyword", "i32"], - ["variable", "%tmp4"], - ["label", "done:"], - ["keyword", "ret"], - ["keyword", "i32"], - ["variable", "%b"], - ["punctuation", "}"] + ["keyword", "define"], + ["type", "i32"], + ["variable", "@add"], + ["punctuation", "("], + ["type", "i32"], + ["variable", "%a"], + ["punctuation", ","], + ["type", "i32"], + ["variable", "%b"], + ["punctuation", ")"], + ["punctuation", "{"], + ["label", "entry:"], + ["variable", "%tmp1"], + ["punctuation", "="], + ["keyword", "icmp"], + ["keyword", "eq"], + ["type", "i32"], + ["variable", "%a"], + ["punctuation", ","], + ["number", "0"], + ["keyword", "br"], + ["type", "i1"], + ["variable", "%tmp1"], + ["punctuation", ","], + ["type", "label"], + ["variable", "%done"], + ["punctuation", ","], + ["type", "label"], + ["variable", "%recurse"], + ["label", "recurse:"], + ["variable", "%tmp2"], + ["punctuation", "="], + ["keyword", "sub"], + ["type", "i32"], + ["variable", "%a"], + ["punctuation", ","], + ["number", "1"], + ["variable", "%tmp3"], + ["punctuation", "="], + ["keyword", "add"], + ["type", "i32"], + ["variable", "%b"], + ["punctuation", ","], + ["number", "1"], + ["variable", "%tmp4"], + ["punctuation", "="], + ["keyword", "call"], + ["type", "i32"], + ["variable", "@add"], + ["punctuation", "("], + ["type", "i32"], + ["variable", "%tmp2"], + ["punctuation", ","], + ["type", "i32"], + ["variable", "%tmp3"], + ["punctuation", ")"], + ["keyword", "ret"], + ["type", "i32"], + ["variable", "%tmp4"], + ["label", "done:"], + ["keyword", "ret"], + ["type", "i32"], + ["variable", "%b"], + ["punctuation", "}"] ] ---------------------------------------------------- diff --git a/tests/languages/llvm/integers.test b/tests/languages/llvm/integers.test new file mode 100644 index 0000000000..d0922d6ef4 --- /dev/null +++ b/tests/languages/llvm/integers.test @@ -0,0 +1,49 @@ +0 +1 ++1 +-1 +0xdeadbeef +0x123456789ABCDEF +-0x2 + ++1.0 +2.7e3 +-1.0e+3 + +double 0x432ff973cafa8000 +double 4.5e+15 ; equivalent forms as mentioned in the LangRef + +0xK0123456789ABCDEFabcd ; x86_fp80 +0xM0123456789ABCDEF0123456789abcdef ; ppc_fp128 +0xL0123456789ABCDEF0123456789abcdef ; fp128 +0xHFACE ; half + +---------------------------------------------------- + +[ + ["number", "0"], + ["number", "1"], + ["number", "+1"], + ["number", "-1"], + ["number", "0xdeadbeef"], + ["number", "0x123456789ABCDEF"], + ["number", "-0x2"], + ["number", "+1.0"], + ["number", "2.7e3"], + ["number", "-1.0e+3"], + ["type", "double"], + ["number", "0x432ff973cafa8000"], + ["type", "double"], + ["number", "4.5e+15"], + ["comment", "; equivalent forms as mentioned in the LangRef"], + ["number", "0xK0123456789ABCDEFabcd"], + ["comment", "; x86_fp80"], + ["number", "0xM0123456789ABCDEF0123456789abcdef"], + ["comment", "; ppc_fp128"], + ["number", "0xL0123456789ABCDEF0123456789abcdef"], + ["comment", "; fp128"], + ["number", "0xHFACE"], + ["comment", "; half"] +] + +---------------------------------------------------- diff --git a/tests/languages/llvm/langref-module-example.test b/tests/languages/llvm/langref-module-example.test index 08d71439cc..b9b5e9154a 100644 --- a/tests/languages/llvm/langref-module-example.test +++ b/tests/languages/llvm/langref-module-example.test @@ -21,92 +21,92 @@ define i32 @main() { ; i32()* ---------------------------------------------------- [ - ["comment", "; Declare the string constant as a global constant."], - ["variable", "@.str"], - ["punctuation", "="], - ["keyword", "private"], - ["keyword", "unnamed_addr"], - ["keyword", "constant"], - ["punctuation", "["], - ["number", "13"], - ["keyword", "x"], - ["keyword", "i8"], - ["punctuation", "]"], - ["keyword", "c"], - ["string", "\"hello world\\0A\\00\""], - ["comment", "; External declaration of the puts function"], - ["keyword", "declare"], - ["keyword", "i32"], - ["variable", "@puts"], - ["punctuation", "("], - ["keyword", "i8"], - ["punctuation", "*"], - ["keyword", "nocapture"], - ["punctuation", ")"], - ["keyword", "nounwind"], - ["comment", "; Definition of main function"], - ["keyword", "define"], - ["keyword", "i32"], - ["variable", "@main"], - ["punctuation", "("], - ["punctuation", ")"], - ["punctuation", "{"], - ["comment", "; i32()*"], - ["comment", "; Convert [13 x i8]* to i8*..."], - ["variable", "%cast210"], - ["punctuation", "="], - ["keyword", "getelementptr"], - ["punctuation", "["], - ["number", "13"], - ["keyword", "x"], - ["keyword", "i8"], - ["punctuation", "]"], - ["punctuation", ","], - ["punctuation", "["], - ["number", "13"], - ["keyword", "x"], - ["keyword", "i8"], - ["punctuation", "]"], - ["punctuation", "*"], - ["variable", "@.str"], - ["punctuation", ","], - ["keyword", "i64"], - ["number", "0"], - ["punctuation", ","], - ["keyword", "i64"], - ["number", "0"], - ["comment", "; Call puts function to write out the string to stdout."], - ["keyword", "call"], - ["keyword", "i32"], - ["variable", "@puts"], - ["punctuation", "("], - ["keyword", "i8"], - ["punctuation", "*"], - ["variable", "%cast210"], - ["punctuation", ")"], - ["keyword", "ret"], - ["keyword", "i32"], - ["number", "0"], - ["punctuation", "}"], - ["comment", "; Named metadata"], - ["variable", "!0"], - ["punctuation", "="], - ["punctuation", "!"], - ["punctuation", "{"], - ["keyword", "i32"], - ["number", "42"], - ["punctuation", ","], - ["keyword", "null"], - ["punctuation", ","], - ["punctuation", "!"], - ["string", "\"string\""], - ["punctuation", "}"], - ["variable", "!foo"], - ["punctuation", "="], - ["punctuation", "!"], - ["punctuation", "{"], - ["variable", "!0"], - ["punctuation", "}"] + ["comment", "; Declare the string constant as a global constant."], + ["variable", "@.str"], + ["punctuation", "="], + ["keyword", "private"], + ["keyword", "unnamed_addr"], + ["keyword", "constant"], + ["punctuation", "["], + ["number", "13"], + ["keyword", "x"], + ["type", "i8"], + ["punctuation", "]"], + ["keyword", "c"], + ["string", "\"hello world\\0A\\00\""], + ["comment", "; External declaration of the puts function"], + ["keyword", "declare"], + ["type", "i32"], + ["variable", "@puts"], + ["punctuation", "("], + ["type", "i8"], + ["punctuation", "*"], + ["keyword", "nocapture"], + ["punctuation", ")"], + ["keyword", "nounwind"], + ["comment", "; Definition of main function"], + ["keyword", "define"], + ["type", "i32"], + ["variable", "@main"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["comment", "; i32()*"], + ["comment", "; Convert [13 x i8]* to i8*..."], + ["variable", "%cast210"], + ["punctuation", "="], + ["keyword", "getelementptr"], + ["punctuation", "["], + ["number", "13"], + ["keyword", "x"], + ["type", "i8"], + ["punctuation", "]"], + ["punctuation", ","], + ["punctuation", "["], + ["number", "13"], + ["keyword", "x"], + ["type", "i8"], + ["punctuation", "]"], + ["punctuation", "*"], + ["variable", "@.str"], + ["punctuation", ","], + ["type", "i64"], + ["number", "0"], + ["punctuation", ","], + ["type", "i64"], + ["number", "0"], + ["comment", "; Call puts function to write out the string to stdout."], + ["keyword", "call"], + ["type", "i32"], + ["variable", "@puts"], + ["punctuation", "("], + ["type", "i8"], + ["punctuation", "*"], + ["variable", "%cast210"], + ["punctuation", ")"], + ["keyword", "ret"], + ["type", "i32"], + ["number", "0"], + ["punctuation", "}"], + ["comment", "; Named metadata"], + ["variable", "!0"], + ["punctuation", "="], + ["punctuation", "!"], + ["punctuation", "{"], + ["type", "i32"], + ["number", "42"], + ["punctuation", ","], + ["keyword", "null"], + ["punctuation", ","], + ["punctuation", "!"], + ["string", "\"string\""], + ["punctuation", "}"], + ["variable", "!foo"], + ["punctuation", "="], + ["punctuation", "!"], + ["punctuation", "{"], + ["variable", "!0"], + ["punctuation", "}"] ] ---------------------------------------------------- From 8833282a24179b86f43c4b42b004d9d00029f0aa Mon Sep 17 00:00:00 2001 From: Cassie Jones Date: Mon, 23 Mar 2020 15:16:15 -0400 Subject: [PATCH 3/3] Second round of review changes for LLVM IR --- components/prism-llvm.js | 16 +++++++------- components/prism-llvm.min.js | 2 +- tests/languages/llvm/edge-cases.test | 11 ---------- .../llvm/{integers.test => numbers.test} | 8 ++----- tests/languages/llvm/string.test | 22 +++++++++++++++++++ 5 files changed, 33 insertions(+), 26 deletions(-) delete mode 100644 tests/languages/llvm/edge-cases.test rename tests/languages/llvm/{integers.test => numbers.test} (89%) create mode 100644 tests/languages/llvm/string.test diff --git a/components/prism-llvm.js b/components/prism-llvm.js index f22be3f060..36f85d37a7 100644 --- a/components/prism-llvm.js +++ b/components/prism-llvm.js @@ -2,18 +2,18 @@ Prism.languages.llvm = { 'comment': /;.*/, 'string': { - pattern: /"[^"]*"/, - greedy: true, - }, - 'boolean': /\b(?:true|false)\b/, + pattern: /"[^"]*"/, + greedy: true, + }, + 'boolean': /\b(?:true|false)\b/, 'variable': /[%@!#](?:(?!\d)(?:[-$.\w]|\\[a-f\d]{2})+|\d+)/i, 'label': /(?!\d)(?:[-$.\w]|\\[a-f\d]{2})+:/i, 'type': { - pattern: /\b(?:double|float|fp128|half|i[1-9]\d*|label|metadata|ppc_fp128|token|void|x86_fp80|x86_mmx)\b/, - alias: 'class-name', - }, + pattern: /\b(?:double|float|fp128|half|i[1-9]\d*|label|metadata|ppc_fp128|token|void|x86_fp80|x86_mmx)\b/, + alias: 'class-name', + }, 'keyword': /\b[a-z_][a-z_0-9]*\b/, - 'number': /[+-]?\b\d+(?:.\d+)?(?:[eE][+-]?\d+)?\b|\b0x[\dA-Fa-f]+\b|\b0xK[\dA-Fa-f]{20}\b|\b0x[ML][\dA-Fa-f]{32}\b|\b0xH[\dA-Fa-f]{4}\b/, + 'number': /[+-]?\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b|\b0x[\dA-Fa-f]+\b|\b0xK[\dA-Fa-f]{20}\b|\b0x[ML][\dA-Fa-f]{32}\b|\b0xH[\dA-Fa-f]{4}\b/, 'punctuation': /[{}[\];(),.!*=<>]/, }; }(Prism)); diff --git a/components/prism-llvm.min.js b/components/prism-llvm.min.js index bca19fdb29..e0b0636b27 100644 --- a/components/prism-llvm.min.js +++ b/components/prism-llvm.min.js @@ -1 +1 @@ -Prism.languages.llvm={comment:/;.*/,string:{pattern:/"[^"]*"/,greedy:!0},boolean:/\b(?:true|false)\b/,variable:/[%@!#](?:(?!\d)(?:[-$.\w]|\\[a-f\d]{2})+|\d+)/i,label:/(?!\d)(?:[-$.\w]|\\[a-f\d]{2})+:/i,type:{pattern:/\b(?:double|float|fp128|half|i[1-9]\d*|label|metadata|ppc_fp128|token|void|x86_fp80|x86_mmx)\b/,alias:"class-name"},keyword:/\b[a-z_][a-z_0-9]*\b/,number:/[+-]?\b\d+(?:.\d+)?(?:[eE][+-]?\d+)?\b|\b0x[\dA-Fa-f]+\b|\b0xK[\dA-Fa-f]{20}\b|\b0x[ML][\dA-Fa-f]{32}\b|\b0xH[\dA-Fa-f]{4}\b/,punctuation:/[{}[\];(),.!*=<>]/}; \ No newline at end of file +Prism.languages.llvm={comment:/;.*/,string:{pattern:/"[^"]*"/,greedy:!0},boolean:/\b(?:true|false)\b/,variable:/[%@!#](?:(?!\d)(?:[-$.\w]|\\[a-f\d]{2})+|\d+)/i,label:/(?!\d)(?:[-$.\w]|\\[a-f\d]{2})+:/i,type:{pattern:/\b(?:double|float|fp128|half|i[1-9]\d*|label|metadata|ppc_fp128|token|void|x86_fp80|x86_mmx)\b/,alias:"class-name"},keyword:/\b[a-z_][a-z_0-9]*\b/,number:/[+-]?\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b|\b0x[\dA-Fa-f]+\b|\b0xK[\dA-Fa-f]{20}\b|\b0x[ML][\dA-Fa-f]{32}\b|\b0xH[\dA-Fa-f]{4}\b/,punctuation:/[{}[\];(),.!*=<>]/}; \ No newline at end of file diff --git a/tests/languages/llvm/edge-cases.test b/tests/languages/llvm/edge-cases.test deleted file mode 100644 index fe7d06e06f..0000000000 --- a/tests/languages/llvm/edge-cases.test +++ /dev/null @@ -1,11 +0,0 @@ -" ; " - ----------------------------------------------------- - -[ - ["string", "\" ; \""] -] - ----------------------------------------------------- - -Specific edge-cases diff --git a/tests/languages/llvm/integers.test b/tests/languages/llvm/numbers.test similarity index 89% rename from tests/languages/llvm/integers.test rename to tests/languages/llvm/numbers.test index d0922d6ef4..2c700b1605 100644 --- a/tests/languages/llvm/integers.test +++ b/tests/languages/llvm/numbers.test @@ -2,9 +2,6 @@ 1 +1 -1 -0xdeadbeef -0x123456789ABCDEF --0x2 +1.0 2.7e3 @@ -25,9 +22,6 @@ double 4.5e+15 ; equivalent forms as mentioned in the LangRef ["number", "1"], ["number", "+1"], ["number", "-1"], - ["number", "0xdeadbeef"], - ["number", "0x123456789ABCDEF"], - ["number", "-0x2"], ["number", "+1.0"], ["number", "2.7e3"], ["number", "-1.0e+3"], @@ -47,3 +41,5 @@ double 4.5e+15 ; equivalent forms as mentioned in the LangRef ] ---------------------------------------------------- + +Numeric literals. diff --git a/tests/languages/llvm/string.test b/tests/languages/llvm/string.test new file mode 100644 index 0000000000..dc083f356c --- /dev/null +++ b/tests/languages/llvm/string.test @@ -0,0 +1,22 @@ +" ; " +"" +"\00\FF" +"\22\5cI appreciate that LLVM strings only one kind of escaping" +"/some/path" +b"hello" + +---------------------------------------------------- + +[ + ["string", "\" ; \""], + ["string", "\"\""], + ["string", "\"\\00\\FF\""], + ["string", "\"\\22\\5cI appreciate that LLVM strings only one kind of escaping\""], + ["string", "\"/some/path\""], + ["keyword", "b"], + ["string", "\"hello\""] +] + +---------------------------------------------------- + +Different string literals.