{"id":2,"date":"2024-01-28T12:34:10","date_gmt":"2024-01-28T11:34:10","guid":{"rendered":"https:\/\/silver-boards.com\/?page_id=2"},"modified":"2025-10-03T08:48:14","modified_gmt":"2025-10-03T06:48:14","slug":"wirthx","status":"publish","type":"page","link":"https:\/\/silver-boards.com\/index.php\/wirthx\/","title":{"rendered":"WirthX Compiler"},"content":{"rendered":"<h1>wirthx<\/h1>\n<p>Wirthx is an experimental pascal compiler.\nThe language is named after Niklaus Wirth the creator of pascal.<\/p>\n<h2>Compiler<\/h2>\n<p>The compiler is based on llvm and will generate a native binary for the target plattform.\nFor now only <code>linux-x86-64<\/code> and <code>win64<\/code> are supported.<\/p>\n<h2>Current Restrictions<\/h2>\n<blockquote>\n<p>[!WARNING]<\/p>\n<ul>\n<li>only ascii characters are allowed in the source code<\/li>\n<li>no support for <code>set<\/code> types<\/li>\n<li>no support for <code>file<\/code> types with a sub type<\/li>\n<li>no support for <code>packed<\/code> types<\/li>\n<li>no support for <code>class<\/code> or <code>object<\/code> types<\/li>\n<\/ul>\n<\/blockquote>\n<h3>Options<\/h3>\n<table>\n<thead>\n<tr>\n<th><strong>Option<\/strong><\/th>\n<th><strong>Values<\/strong><\/th>\n<th><strong>Description<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>&#8211;run<\/td>\n<\/tr>\n<tr>\n<td><br>-r<\/td>\n<td><\/td>\n<td>Runs the compiled program<\/td>\n<\/tr>\n<tr>\n<td>&#8211;debug<\/td>\n<td><\/td>\n<td>Creates a debug build<\/td>\n<\/tr>\n<tr>\n<td>&#8211;release<\/td>\n<td><\/td>\n<td>Creates a release build<\/td>\n<\/tr>\n<tr>\n<td>&#8211;rtl<\/td>\n<td>path<\/td>\n<td>sets the path for the rtl (run time library)<\/td>\n<\/tr>\n<tr>\n<td>&#8211;output<\/td>\n<td>path<\/td>\n<td>sets the output \/ build directory<\/td>\n<\/tr>\n<tr>\n<td>&#8211;llvm-ir<\/td>\n<td><\/td>\n<td>Outputs the LLVM-IR to the standard error output<\/td>\n<\/tr>\n<tr>\n<td>&#8211;help<\/td>\n<td><\/td>\n<td>Outputs the program help<\/td>\n<\/tr>\n<tr>\n<td>&#8211;version<\/td>\n<td><\/td>\n<td>Prints the current version of the compiler<\/td>\n<\/tr>\n<tr>\n<td>&#8211;lsp<\/td>\n<td><\/td>\n<td>runs the compiler in the language server mode<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>Usage<\/h1>\n<pre><code class=\"lang-sh language-sh sh\">wirthx testfiles\/hello.pas<\/code><\/pre>\n<h2>Executing the compiler<\/h2>\n<p>The compiler will generate a native executable based on the program name defined in the program unit.<\/p>\n<pre><code class=\"lang-sh language-sh sh\">wirthx -c testfiles\/hello.pas<\/code><\/pre>\n<h1>Examples<\/h1>\n<h2>Hello World<\/h2>\n<pre><code class=\"lang-pascal language-pascal pascal\">program test;\n\nbegin\n    Writeln(&#039;Hello World&#039;);\nend.<\/code><\/pre>\n<h2>Functions<\/h2>\n<pre><code class=\"lang-pascal language-pascal pascal\">program test;\n\n    function addx(a : integer;b :integer): integer;\n    begin\n        addx := a + b;\n    end;\nvar\n    my_var : integer;\nbegin\n    my_var := addx(1,2);\n    Writeln(my_var);\nend.<\/code><\/pre>\n<h2>Procedures<\/h2>\n<pre><code class=\"lang-pascal language-pascal pascal\">program test;\n\n    procedure my_inc(var value: integer);\n    begin\n        value := value + 1;\n    end;\nvar\n    my_var : integer := 10;\nbegin\n    my_inc(my_var);\n    Writeln(my_var);\nend.<\/code><\/pre>\n<h2>Records<\/h2>\n<pre><code class=\"lang-pascal language-pascal pascal\">program test;\n\n    type Vec2 = record\n        x : int64;\n        y : int64;\n    end;\n\n    \/\/ pass the vector as a reference \n    procedure vec2_inc(var t : Vec2); \n    begin\n        t.x := t.x + 1;\n        t.y := t.y + 1;\n    end;\nvar\n    myvec : Vec2;\nbegin\n    myvec.x := 2;\n    myvec.y := 3;\n    vec2_inc(myvec);\nend.<\/code><\/pre>\n<h2>Conditions<\/h2>\n<pre><code class=\"lang-pascal language-pascal pascal\">program test;\nvar\n    test : integer = 20;\nbegin\n    if test mod 2 then\n        writeln(&#039;20 is divisible by 2 without a reminder.&#039;);\nend.<\/code><\/pre>\n<h2>For &#8211; Loops<\/h2>\n<pre><code class=\"lang-pascal language-pascal pascal\">program test;\nvar\n    i : integer;\nbegin\n    for i:= 1 to 20 do\n        writeln(i);\nend.<\/code><\/pre>\n<h2>While Loops<\/h2>\n<pre><code class=\"lang-pascal language-pascal pascal\">program test;\nvar\n    loop_var : integer = 20;\nbegin\n    while loop_var &gt; 0 do\n    begin\n        writeln(loop_var);\n        loop_var := loop_var - 1;\n    end;\nend.<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>wirthx Wirthx is an experimental pascal compiler. The language is named after Niklaus Wirth the creator of pascal. Compiler The [&hellip;]<\/p>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-2","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/silver-boards.com\/index.php\/wp-json\/wp\/v2\/pages\/2","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/silver-boards.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/silver-boards.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/silver-boards.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/silver-boards.com\/index.php\/wp-json\/wp\/v2\/comments?post=2"}],"version-history":[{"count":5,"href":"https:\/\/silver-boards.com\/index.php\/wp-json\/wp\/v2\/pages\/2\/revisions"}],"predecessor-version":[{"id":31,"href":"https:\/\/silver-boards.com\/index.php\/wp-json\/wp\/v2\/pages\/2\/revisions\/31"}],"wp:attachment":[{"href":"https:\/\/silver-boards.com\/index.php\/wp-json\/wp\/v2\/media?parent=2"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}