Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Added Intrinsics Libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinAlavik authored Oct 20, 2023
1 parent 5a6a8d9 commit ea65c2e
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 157 deletions.
34 changes: 5 additions & 29 deletions src/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,10 @@
<div class="body">
<div class="side-bar">
<a href="index.html">
<img
class="icon"
<img class="icon"
src="https://avatars.githubusercontent.com/u/146694713?s=400&u=4e01b5afefbf7e40641702e5cbdf785ff183fe35&v=4"
alt="P Icon"
/></a>
<ul>
<li><a href="index.html">Introduction</a></li>
<li><a href="getting-started.html">Getting Started</a></li>
<ul>
<li><a href="getting-started.html#installing">Installing</a></li>
<li><a href="getting-started.html#pint-first-time">Running pint for the first time</a></li>
<li><a href="getting-started.html#first-program">Your very first P program!</a></li>
</ul>
<li><a href="variables.html">Variables</a></li>
<ul>
<li><a href="variables.html#defining-variables">Defining Variables</a></li>
<li><a href="variables.html#using-variables">Using Variables</a></li>
</ul>
<li><a href="functions.html">Function</a></li>
<ul>
<li><a href="functions.html#defining-functions">Defining Functions</a></li>
<li><a href="functions.html#using-functions">Using Functions</a></li>
</ul>
<li><a class="current" href="examples.html">Examples</a></li>
<ul>
<li><a href="examples.html#fizz-buzz">Fizz Buzz</a></li>
<li><a href="examples.html#http-server">Simple HTTP Server</a></li>
<li><a href="examples.html#http-request">Simple HTTP Request</a></li>
</ul>
</ul>
alt="P Icon" /></a>
<ul></ul>
</div>
<div class="page-content">
<h1 class="page-title">Examples</h1>
Expand Down Expand Up @@ -96,5 +70,7 @@ <h2 id="http-request">Simple HTTP Request</h2>
writeln(res.json())</pre>
</div>
</div>
<footer class="webfooter">&copy; Plang 2023</footer>
<script src="script/main.js"></script>
</body>
</html>
34 changes: 5 additions & 29 deletions src/functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,10 @@
<div class="body">
<div class="side-bar">
<a href="index.html">
<img
class="icon"
<img class="icon"
src="https://avatars.githubusercontent.com/u/146694713?s=400&u=4e01b5afefbf7e40641702e5cbdf785ff183fe35&v=4"
alt="P Icon"
/></a>
<ul>
<li><a href="index.html">Introduction</a></li>
<li><a href="getting-started.html">Getting Started</a></li>
<ul>
<li><a href="getting-started.html#installing">Installing</a></li>
<li><a href="getting-started.html#pint-first-time">Running pint for the first time</a></li>
<li><a href="getting-started.html#first-program">Your very first P program!</a></li>
</ul>
<li><a href="variables.html">Variables</a></li>
<ul>
<li><a href="variables.html#defining-variables">Defining Variables</a></li>
<li><a href="variables.html#using-variables">Using Variables</a></li>
</ul>
<li><a class="current" href="functions.html">Function</a></li>
<ul>
<li><a href="functions.html#defining-functions">Defining Functions</a></li>
<li><a href="functions.html#using-functions">Using Functions</a></li>
</ul>
<li><a href="examples.html">Examples</a></li>
<ul>
<li><a href="examples.html#fizz-buzz">Fizz Buzz</a></li>
<li><a href="examples.html#http-server">Simple HTTP Server</a></li>
<li><a href="examples.html#http-request">Simple HTTP Request</a></li>
</ul>
</ul>
alt="P Icon" /></a>
<ul></ul>
</div>
<div class="page-content">
<h1 class="page-title">Functions</h1>
Expand All @@ -53,5 +27,7 @@ <h2 id="defining-functions">Defining Functions</h2>
<h2 id="using-functions">Using Functions</h2>
</div>
</div>
<footer class="webfooter">&copy; Plang 2023</footer>
<script src="script/main.js"></script>
</body>
</html>
32 changes: 3 additions & 29 deletions src/getting-started.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,10 @@
<div class="body">
<div class="side-bar">
<a href="index.html">
<img
class="icon"
<img class="icon"
src="https://avatars.githubusercontent.com/u/146694713?s=400&u=4e01b5afefbf7e40641702e5cbdf785ff183fe35&v=4"
alt="P Icon"
/></a>
<ul>
<li><a href="index.html">Introduction</a></li>
<li><a class="current" href="getting-started.html">Getting Started</a></li>
<ul>
<li><a href="getting-started.html#installing">Installing</a></li>
<li><a href="getting-started.html#pint-first-time">Running pint for the first time</a></li>
<li><a href="getting-started.html#first-program">Your very first P program!</a></li>
</ul>
<li><a href="variables.html">Variables</a></li>
<ul>
<li><a href="variables.html#defining-variables">Defining Variables</a></li>
<li><a href="variables.html#using-variables">Using Variables</a></li>
</ul>
<li><a href="functions.html">Function</a></li>
<ul>
<li><a href="functions.html#defining-functions">Defining Functions</a></li>
<li><a href="functions.html#using-functions">Using Functions</a></li>
</ul>
<li><a href="examples.html">Examples</a></li>
<ul>
<li><a href="examples.html#fizz-buzz">Fizz Buzz</a></li>
<li><a href="examples.html#http-server">Simple HTTP Server</a></li>
<li><a href="examples.html#http-request">Simple HTTP Request</a></li>
</ul>
</ul>
alt="P Icon" /></a>
<ul></ul>
</div>
<div class="page-content">
<h1 class="page-title" id="getting-started">Getting Started</h1>
Expand Down
26 changes: 1 addition & 25 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,7 @@
src="https://avatars.githubusercontent.com/u/146694713?s=400&u=4e01b5afefbf7e40641702e5cbdf785ff183fe35&v=4"
alt="P Icon"
/></a>
<ul>
<li><a class="current" href="index.html">Introduction</a></li>
<li><a href="getting-started.html">Getting Started</a></li>
<ul>
<li><a href="getting-started.html#installing">Installing</a></li>
<li><a href="getting-started.html#pint-first-time">Running pint for the first time</a></li>
<li><a href="getting-started.html#first-program">Your very first P program!</a></li>
</ul>
<li><a href="variables.html">Variables</a></li>
<ul>
<li><a href="variables.html#defining-variables">Defining Variables</a></li>
<li><a href="variables.html#using-variables">Using Variables</a></li>
</ul>
<li><a href="functions.html">Function</a></li>
<ul>
<li><a href="functions.html#defining-functions">Defining Functions</a></li>
<li><a href="functions.html#using-functions">Using Functions</a></li>
</ul>
<li><a href="examples.html">Examples</a></li>
<ul>
<li><a href="examples.html#fizz-buzz">Fizz Buzz</a></li>
<li><a href="examples.html#http-server">Simple HTTP Server</a></li>
<li><a href="examples.html#http-request">Simple HTTP Request</a></li>
</ul>
</ul>
<ul></ul>
</div>
<div class="page-content">
<h1 class="page-title" id="Introduction">Introduction</h1>
Expand Down
45 changes: 45 additions & 0 deletions src/intrinsics-libs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Plang Documents - Intrinsics Libraries</title>
<link rel="stylesheet" href="css/colors.css" />
<link rel="stylesheet" href="css/main.css" />
<meta name="description" content="A simple guide to help you get started with making your own intrinsics libraries">
<meta name="keywords" content="p, p docs, plang, plang docs, p programming lang, p programming language, p-programming-language">
<meta name="author" content="Plang">
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
crossorigin="anonymous"
></script>
</head>
<body>
<div class="body">
<div class="side-bar">
<a href="index.html">
<img
class="icon"
src="https://avatars.githubusercontent.com/u/146694713?s=400&u=4e01b5afefbf7e40641702e5cbdf785ff183fe35&v=4"
alt="P Icon"
/></a>
<ul></ul>
</div>
<div class="page-content">
<h1 class="page-title" id="Introduction">Intrinsics Libraries</h1>
<p>A simple guide to help you get started with making your own intrinsics libraries</p>
<h2 id="getting-started">Getting Started</h2>
<p>Looking at already existing libraries (<a href="https://github.com/p-programming-language/plang/tree/main/src/runtime/intrinsics/libs/">here</a>) can help you with this documentation</p>
</div>
</div>
<footer class="webfooter">&copy; Plang 2023</footer>
<script src="script/main.js"></script>
</body>
</html>
54 changes: 54 additions & 0 deletions src/script/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const sidebarItems = [
{ text: 'Introduction', href: 'index.html' },
{ text: 'Getting Started', href: 'getting-started.html', subitems: [
{ text: 'Installing', href: 'getting-started.html#installing' },
{ text: 'Running pint for the first time', href: 'getting-started.html#pint-first-time' },
{ text: 'Your very first P program!', href: 'getting-started.html#first-program' }
] },
{ text: 'Variables', href: 'variables.html', subitems: [
{ text: 'Defining Variables', href: 'variables.html#defining-variables' },
{ text: 'Using Variables', href: 'variables.html#using-variables' }
] },
{ text: 'Function', href: 'functions.html', subitems: [
{ text: 'Defining Functions', href: 'functions.html#defining-functions' },
{ text: 'Using Functions', href: 'functions.html#using-functions' }
] },
{ text: 'Examples', href: 'examples.html', subitems: [
{ text: 'Fizz Buzz', href: 'examples.html#fizz-buzz' },
{ text: 'Simple HTTP Server', href: 'examples.html#http-server' },
{ text: 'Simple HTTP Request', href: 'examples.html#http-request' }
] },
{ text: 'Intrinsics Libraries', href: 'intrinsics-libs.html', subitems: [
{ text: "Getting Started", href: 'intrinsics-libs.html#getting-started' }
] }
];

function generateSidebar() {
const sidebar = document.querySelector('.side-bar ul');

sidebarItems.forEach(item => {
const li = document.createElement('li');
const a = document.createElement('a');
a.textContent = item.text;
a.href = item.href;
li.appendChild(a);

if (item.subitems) {
const subul = document.createElement('ul');
item.subitems.forEach(subitem => {
const subli = document.createElement('li');
const suba = document.createElement('a');
suba.textContent = subitem.text;
suba.href = subitem.href;
subli.appendChild(suba);
subul.appendChild(subli);
});
li.appendChild(subul);
}

sidebar.appendChild(li);
});
}

// Call the function to generate the sidebar
generateSidebar();
77 changes: 32 additions & 45 deletions src/variables.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,29 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Plang Documents - Variables</title>
<meta name="description" content="More in depth info about using variables and defining them">
<link rel="stylesheet" href="css/colors.css">
<link rel="stylesheet" href="css/main.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Plang Documents - Variables</title>
<meta name="description" content="More in depth info about using variables and defining them">
<link rel="stylesheet" href="css/colors.css">
<link rel="stylesheet" href="css/main.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
crossorigin="anonymous"></script>
</head>

<body>
<div class="body">
<div class="body">
<div class="side-bar">
<a href="index.html">
<img
class="icon"
<img class="icon"
src="https://avatars.githubusercontent.com/u/146694713?s=400&u=4e01b5afefbf7e40641702e5cbdf785ff183fe35&v=4"
alt="P Icon"
/></a>
<ul>
<li><a href="index.html">Introduction</a></li>
<li><a href="getting-started.html">Getting Started</a></li>
<ul>
<li><a href="getting-started.html#installing">Installing</a></li>
<li><a href="getting-started.html#pint-first-time">Running pint for the first time</a></li>
<li><a href="getting-started.html#first-program">Your very first P program!</a></li>
</ul>
<li><a class="current" href="variables.html">Variables</a></li>
<ul>
<li><a href="variables.html#defining-variables">Defining Variables</a></li>
<li><a href="variables.html#using-variables">Using Variables</a></li>
</ul>
<li><a href="functions.html">Function</a></li>
<ul>
<li><a href="functions.html#defining-functions">Defining Functions</a></li>
<li><a href="functions.html#using-functions">Using Functions</a></li>
</ul>
<li><a href="examples.html">Examples</a></li>
<ul>
<li><a href="examples.html#fizz-buzz">Fizz Buzz</a></li>
<li><a href="examples.html#http-server">Simple HTTP Server</a></li>
<li><a href="examples.html#http-request">Simple HTTP Request</a></li>
</ul>
</ul>
alt="P Icon" /></a>
<ul></ul>
</div>
<div class="page-content">
<h1 class="page-title">Variables</h1>
Expand All @@ -52,21 +32,26 @@ <h2 id="defining-variables">Defining Variables</h2>
<p>You can define a variable like this:</p>
<code>*mut type name = value</code>
<p class="highlight">(* = optional)</p>
<p><strong><i>type</i></strong> can be any of these: <strong>string, int, float, bool</strong> but also custom types (more on them <a href="custom-types.html">here</a>)<br><strong><i>name</i></strong> can be any letters, numbers but not any "-" or " " in them<br><strong><i>mut</i></strong> is used to say if the variable is modifiable, basically saying if you can change the value or not. To make a variable editable you do: <code>mut type name = value</code> if not its just <code>type name = value</code></p>
<p><strong><i>type</i></strong> can be any of these: <strong>string, int, float, bool</strong> but also custom
types (more on them <a href="custom-types.html">here</a>)<br><strong><i>name</i></strong> can be any letters,
numbers but not any "-" or " " in them<br><strong><i>mut</i></strong> is used to say if the variable is
modifiable, basically saying if you can change the value or not. To make a variable editable you do:
<code>mut type name = value</code> if not its just <code>type name = value</code></p>
<p>An example of defining a variable called name with the value "Kevin":<code>string name = "Kevin"</code></p>
<br>
<h2 id="using-variables">Using Variables</h2>
<p>To use a variable you can simple just call its name, example:
<pre class="multiCode">
<pre class="multiCode">
use writeln from @std.io

string name = "Kevin"
writeln(name)</pre>
<br>
Output:
<samp>Kevin</samp>
<br>
Output:
<samp>Kevin</samp>
</p>
<p>To define a editable variable you can do: <pre class="multiCode">
<p>To define a editable variable you can do:
<pre class="multiCode">
use writeln from @std.io

mut age = 18
Expand All @@ -76,10 +61,12 @@ <h2 id="using-variables">Using Variables</h2>
<br>
Output:
<samp>I am 18
I am 19</samp>
</p>
I am 19</samp>
</p>
</div>
</div>
<footer class="webfooter">&copy; Plang 2023</footer>
<script src="script/main.js"></script>
</body>

</html>

0 comments on commit ea65c2e

Please sign in to comment.