Skip to content

Commit e54dee1

Browse files
Update README.md
1 parent 1b5b126 commit e54dee1

File tree

1 file changed

+174
-1
lines changed

1 file changed

+174
-1
lines changed

README.md

Lines changed: 174 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,175 @@
11
# PeththaScript
2-
A meme project I worked on. Hope you like it! 👨‍💻
2+
PeththaScript is just a meme project I've been working on :wink:. Hope you like it. Have fun! :heart:
3+
4+
---
5+
6+
## Documentation
7+
8+
### Requirements
9+
1. Node.js
10+
11+
### 1. How to Setup
12+
Download the complete folder as a zip file. Extract the zip file to anywhere on your device. And you're ready to go.
13+
14+
### 2. Creating Your First File
15+
Open the extracted folder in your preferred code editor. Create a new file with the extention `.pet`. It is recommended not to use spaces in the file name. However, using spaces is also fine if wanted. The format for the file name is give below.
16+
17+
```
18+
[filename].peth
19+
```
20+
21+
### 3. Writing the First Line of Code
22+
PeththaScript has a very simple syntax once you understand it. Basically every line has 3 sections explaining 3 properties about the input value. These 2 sections are broken into `peththa`, `bath` and `kawada`. At the end of each line is a pair of square brackets surrounding what to do with the processed value. There are 2 valid values that can be written within these square brackets. They are either `log` or `store`. Back to the 3 sections of the line, `peththa` defines what to do with the input value, `bath` is where you input the type of the input and `kawada` is where the actual input is provided. Given below is the syntax of a simple PeththaScript line.
23+
24+
```
25+
peththa ? function : bath ? type : kawada ? value [log|store]
26+
```
27+
28+
There are 6 valid functions. They are,
29+
- keep
30+
- repeat
31+
- reverse
32+
- jumble
33+
- rotateR
34+
- rotateL
35+
36+
The `keep` function is used when you want to log or store the raw value of your input.
37+
The `repeat` function is used to repeat a string *n* number of times.
38+
The `reverse` function is used to reverse the characters of a string.
39+
The `jumble` function is used to shuffle the position of the characters of a string.
40+
The `rotateR` function is used to [right rotate](https://www.geeksforgeeks.org/complete-guide-on-array-rotations/) a string *n* number of times.
41+
The `rotateL` function is used to [left rotate](https://www.geeksforgeeks.org/complete-guide-on-array-rotations/) a string *n* number of times.
42+
43+
In the functions `repeat`, `rotateR` and `rotateL` take the input of *n* using what's termed as a **sectional input field**. Sectional input fields are written using curly braces (`{}`) and the value written within the curly braces is called the **sectional input**. A sectional input field can only contain one numerical value. An example is given below.
44+
45+
```
46+
peththa ? repeat : bath ? str : kawada ? "hello world" [log] {2}
47+
peththa ? rotateR : bath ? str : kawada ? "hello world" [log] {2}
48+
peththa ? rotateL : bath ? str : kawada ? "hello world" [log] {2}
49+
```
50+
Output:
51+
```
52+
hello worldhello world
53+
ldhello wor
54+
llo worldhe
55+
```
56+
57+
By the first line of code we are saying to repeat the provided string 2 times and log it to the console, the second line says to right rotate the string 2 times and log it and the third line is saying to left rotate the 2 times and log it.
58+
59+
That's all about functions. When talking about data types, there are 3 valid types in PeththaScript. They are,
60+
61+
- str : type provided when the value is a string
62+
- int : type provided when the value is a number
63+
- bigInt : type provided when the value is a very large number
64+
65+
When providing the value in the `kawada` section,
66+
67+
- Values of type `str` must be surrounded by double quotes
68+
- Values of type `str` can contain double quotes within the string itself. The string is closed at the last double quotation mark.
69+
- Values of type `int` and `bigInt` must be numberical
70+
71+
Next is what we call the `Dot Function`. The Dot Function is the value we write at the end of the line within square brackets.
72+
73+
```
74+
peththa ? keep : bath ? int : kawada ? 2134 [log]
75+
```
76+
77+
Here `[log]` is the dot function. The 2 valid dot functions are `log` and `store`. The `log` function is pretty straight-forward. It logs the value to the console. However the store function is bit more complicated. Whenever you write a line with the `store` dot function, the `render` file stores that value in a variable. And that introduces us to a new line structure.
78+
79+
```
80+
peththa ? keep : bath ? str : kawada ? "Hello World" [store]
81+
<reverse> [log]
82+
```
83+
Output
84+
```
85+
dlroW olleH
86+
```
87+
88+
Here, the value of the first line is stored for later use and the second line accesses this value. So basically, you just have to write the wanted function within '<>' and just define the dot function to access the stored value. These lines are called `accessor lines`.
89+
90+
> If a new line with the `store` dot function is written after the previous one, the stored value is replaced with the processed value of the new line and that value is provided to any accessor lines thereafter.
91+
92+
```
93+
peththa ? keep : bath ? str : kawada ? "Hello World" [store]
94+
<reverse> [log]
95+
peththa ? keep : bath ? str : kawada ? "Hi There" [store]
96+
<reverse> [log]
97+
```
98+
Output
99+
```
100+
dlroW olleH
101+
erehT iH
102+
```
103+
### Variables
104+
If you've been wondering, "Wait! I can't write all the text I want in that one line", don't worry! I got you. Variables in PeththaScript, like any other language, is used to store values to be used later. However, in PeththaScript, variables are written in a seperate file. This file's name must be the filename as your code file. The only difference is that the extention need to be `.vpeth` instead of `.peth`. This file should also be created within the `src` folder.
105+
106+
```
107+
[filename].vpeth
108+
```
109+
110+
To define variables, a line structure similar to the following is used.
111+
112+
```
113+
<varName:varType>
114+
```
115+
This is a `declaration line` and is used to define a variable. Here, the variable name (varName) must start with a capital or simple English letter and after that can contain any english letter, integers from 0-9 and underscores (`_`).
116+
117+
Example: `variable_name1`
118+
119+
The value of the variable needs to start in the line following the declaration line. When writing strings, double quotes are not used. Instead you can just write it in as many lines as wanted and the line breaks are not accounted for. If you want to add any line breaks, you can use `\n` within the value of the variable. You can use multiple lines when defining variables of type `int` and `bigInt` as well since the line breaks are not counted.
120+
121+
```
122+
<var1:str>
123+
Hello world!
124+
This is Infroid Coder.
125+
Hope you're all doing well.
126+
<var2:int>
127+
21984789
128+
32439
129+
<var3:bigInt>
130+
7432839809443462
131+
48798489358793487
132+
343782
133+
```
134+
135+
The value of `var1` in this case is:
136+
```
137+
Hello world!This is Infroid Coder.Hope you're all doing well
138+
```
139+
140+
Notice how there are no spaces after 'Hello world!' and '...Infroid Coder.' since the line breaks were replaced with empty strings.
141+
142+
The value of `var2` is:
143+
```
144+
2198478932439
145+
```
146+
147+
The value of `var3` is:
148+
```
149+
743283980944346248798489358793487343782
150+
```
151+
152+
### Accessing Variables in the Code
153+
154+
To access a variable you've just initialized/defined, you would start with the same syntax of a normal line except, the type or `bath` is set to the type of the variable and the value or `kawada` is set to the variable name surrounded by paranthesis.
155+
156+
```
157+
peththa ? keep : bath ? str : kawada ? (var1) [log]
158+
```
159+
160+
Here, `var1` is the variable name and notice how the type is set `str` which is the type of the variable.
161+
162+
### Comments
163+
Comments are important for documenting your code or debugging. In PeththaScript you can write comments in the following format.
164+
165+
```
166+
### This is a comment
167+
```
168+
169+
---
170+
171+
<p align="center">That is all for the documentation. Hope you have fun with <b>PeththaScript</b>. Happy Coding!👨‍💻</p>
172+
173+
---
174+
175+
<h1 align="center">Thank You!</h1>

0 commit comments

Comments
 (0)