From a7cf56b7a34128441e5fcc32faf8e83f8075185e Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Thu, 29 Aug 2019 16:25:02 +0200 Subject: [PATCH] Added suppprt for Zig (#2019) This adds support for the Zig language. https://ziglang.org/ --- components.js | 2 +- components.json | 4 + components/prism-zig.js | 97 ++++ components/prism-zig.min.js | 1 + examples/prism-zig.html | 46 ++ .../languages/zig/builtin-types_feature.test | 75 +++ tests/languages/zig/builtin_feature.test | 417 +++++++++++++++ tests/languages/zig/class-name_feature.test | 504 ++++++++++++++++++ tests/languages/zig/keyword_feature.test | 105 ++++ tests/languages/zig/label_feature.test | 75 +++ tests/languages/zig/number_feature.test | 22 + tests/languages/zig/operator_feature.test | 73 +++ tests/languages/zig/punctuation_feature.test | 21 + 13 files changed, 1441 insertions(+), 1 deletion(-) create mode 100644 components/prism-zig.js create mode 100644 components/prism-zig.min.js create mode 100644 examples/prism-zig.html create mode 100644 tests/languages/zig/builtin-types_feature.test create mode 100644 tests/languages/zig/builtin_feature.test create mode 100644 tests/languages/zig/class-name_feature.test create mode 100644 tests/languages/zig/keyword_feature.test create mode 100644 tests/languages/zig/label_feature.test create mode 100644 tests/languages/zig/number_feature.test create mode 100644 tests/languages/zig/operator_feature.test create mode 100644 tests/languages/zig/punctuation_feature.test diff --git a/components.js b/components.js index 05cdf006c6..64edbb207b 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","peerDependencies":"markup"},"clike":{"title":"C-like","option":"default","overrideExampleHeader":true},"javascript":{"title":"JavaScript","require":"clike","peerDependencies":"markup","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"abnf":{"title":"Augmented Backus–Naur form","owner":"RunDevelopment"},"actionscript":{"title":"ActionScript","require":"javascript","peerDependencies":"markup","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"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"},"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"},"bro":{"title":"Bro","owner":"wayward710"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"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","owner":"milesj"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"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"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"firestore-security-rules":{"title":"Firestore security rules","require":"clike","owner":"RunDevelopment"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"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","peerDependencies":["css","coffeescript","erb","javascript","less","markdown","ruby","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","peerDependencies":["javascript","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"],"peerDependencies":["scala"],"owner":"RunDevelopment"},"javadoclike":{"title":"JavaDoc-like","peerDependencies":["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"],"peerDependencies":["actionscript","coffeescript"],"owner":"RunDevelopment"},"js-extras":{"title":"JS Extras","require":"javascript","peerDependencies":["actionscript","coffeescript","flow","n4js","typescript"],"owner":"RunDevelopment"},"js-templates":{"title":"JS Templates","require":"javascript","peerDependencies":["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"},"less":{"title":"Less","require":"css","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"},"n1ql":{"title":"N1QL","owner":"TMWilds"},"n4js":{"title":"N4JS","require":"javascript","peerDependencies":["jsdoc"],"alias":"n4jsd","owner":"bsmith-n4"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","owner":"stephanmax"},"nasm":{"title":"NASM","owner":"rbmj"},"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":"cpp","peerDependencies":["c","cpp"],"overrideExampleHeader":true,"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"],"owner":"RunDevelopment"},"php-extras":{"title":"PHP Extras","require":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"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"],"peerDependencies":["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],"owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","peerDependencies":["c","cpp","fortran"],"owner":"Golmote"},"python":{"title":"Python","alias":"py","owner":"multipetros"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"jsx":{"title":"React JSX","require":["markup","javascript"],"peerDependencies":["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","peerDependencies":["actionscript","coffeescript","flow","javascript","typescript","vala"],"owner":"RunDevelopment"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"ruby":{"title":"Ruby","require":"clike","alias":"rb","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","require":"sql","owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","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"},"soy":{"title":"Soy (Closure Template)","require":"markup-templating","owner":"Golmote"},"splunk-spl":{"title":"Splunk SPL","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","peerDependencies":"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","peerDependencies":"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"}},"plugins":{"meta":{"path":"plugins/{id}/prism-{id}","link":"plugins/{id}/"},"line-highlight":"Line Highlight","line-numbers":{"title":"Line Numbers","owner":"kuba-kubula"},"show-invisibles":{"title":"Show Invisibles","after":["autolinker","data-uri-highlight"]},"autolinker":"Autolinker","wpd":"WebPlatform Docs","custom-class":{"title":"Custom Class","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","noCSS":true},"show-language":{"title":"Show Language","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","owner":"Golmote","noCSS":true},"previewers":{"title":"Previewers","owner":"Golmote"},"autoloader":{"title":"Autoloader","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","owner":"Golmote","after":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","owner":"chriswells0"},"unescaped-markup":"Unescaped Markup","normalize-whitespace":{"title":"Normalize Whitespace","owner":"zeitgeist87","after":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","owner":"mAAdhaTTah","require":"toolbar","noCSS":true},"diff-highlight":{"title":"Diff Highlight","owner":"RunDevelopment","require":"diff"}}}; +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","peerDependencies":"markup"},"clike":{"title":"C-like","option":"default","overrideExampleHeader":true},"javascript":{"title":"JavaScript","require":"clike","peerDependencies":"markup","alias":"js","option":"default"},"abap":{"title":"ABAP","owner":"dellagustin"},"abnf":{"title":"Augmented Backus–Naur form","owner":"RunDevelopment"},"actionscript":{"title":"ActionScript","require":"javascript","peerDependencies":"markup","owner":"Golmote"},"ada":{"title":"Ada","owner":"Lucretia"},"apacheconf":{"title":"Apache Configuration","owner":"GuiTeK"},"apl":{"title":"APL","owner":"ngn"},"applescript":{"title":"AppleScript","owner":"Golmote"},"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"},"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"},"bro":{"title":"Bro","owner":"wayward710"},"c":{"title":"C","require":"clike","owner":"zeitgeist87"},"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","owner":"milesj"},"d":{"title":"D","require":"clike","owner":"Golmote"},"dart":{"title":"Dart","require":"clike","owner":"Golmote"},"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"},"erb":{"title":"ERB","require":["ruby","markup-templating"],"owner":"Golmote"},"erlang":{"title":"Erlang","owner":"Golmote"},"fsharp":{"title":"F#","require":"clike","owner":"simonreynolds7"},"firestore-security-rules":{"title":"Firestore security rules","require":"clike","owner":"RunDevelopment"},"flow":{"title":"Flow","require":"javascript","owner":"Golmote"},"fortran":{"title":"Fortran","owner":"Golmote"},"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","peerDependencies":["css","coffeescript","erb","javascript","less","markdown","ruby","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","peerDependencies":["javascript","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"],"peerDependencies":["scala"],"owner":"RunDevelopment"},"javadoclike":{"title":"JavaDoc-like","peerDependencies":["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"],"peerDependencies":["actionscript","coffeescript"],"owner":"RunDevelopment"},"js-extras":{"title":"JS Extras","require":"javascript","peerDependencies":["actionscript","coffeescript","flow","n4js","typescript"],"owner":"RunDevelopment"},"js-templates":{"title":"JS Templates","require":"javascript","peerDependencies":["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"},"less":{"title":"Less","require":"css","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"},"n1ql":{"title":"N1QL","owner":"TMWilds"},"n4js":{"title":"N4JS","require":"javascript","peerDependencies":["jsdoc"],"alias":"n4jsd","owner":"bsmith-n4"},"nand2tetris-hdl":{"title":"Nand To Tetris HDL","owner":"stephanmax"},"nasm":{"title":"NASM","owner":"rbmj"},"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":"cpp","peerDependencies":["c","cpp"],"overrideExampleHeader":true,"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"],"owner":"RunDevelopment"},"php-extras":{"title":"PHP Extras","require":"php","owner":"milesj"},"plsql":{"title":"PL/SQL","require":"sql","owner":"Golmote"},"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"],"peerDependencies":["coffeescript","ejs","handlebars","less","livescript","markdown","scss","stylus","twig"],"owner":"Golmote"},"puppet":{"title":"Puppet","owner":"Golmote"},"pure":{"title":"Pure","peerDependencies":["c","cpp","fortran"],"owner":"Golmote"},"python":{"title":"Python","alias":"py","owner":"multipetros"},"q":{"title":"Q (kdb+ database)","owner":"Golmote"},"qore":{"title":"Qore","require":"clike","owner":"temnroegg"},"r":{"title":"R","owner":"Golmote"},"jsx":{"title":"React JSX","require":["markup","javascript"],"peerDependencies":["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","peerDependencies":["actionscript","coffeescript","flow","javascript","typescript","vala"],"owner":"RunDevelopment"},"rest":{"title":"reST (reStructuredText)","owner":"Golmote"},"rip":{"title":"Rip","owner":"ravinggenius"},"roboconf":{"title":"Roboconf","owner":"Golmote"},"ruby":{"title":"Ruby","require":"clike","alias":"rb","owner":"samflores"},"rust":{"title":"Rust","owner":"Golmote"},"sas":{"title":"SAS","require":"sql","owner":"Golmote"},"sass":{"title":"Sass (Sass)","require":"css","owner":"Golmote"},"scss":{"title":"Sass (Scss)","require":"css","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"},"soy":{"title":"Soy (Closure Template)","require":"markup-templating","owner":"Golmote"},"splunk-spl":{"title":"Splunk SPL","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","peerDependencies":"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","peerDependencies":"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":"Line Highlight","line-numbers":{"title":"Line Numbers","owner":"kuba-kubula"},"show-invisibles":{"title":"Show Invisibles","after":["autolinker","data-uri-highlight"]},"autolinker":"Autolinker","wpd":"WebPlatform Docs","custom-class":{"title":"Custom Class","owner":"dvkndn","noCSS":true},"file-highlight":{"title":"File Highlight","noCSS":true},"show-language":{"title":"Show Language","owner":"nauzilus","noCSS":true,"require":"toolbar"},"jsonp-highlight":{"title":"JSONP Highlight","noCSS":true,"owner":"nauzilus"},"highlight-keywords":{"title":"Highlight Keywords","owner":"vkbansal","noCSS":true},"remove-initial-line-feed":{"title":"Remove initial line feed","owner":"Golmote","noCSS":true},"previewers":{"title":"Previewers","owner":"Golmote"},"autoloader":{"title":"Autoloader","owner":"Golmote","noCSS":true},"keep-markup":{"title":"Keep Markup","owner":"Golmote","after":"normalize-whitespace","noCSS":true},"command-line":{"title":"Command Line","owner":"chriswells0"},"unescaped-markup":"Unescaped Markup","normalize-whitespace":{"title":"Normalize Whitespace","owner":"zeitgeist87","after":"unescaped-markup","noCSS":true},"data-uri-highlight":{"title":"Data-URI Highlight","owner":"Golmote","noCSS":true},"toolbar":{"title":"Toolbar","owner":"mAAdhaTTah"},"copy-to-clipboard":{"title":"Copy to Clipboard Button","owner":"mAAdhaTTah","require":"toolbar","noCSS":true},"diff-highlight":{"title":"Diff Highlight","owner":"RunDevelopment","require":"diff"}}}; if (typeof module !== 'undefined' && module.exports) { module.exports = components; } \ No newline at end of file diff --git a/components.json b/components.json index 5d3ec55902..8fecd06e62 100644 --- a/components.json +++ b/components.json @@ -1005,6 +1005,10 @@ "title": "YAML", "alias": "yml", "owner": "hason" + }, + "zig": { + "title": "Zig", + "owner": "RunDevelopment" } }, "plugins": { diff --git a/components/prism-zig.js b/components/prism-zig.js new file mode 100644 index 0000000000..64f1bdc24a --- /dev/null +++ b/components/prism-zig.js @@ -0,0 +1,97 @@ +(function (Prism) { + + var keyword = /\b(?:align|allowzero|and|asm|async|await|break|cancel|catch|comptime|const|continue|defer|else|enum|errdefer|error|export|extern|fn|for|if|inline|linksection|nakedcc|noalias|null|or|orelse|packed|promise|pub|resume|return|stdcallcc|struct|suspend|switch|test|threadlocal|try|undefined|union|unreachable|usingnamespace|var|volatile|while)\b/; + + var IDENTIFIER = '\\b(?!' + keyword.source + ')(?!\\d)\\w+\\b'; + var ALIGN = /align\s*\((?:[^()]|\([^()]*\))*\)/.source; + var PREFIX_TYPE_OP = /(?:\?|\bpromise->|(?:\[[^[\]]*\]|\*(?!\*)|\*\*)(?:\s*|\s*const\b|\s*volatile\b|\s*allowzero\b)*)/.source.replace(//g, ALIGN); + var SUFFIX_EXPR = /(?:\bpromise\b|(?:\berror\.)?(?:\.)*(?!\s+))/.source.replace(//g, IDENTIFIER); + var TYPE = '(?!\\s)(?:!?\\s*(?:' + PREFIX_TYPE_OP + '\\s*)*' + SUFFIX_EXPR + ')+'; + + /* + * A simplified grammar for Zig compile time type literals: + * + * TypeExpr = ( "!"? PREFIX_TYPE_OP* SUFFIX_EXPR )+ + * + * SUFFIX_EXPR = ( \b "promise" \b | ( \b "error" "." )? IDENTIFIER ( "." IDENTIFIER )* (?! \s+ IDENTIFIER ) ) + * + * PREFIX_TYPE_OP = "?" + * | \b "promise" "->" + * | ( "[" [^\[\]]* "]" | "*" | "**" ) ( ALIGN | "const" \b | "volatile" \b | "allowzero" \b )* + * + * ALIGN = "align" "(" ( [^()] | "(" [^()]* ")" )* ")" + * + * IDENTIFIER = \b (?! KEYWORD ) [a-zA-Z_] \w* \b + * + */ + + Prism.languages.zig = { + 'comment': [ + { + pattern: /\/{3}.*/, + alias: 'doc-comment' + }, + /\/{2}.*/ + ], + 'string': [ + { + // "string" and c"string" + pattern: /(^|[^\\@])c?"(?:[^"\\\r\n]|\\.)*"/, + lookbehind: true, + greedy: true + }, + { + // multiline strings and c-strings + pattern: /([\r\n])([ \t]+c?\\{2}).*(?:(?:\r\n?|\n)\2.*)*/, + lookbehind: true, + greedy: true + }, + { + // characters 'a', '\n', '\xFF', '\u{10FFFF}' + pattern: /(^|[^\\])'(?:[^'\\\r\n]|\\(?:.|x[a-fA-F\d]{2}|u\{[a-fA-F\d]{1,6}\}))'/, + lookbehind: true, + greedy: true + } + ], + 'builtin': /\B@(?!\d)\w+(?=\s*\()/, + 'label': { + pattern: /(\b(?:break|continue)\s*:\s*)\w+\b|\b(?!\d)\w+\b(?=\s*:\s*(?:\{|while\b))/, + lookbehind: true + }, + 'class-name': [ + // const Foo = struct {}; + /\b(?!\d)\w+(?=\s*=\s*(?:(?:extern|packed)\s+)?(?:enum|struct|union)\s*[({])/, + { + // const x: i32 = 9; + // var x: Bar; + // fn foo(x: bool, y: f32) void {} + pattern: RegExp(/(:\s*)(?=\s*(?:\s*)?[=;,)])|(?=\s*(?:\s*)?\{)/.source.replace(//g, TYPE).replace(//g, ALIGN)), + lookbehind: true, + inside: null // see below + }, + { + // extern fn foo(x: f64) f64; (optional alignment) + pattern: RegExp(/(\)\s*)(?=\s*(?:\s*)?;)/.source.replace(//g, TYPE).replace(//g, ALIGN)), + lookbehind: true, + inside: null // see below + } + ], + 'builtin-types': { + pattern: /\b(?:anyerror|bool|c_u?(?:short|int|long|longlong)|c_longdouble|c_void|comptime_(?:float|int)|[iu](?:8|16|32|64|128|size)|f(?:16|32|64|128)|noreturn|type|void)\b/, + alias: 'keyword' + }, + 'keyword': keyword, + 'function': /\b(?!\d)\w+(?=\s*\()/, + 'number': /\b(?:0b[01]+|0o[0-7]+|0x[a-fA-F\d]+\.?[a-fA-F\d]*(?:[pP][+-]?[a-fA-F\d]+)?|\d+\.?\d*(?:[eE][+-]?\d+)?)\b/, + 'boolean': /\b(?:false|true)\b/, + 'operator': /\.[*?]|\.{2,3}|[-=]>|\*\*|\+\+|\|\||(?:<<|>>|[-+*]%|[-+*/%^&|<>!=])=?|[?~]/, + 'punctuation': /[.:,;(){}[\]]/ + }; + + Prism.languages.zig['class-name'].forEach(function (obj) { + if (obj.inside === null) { + obj.inside = Prism.languages.zig; + } + }); + +}(Prism)); diff --git a/components/prism-zig.min.js b/components/prism-zig.min.js new file mode 100644 index 0000000000..968859607d --- /dev/null +++ b/components/prism-zig.min.js @@ -0,0 +1 @@ +!function(n){var e=/\b(?:align|allowzero|and|asm|async|await|break|cancel|catch|comptime|const|continue|defer|else|enum|errdefer|error|export|extern|fn|for|if|inline|linksection|nakedcc|noalias|null|or|orelse|packed|promise|pub|resume|return|stdcallcc|struct|suspend|switch|test|threadlocal|try|undefined|union|unreachable|usingnamespace|var|volatile|while)\b/,a="\\b(?!"+e.source+")(?!\\d)\\w+\\b",r="align\\s*\\((?:[^()]|\\([^()]*\\))*\\)",s="(?!\\s)(?:!?\\s*(?:"+"(?:\\?|\\bpromise->|(?:\\[[^[\\]]*\\]|\\*(?!\\*)|\\*\\*)(?:\\s*|\\s*const\\b|\\s*volatile\\b|\\s*allowzero\\b)*)".replace(//g,r)+"\\s*)*"+"(?:\\bpromise\\b|(?:\\berror\\.)?(?:\\.)*(?!\\s+))".replace(//g,a)+")+";n.languages.zig={comment:[{pattern:/\/{3}.*/,alias:"doc-comment"},/\/{2}.*/],string:[{pattern:/(^|[^\\@])c?"(?:[^"\\\r\n]|\\.)*"/,lookbehind:!0,greedy:!0},{pattern:/([\r\n])([ \t]+c?\\{2}).*(?:(?:\r\n?|\n)\2.*)*/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\])'(?:[^'\\\r\n]|\\(?:.|x[a-fA-F\d]{2}|u\{[a-fA-F\d]{1,6}\}))'/,lookbehind:!0,greedy:!0}],builtin:/\B@(?!\d)\w+(?=\s*\()/,label:{pattern:/(\b(?:break|continue)\s*:\s*)\w+\b|\b(?!\d)\w+\b(?=\s*:\s*(?:\{|while\b))/,lookbehind:!0},"class-name":[/\b(?!\d)\w+(?=\s*=\s*(?:(?:extern|packed)\s+)?(?:enum|struct|union)\s*[({])/,{pattern:RegExp("(:\\s*)(?=\\s*(?:\\s*)?[=;,)])|(?=\\s*(?:\\s*)?\\{)".replace(//g,s).replace(//g,r)),lookbehind:!0,inside:null},{pattern:RegExp("(\\)\\s*)(?=\\s*(?:\\s*)?;)".replace(//g,s).replace(//g,r)),lookbehind:!0,inside:null}],"builtin-types":{pattern:/\b(?:anyerror|bool|c_u?(?:short|int|long|longlong)|c_longdouble|c_void|comptime_(?:float|int)|[iu](?:8|16|32|64|128|size)|f(?:16|32|64|128)|noreturn|type|void)\b/,alias:"keyword"},keyword:e,function:/\b(?!\d)\w+(?=\s*\()/,number:/\b(?:0b[01]+|0o[0-7]+|0x[a-fA-F\d]+\.?[a-fA-F\d]*(?:[pP][+-]?[a-fA-F\d]+)?|\d+\.?\d*(?:[eE][+-]?\d+)?)\b/,boolean:/\b(?:false|true)\b/,operator:/\.[*?]|\.{2,3}|[-=]>|\*\*|\+\+|\|\||(?:<<|>>|[-+*]%|[-+*/%^&|<>!=])=?|[?~]/,punctuation:/[.:,;(){}[\]]/},n.languages.zig["class-name"].forEach(function(e){null===e.inside&&(e.inside=n.languages.zig)})}(Prism); \ No newline at end of file diff --git a/examples/prism-zig.html b/examples/prism-zig.html new file mode 100644 index 0000000000..67bf148cd3 --- /dev/null +++ b/examples/prism-zig.html @@ -0,0 +1,46 @@ +

Full example

+
const std = @import("std");
+
+pub fn main() !void {
+    // If this program is run without stdout attached, exit with an error.
+    const stdout_file = try std.io.getStdOut();
+    // If this program encounters pipe failure when printing to stdout, exit
+    // with an error.
+    try stdout_file.write("Hello, world!\n");
+}
+
+const warn = @import("std").debug.warn;
+
+pub fn main() void {
+    warn("Hello, world!\n");
+}
+
+const assert = @import("std").debug.assert;
+
+test "comments" {
+    // Comments in Zig start with "//" and end at the next LF byte (end of line).
+    // The below line is a comment, and won't be executed.
+
+    //assert(false);
+
+    const x = true;  // another comment
+    assert(x);
+}
+
+/// A structure for storing a timestamp, with nanosecond precision (this is a
+/// multiline doc comment).
+const Timestamp = struct {
+    /// The number of seconds since the epoch (this is also a doc comment).
+    seconds: i64,  // signed so we can represent pre-1970 (not a doc comment)
+    /// The number of nanoseconds past the second (doc comment again).
+    nanos: u32,
+
+    /// Returns a `Timestamp` struct representing the Unix epoch; that is, the
+    /// moment of 1970 Jan 1 00:00:00 UTC (this is a doc comment too).
+    pub fn unixEpoch() Timestamp {
+        return Timestamp{
+            .seconds = 0,
+            .nanos = 0,
+        };
+    }
+};
diff --git a/tests/languages/zig/builtin-types_feature.test b/tests/languages/zig/builtin-types_feature.test new file mode 100644 index 0000000000..7af60750a9 --- /dev/null +++ b/tests/languages/zig/builtin-types_feature.test @@ -0,0 +1,75 @@ +i8 +u8 +i16 +u16 +i32 +u32 +i64 +u64 +i128 +u128 +isize +usize +c_short +c_ushort +c_int +c_uint +c_long +c_ulong +c_longlong +c_ulonglong +c_longdouble +c_void +f16 +f32 +f64 +f128 +bool +void +noreturn +type +anyerror +comptime_int +comptime_float + +---------------------------------------------------- + +[ + ["builtin-types", "i8"], + ["builtin-types", "u8"], + ["builtin-types", "i16"], + ["builtin-types", "u16"], + ["builtin-types", "i32"], + ["builtin-types", "u32"], + ["builtin-types", "i64"], + ["builtin-types", "u64"], + ["builtin-types", "i128"], + ["builtin-types", "u128"], + ["builtin-types", "isize"], + ["builtin-types", "usize"], + ["builtin-types", "c_short"], + ["builtin-types", "c_ushort"], + ["builtin-types", "c_int"], + ["builtin-types", "c_uint"], + ["builtin-types", "c_long"], + ["builtin-types", "c_ulong"], + ["builtin-types", "c_longlong"], + ["builtin-types", "c_ulonglong"], + ["builtin-types", "c_longdouble"], + ["builtin-types", "c_void"], + ["builtin-types", "f16"], + ["builtin-types", "f32"], + ["builtin-types", "f64"], + ["builtin-types", "f128"], + ["builtin-types", "bool"], + ["builtin-types", "void"], + ["builtin-types", "noreturn"], + ["builtin-types", "type"], + ["builtin-types", "anyerror"], + ["builtin-types", "comptime_int"], + ["builtin-types", "comptime_float"] +] + +---------------------------------------------------- + +Checks for builtin types. diff --git a/tests/languages/zig/builtin_feature.test b/tests/languages/zig/builtin_feature.test new file mode 100644 index 0000000000..e152c64be7 --- /dev/null +++ b/tests/languages/zig/builtin_feature.test @@ -0,0 +1,417 @@ +@addWithOverflow() +@alignCast() +@alignOf() +@ArgType() +@atomicLoad() +@atomicRmw() +@bitCast() +@bitOffsetOf() +@boolToInt() +@breakpoint() +@mulAdd() +@byteSwap() +@bitReverse() +@byteOffsetOf() +@bytesToSlice() +@cDefine() +@cImport() +@cInclude() +@clz() +@cmpxchgStrong() +@cmpxchgWeak() +@compileError() +@compileLog() +@ctz() +@cUndef() +@divExact() +@divFloor() +@divTrunc() +@embedFile() +@enumToInt() +@errorName() +@errorReturnTrace() +@errorToInt() +@errSetCast() +@export() +@fence() +@field() +@fieldParentPtr() +@floatCast() +@floatToInt() +@frameAddress() +@handle() +@hasDecl() +@hasField() +@import() +@inlineCall() +@intCast() +@intToEnum() +@intToError() +@intToFloat() +@intToPtr() +@IntType() +@memberCount() +@memberName() +@memberType() +@memcpy() +@memset() +@mod() +@mulWithOverflow() +@newStackCall() +@noInlineCall() +@OpaqueType() +@panic() +@popCount() +@ptrCast() +@ptrToInt() +@rem() +@returnAddress() +@setAlignStack() +@setCold() +@setEvalBranchQuota() +@setFloatMode() +@setRuntimeSafety() +@shlExact() +@shlWithOverflow() +@shrExact() +@sizeOf() +@sliceToBytes() +@sqrt() +@sin() +@cos() +@exp() +@exp2() +@ln() +@log2() +@log10() +@fabs() +@floor() +@ceil() +@trunc() +@round() +@subWithOverflow() +@tagName() +@TagType() +@This() +@truncate() +@typeId() +@typeInfo() +@typeName() +@typeOf() +@unionInit() +@Vector() + +---------------------------------------------------- + +[ + ["builtin", "@addWithOverflow"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@alignCast"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@alignOf"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@ArgType"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@atomicLoad"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@atomicRmw"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@bitCast"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@bitOffsetOf"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@boolToInt"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@breakpoint"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@mulAdd"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@byteSwap"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@bitReverse"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@byteOffsetOf"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@bytesToSlice"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@cDefine"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@cImport"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@cInclude"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@clz"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@cmpxchgStrong"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@cmpxchgWeak"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@compileError"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@compileLog"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@ctz"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@cUndef"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@divExact"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@divFloor"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@divTrunc"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@embedFile"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@enumToInt"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@errorName"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@errorReturnTrace"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@errorToInt"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@errSetCast"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@export"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@fence"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@field"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@fieldParentPtr"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@floatCast"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@floatToInt"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@frameAddress"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@handle"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@hasDecl"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@hasField"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@import"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@inlineCall"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@intCast"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@intToEnum"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@intToError"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@intToFloat"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@intToPtr"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@IntType"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@memberCount"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@memberName"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@memberType"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@memcpy"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@memset"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@mod"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@mulWithOverflow"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@newStackCall"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@noInlineCall"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@OpaqueType"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@panic"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@popCount"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@ptrCast"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@ptrToInt"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@rem"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@returnAddress"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@setAlignStack"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@setCold"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@setEvalBranchQuota"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@setFloatMode"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@setRuntimeSafety"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@shlExact"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@shlWithOverflow"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@shrExact"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@sizeOf"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@sliceToBytes"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@sqrt"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@sin"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@cos"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@exp"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@exp2"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@ln"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@log2"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@log10"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@fabs"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@floor"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@ceil"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@trunc"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@round"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@subWithOverflow"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@tagName"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@TagType"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@This"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@truncate"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@typeId"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@typeInfo"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@typeName"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@typeOf"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@unionInit"], + ["punctuation", "("], + ["punctuation", ")"], + ["builtin", "@Vector"], + ["punctuation", "("], + ["punctuation", ")"] +] + +---------------------------------------------------- + +Checks for builtin functions. diff --git a/tests/languages/zig/class-name_feature.test b/tests/languages/zig/class-name_feature.test new file mode 100644 index 0000000000..9b0d92caf0 --- /dev/null +++ b/tests/languages/zig/class-name_feature.test @@ -0,0 +1,504 @@ +const Timestamp = struct { + seconds: i64, + nanos: u32, + pub fn unixEpoch() Timestamp { + return Timestamp{ + .seconds = 0, + .nanos = 0, + }; + } +}; + +const one_plus_one: i32 = 1 + 1; +var x: i32; +const value: ?u32 = null; +var optional_value: ?[]const u8 = null; +var number_or_error: anyerror!i32 = error.ArgNotFound; +const array1 = [_]u32{1,2}; +var foo: S align(4) = undefined; + +fn add(a: i32, b: i32) i32 { + return a + b; +} +extern fn foo(x: f64) f64; +fn noop4() align(4) void {} +fn derp() align(@sizeOf(usize) * 2) i32 { return 1234; } + +fn eventuallyNullSequence() ?u32 { + return if (numbers_left == 0) null else blk: { + numbers_left -= 1; + break :blk numbers_left; + }; +} + +const message = [_]u8{ 'h', 'e', 'l', 'l', 'o' }; + +const mat4x4 = [4][4]f32{ + [_]f32{ 1.0, 0.0, 0.0, 0.0 }, + [_]f32{ 0.0, 1.0, 0.0, 1.0 }, + [_]f32{ 0.0, 0.0, 1.0, 0.0 }, + [_]f32{ 0.0, 0.0, 0.0, 1.0 }, +}; + +const Point = struct {}; +const Point2 = packed struct {}; +const Type = enum {}; +const Value = enum(u2) {}; +const Number = packed enum(u8) {}; +const Foo = extern enum { A, B, C }; +const Foo = extern enum { A, B, C }; +const Payload = union {}; +const ComplexType = union(ComplexTypeTag) {}; + +var node = ListOfInts.Node {}; +var list2 = LinkedList(i32) {}; + +---------------------------------------------------- + +[ + ["keyword", "const"], + ["class-name", "Timestamp"], + ["operator", "="], + ["keyword", "struct"], + ["punctuation", "{"], + "\r\n\tseconds", + ["punctuation", ":"], + ["class-name", [ + ["builtin-types", "i64"] + ]], + ["punctuation", ","], + "\r\n\tnanos", + ["punctuation", ":"], + ["class-name", [ + ["builtin-types", "u32"] + ]], + ["punctuation", ","], + ["keyword", "pub"], + ["keyword", "fn"], + ["function", "unixEpoch"], + ["punctuation", "("], + ["punctuation", ")"], + ["class-name", [ + "Timestamp" + ]], + ["punctuation", "{"], + ["keyword", "return"], + ["class-name", [ + "Timestamp" + ]], + ["punctuation", "{"], + ["punctuation", "."], + "seconds ", + ["operator", "="], + ["number", "0"], + ["punctuation", ","], + ["punctuation", "."], + "nanos ", + ["operator", "="], + ["number", "0"], + ["punctuation", ","], + ["punctuation", "}"], + ["punctuation", ";"], + ["punctuation", "}"], + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "const"], + " one_plus_one", + ["punctuation", ":"], + ["class-name", [ + ["builtin-types", "i32"] + ]], + ["operator", "="], + ["number", "1"], + ["operator", "+"], + ["number", "1"], + ["punctuation", ";"], + ["keyword", "var"], + " x", + ["punctuation", ":"], + ["class-name", [ + ["builtin-types", "i32"] + ]], + ["punctuation", ";"], + ["keyword", "const"], + " value", + ["punctuation", ":"], + ["class-name", [ + ["operator", "?"], + ["builtin-types", "u32"] + ]], + ["operator", "="], + ["keyword", "null"], + ["punctuation", ";"], + ["keyword", "var"], + " optional_value", + ["punctuation", ":"], + ["class-name", [ + ["operator", "?"], + ["punctuation", "["], + ["punctuation", "]"], + ["keyword", "const"], + ["builtin-types", "u8"] + ]], + ["operator", "="], + ["keyword", "null"], + ["punctuation", ";"], + ["keyword", "var"], + " number_or_error", + ["punctuation", ":"], + ["class-name", [ + ["builtin-types", "anyerror"], + ["operator", "!"], + ["builtin-types", "i32"] + ]], + ["operator", "="], + ["keyword", "error"], + ["punctuation", "."], + "ArgNotFound", + ["punctuation", ";"], + ["keyword", "const"], + " array1 ", + ["operator", "="], + ["class-name", [ + ["punctuation", "["], + "_", + ["punctuation", "]"], + ["builtin-types", "u32"] + ]], + ["punctuation", "{"], + ["number", "1"], + ["punctuation", ","], + ["number", "2"], + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "var"], + " foo", + ["punctuation", ":"], + ["class-name", [ + "S" + ]], + ["keyword", "align"], + ["punctuation", "("], + ["number", "4"], + ["punctuation", ")"], + ["operator", "="], + ["keyword", "undefined"], + ["punctuation", ";"], + ["keyword", "fn"], + ["function", "add"], + ["punctuation", "("], + "a", + ["punctuation", ":"], + ["class-name", [ + ["builtin-types", "i32"] + ]], + ["punctuation", ","], + " b", + ["punctuation", ":"], + ["class-name", [ + ["builtin-types", "i32"] + ]], + ["punctuation", ")"], + ["class-name", [ + ["builtin-types", "i32"] + ]], + ["punctuation", "{"], + ["keyword", "return"], + " a ", + ["operator", "+"], + " b", + ["punctuation", ";"], + ["punctuation", "}"], + ["keyword", "extern"], + ["keyword", "fn"], + ["function", "foo"], + ["punctuation", "("], + "x", + ["punctuation", ":"], + ["class-name", [ + ["builtin-types", "f64"] + ]], + ["punctuation", ")"], + ["class-name", [ + ["builtin-types", "f64"] + ]], + ["punctuation", ";"], + ["keyword", "fn"], + ["function", "noop4"], + ["punctuation", "("], + ["punctuation", ")"], + ["keyword", "align"], + ["punctuation", "("], + ["number", "4"], + ["punctuation", ")"], + ["class-name", [ + ["builtin-types", "void"] + ]], + ["punctuation", "{"], + ["punctuation", "}"], + ["keyword", "fn"], + ["function", "derp"], + ["punctuation", "("], + ["punctuation", ")"], + ["keyword", "align"], + ["punctuation", "("], + ["builtin", "@sizeOf"], + ["punctuation", "("], + ["builtin-types", "usize"], + ["punctuation", ")"], + ["operator", "*"], + ["number", "2"], + ["punctuation", ")"], + ["class-name", [ + ["builtin-types", "i32"] + ]], + ["punctuation", "{"], + ["keyword", "return"], + ["number", "1234"], + ["punctuation", ";"], + ["punctuation", "}"], + ["keyword", "fn"], + ["function", "eventuallyNullSequence"], + ["punctuation", "("], + ["punctuation", ")"], + ["class-name", [ + ["operator", "?"], + ["builtin-types", "u32"] + ]], + ["punctuation", "{"], + ["keyword", "return"], + ["keyword", "if"], + ["punctuation", "("], + "numbers_left ", + ["operator", "=="], + ["number", "0"], + ["punctuation", ")"], + ["keyword", "null"], + ["keyword", "else"], + ["label", "blk"], + ["punctuation", ":"], + ["punctuation", "{"], + "\r\n\t\tnumbers_left ", + ["operator", "-="], + ["number", "1"], + ["punctuation", ";"], + ["keyword", "break"], + ["punctuation", ":"], + ["label", "blk"], + " numbers_left", + ["punctuation", ";"], + ["punctuation", "}"], + ["punctuation", ";"], + ["punctuation", "}"], + ["keyword", "const"], + " message ", + ["operator", "="], + ["class-name", [ + ["punctuation", "["], + "_", + ["punctuation", "]"], + ["builtin-types", "u8"] + ]], + ["punctuation", "{"], + ["string", "'h'"], + ["punctuation", ","], + ["string", "'e'"], + ["punctuation", ","], + ["string", "'l'"], + ["punctuation", ","], + ["string", "'l'"], + ["punctuation", ","], + ["string", "'o'"], + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "const"], + " mat4x4 ", + ["operator", "="], + ["class-name", [ + ["punctuation", "["], + ["number", "4"], + ["punctuation", "]"], + ["punctuation", "["], + ["number", "4"], + ["punctuation", "]"], + ["builtin-types", "f32"] + ]], + ["punctuation", "{"], + ["class-name", [ + ["punctuation", "["], + "_", + ["punctuation", "]"], + ["builtin-types", "f32"] + ]], + ["punctuation", "{"], + ["number", "1.0"], + ["punctuation", ","], + ["number", "0.0"], + ["punctuation", ","], + ["number", "0.0"], + ["punctuation", ","], + ["number", "0.0"], + ["punctuation", "}"], + ["punctuation", ","], + ["class-name", [ + ["punctuation", "["], + "_", + ["punctuation", "]"], + ["builtin-types", "f32"] + ]], + ["punctuation", "{"], + ["number", "0.0"], + ["punctuation", ","], + ["number", "1.0"], + ["punctuation", ","], + ["number", "0.0"], + ["punctuation", ","], + ["number", "1.0"], + ["punctuation", "}"], + ["punctuation", ","], + ["class-name", [ + ["punctuation", "["], + "_", + ["punctuation", "]"], + ["builtin-types", "f32"] + ]], + ["punctuation", "{"], + ["number", "0.0"], + ["punctuation", ","], + ["number", "0.0"], + ["punctuation", ","], + ["number", "1.0"], + ["punctuation", ","], + ["number", "0.0"], + ["punctuation", "}"], + ["punctuation", ","], + ["class-name", [ + ["punctuation", "["], + "_", + ["punctuation", "]"], + ["builtin-types", "f32"] + ]], + ["punctuation", "{"], + ["number", "0.0"], + ["punctuation", ","], + ["number", "0.0"], + ["punctuation", ","], + ["number", "0.0"], + ["punctuation", ","], + ["number", "1.0"], + ["punctuation", "}"], + ["punctuation", ","], + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "const"], + ["class-name", "Point"], + ["operator", "="], + ["keyword", "struct"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "const"], + ["class-name", "Point2"], + ["operator", "="], + ["keyword", "packed"], + ["keyword", "struct"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "const"], + ["class-name", "Type"], + ["operator", "="], + ["keyword", "enum"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "const"], + ["class-name", "Value"], + ["operator", "="], + ["keyword", "enum"], + ["punctuation", "("], + "u2", + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "const"], + ["class-name", "Number"], + ["operator", "="], + ["keyword", "packed"], + ["keyword", "enum"], + ["punctuation", "("], + ["builtin-types", "u8"], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "const"], + ["class-name", "Foo"], + ["operator", "="], + ["keyword", "extern"], + ["keyword", "enum"], + ["punctuation", "{"], + " A", + ["punctuation", ","], + " B", + ["punctuation", ","], + " C ", + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "const"], + ["class-name", "Foo"], + ["operator", "="], + ["keyword", "extern"], + ["keyword", "enum"], + ["punctuation", "{"], + " A", + ["punctuation", ","], + " B", + ["punctuation", ","], + " C ", + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "const"], + ["class-name", "Payload"], + ["operator", "="], + ["keyword", "union"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "const"], + ["class-name", "ComplexType"], + ["operator", "="], + ["keyword", "union"], + ["punctuation", "("], + "ComplexTypeTag", + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "var"], + " node ", + ["operator", "="], + ["class-name", [ + "ListOfInts", + ["punctuation", "."], + "Node" + ]], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", ";"], + ["keyword", "var"], + " list2 ", + ["operator", "="], + ["function", "LinkedList"], + ["punctuation", "("], + ["builtin-types", "i32"], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", ";"] +] + +---------------------------------------------------- + +Checks for class names. diff --git a/tests/languages/zig/keyword_feature.test b/tests/languages/zig/keyword_feature.test new file mode 100644 index 0000000000..4143eec83d --- /dev/null +++ b/tests/languages/zig/keyword_feature.test @@ -0,0 +1,105 @@ +align +allowzero +and +asm +async +await +break +cancel +catch +comptime +const +continue +defer +else +enum +errdefer +error +export +extern +fn +for +if +inline +linksection +nakedcc +noalias +null +or +orelse +packed +promise +pub +resume +return +stdcallcc +struct +suspend +switch +test +threadlocal +try +undefined +union +unreachable +usingnamespace +var +volatile +while + +---------------------------------------------------- + +[ + ["keyword", "align"], + ["keyword", "allowzero"], + ["keyword", "and"], + ["keyword", "asm"], + ["keyword", "async"], + ["keyword", "await"], + ["keyword", "break"], + ["keyword", "cancel"], + ["keyword", "catch"], + ["keyword", "comptime"], + ["keyword", "const"], + ["keyword", "continue"], + ["keyword", "defer"], + ["keyword", "else"], + ["keyword", "enum"], + ["keyword", "errdefer"], + ["keyword", "error"], + ["keyword", "export"], + ["keyword", "extern"], + ["keyword", "fn"], + ["keyword", "for"], + ["keyword", "if"], + ["keyword", "inline"], + ["keyword", "linksection"], + ["keyword", "nakedcc"], + ["keyword", "noalias"], + ["keyword", "null"], + ["keyword", "or"], + ["keyword", "orelse"], + ["keyword", "packed"], + ["keyword", "promise"], + ["keyword", "pub"], + ["keyword", "resume"], + ["keyword", "return"], + ["keyword", "stdcallcc"], + ["keyword", "struct"], + ["keyword", "suspend"], + ["keyword", "switch"], + ["keyword", "test"], + ["keyword", "threadlocal"], + ["keyword", "try"], + ["keyword", "undefined"], + ["keyword", "union"], + ["keyword", "unreachable"], + ["keyword", "usingnamespace"], + ["keyword", "var"], + ["keyword", "volatile"], + ["keyword", "while"] +] + +---------------------------------------------------- + +Checks for keywords. diff --git a/tests/languages/zig/label_feature.test b/tests/languages/zig/label_feature.test new file mode 100644 index 0000000000..e402699099 --- /dev/null +++ b/tests/languages/zig/label_feature.test @@ -0,0 +1,75 @@ +outer: while (true) { + while (true) { + break :outer; + } +} + +fn eventuallyErrorSequence() anyerror!u32 { + return if (numbers_left == 0) error.ReachedZero else blk: { + numbers_left -= 1; + break :blk numbers_left; + }; +} + +---------------------------------------------------- + +[ + ["label", "outer"], + ["punctuation", ":"], + ["keyword", "while"], + ["punctuation", "("], + ["boolean", "true"], + ["punctuation", ")"], + ["punctuation", "{"], + ["keyword", "while"], + ["punctuation", "("], + ["boolean", "true"], + ["punctuation", ")"], + ["punctuation", "{"], + ["keyword", "break"], + ["punctuation", ":"], + ["label", "outer"], + ["punctuation", ";"], + ["punctuation", "}"], + ["punctuation", "}"], + ["keyword", "fn"], + ["function", "eventuallyErrorSequence"], + ["punctuation", "("], + ["punctuation", ")"], + ["class-name", [ + ["builtin-types", "anyerror"], + ["operator", "!"], + ["builtin-types", "u32"] + ]], + ["punctuation", "{"], + ["keyword", "return"], + ["keyword", "if"], + ["punctuation", "("], + "numbers_left ", + ["operator", "=="], + ["number", "0"], + ["punctuation", ")"], + ["keyword", "error"], + ["punctuation", "."], + "ReachedZero ", + ["keyword", "else"], + ["label", "blk"], + ["punctuation", ":"], + ["punctuation", "{"], + "\r\n\t\tnumbers_left ", + ["operator", "-="], + ["number", "1"], + ["punctuation", ";"], + ["keyword", "break"], + ["punctuation", ":"], + ["label", "blk"], + " numbers_left", + ["punctuation", ";"], + ["punctuation", "}"], + ["punctuation", ";"], + ["punctuation", "}"] +] + +---------------------------------------------------- + +Checks for labels. diff --git a/tests/languages/zig/number_feature.test b/tests/languages/zig/number_feature.test new file mode 100644 index 0000000000..ce257a0ee6 --- /dev/null +++ b/tests/languages/zig/number_feature.test @@ -0,0 +1,22 @@ +123 +123.456e-7 + +0xBadFace +0xBAD.FACEp+F + +0b1001 +0o377 +---------------------------------------------------- + +[ + ["number", "123"], + ["number", "123.456e-7"], + ["number", "0xBadFace"], + ["number", "0xBAD.FACEp+F"], + ["number", "0b1001"], + ["number", "0o377"] +] + +---------------------------------------------------- + +Checks for numbers. diff --git a/tests/languages/zig/operator_feature.test b/tests/languages/zig/operator_feature.test new file mode 100644 index 0000000000..4ae1cc403b --- /dev/null +++ b/tests/languages/zig/operator_feature.test @@ -0,0 +1,73 @@ ++ - * / % ++= -= *= /= %= + +& | ^ +&= |= ^= + ++% -% *% ++%= -%= *%= + +** ++ + +< > <= >= ! != == = +~ << <<= >> >>= + +.* .? +.. ... + +=> -> +? +|| + +---------------------------------------------------- +[ + ["operator", "+"], + ["operator", "-"], + ["operator", "*"], + ["operator", "/"], + ["operator", "%"], + ["operator", "+="], + ["operator", "-="], + ["operator", "*="], + ["operator", "/="], + ["operator", "%="], + ["operator", "&"], + ["operator", "|"], + ["operator", "^"], + ["operator", "&="], + ["operator", "|="], + ["operator", "^="], + ["operator", "+%"], + ["operator", "-%"], + ["operator", "*%"], + ["operator", "+%="], + ["operator", "-%="], + ["operator", "*%="], + ["operator", "**"], + ["operator", "++"], + ["operator", "<"], + ["operator", ">"], + ["operator", "<="], + ["operator", ">="], + ["operator", "!"], + ["operator", "!="], + ["operator", "=="], + ["operator", "="], + ["operator", "~"], + ["operator", "<<"], + ["operator", "<<="], + ["operator", ">>"], + ["operator", ">>="], + ["operator", ".*"], + ["operator", ".?"], + ["operator", ".."], + ["operator", "..."], + ["operator", "=>"], + ["operator", "->"], + ["operator", "?"], + ["operator", "||"] +] + +---------------------------------------------------- + +Checks for operators. diff --git a/tests/languages/zig/punctuation_feature.test b/tests/languages/zig/punctuation_feature.test new file mode 100644 index 0000000000..189df1cfea --- /dev/null +++ b/tests/languages/zig/punctuation_feature.test @@ -0,0 +1,21 @@ +. : , ; +( ) { } [ ] + +---------------------------------------------------- + +[ + ["punctuation", "."], + ["punctuation", ":"], + ["punctuation", ","], + ["punctuation", ";"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", "["], + ["punctuation", "]"] +] + +---------------------------------------------------- + +Checks for punctuation.