
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
gujjuscript
Advanced tools
GujjuScript is a simple, fun, and easy-to-understand programming language designed as a personal project to explore compiler design and language creation. This language aims to provide a basic foundation for learning about tokenization, parsing, and code execution.
To set up GujjuScript on your machine, follow these steps:
Ensure you have Node.js installed on your system. If not, download and install it from the official website.
You can install GujjuScript globally on your machine via npm. Run the following command in your terminal:
npm install -g gujjuscript
This will allow you to run GujjuScript from anywhere on your system using the gujju command.
After installation, verify that GujjuScript was successfully installed by running the following command:
gujju --version
This should output the installed version of GujjuScript.
Now, you're ready to use GujjuScript on your machine! You can start running GujjuScript files or enter the REPL mode.
To run a GujjuScript file:
gujju index.gjs
To start an interactive GujjuScript REPL:
gujju
To run a file with debugging enabled:
gujju index.gjs --gjs-debug
GujjuScript has a set of reserved keywords that have special meanings in the language. These keywords are used for different programming constructs like declarations and print statements.
jo: Used for declaring variables (similar to let or const in JavaScript).bol: Used for printing the value of a variable or expression (similar to console.log in JavaScript).GujjuScript includes a few basic pre-built functions to make programming easier:
console.log(): A function to print output to the console (used as bol in GujjuScript).+), subtraction (-), multiplication (*), and division (/).Note: More pre-built functions and features can be added based on user needs, but currently, these are the available features.
The GujjuScript compiler follows three main stages to process and run the code: Lexing, Parsing, and Code Generation.
Lexing is the first step in the compilation process. During this phase, the GujjuScript source code is broken down into tokens. Tokens represent the smallest units of meaningful code.
For example, the following GujjuScript code:
jo x = 10
jo y = 20
jo sum = x + y
bol sum
is tokenized into the following array of tokens:
[
{ "type": "keyword", "value": "jo" },
{ "type": "identifier", "value": "x" },
{ "type": "operator", "value": "=" },
{ "type": "number", "value": 10 },
{ "type": "keyword", "value": "jo" },
{ "type": "identifier", "value": "y" },
{ "type": "operator", "value": "=" },
{ "type": "number", "value": 20 },
{ "type": "keyword", "value": "jo" },
{ "type": "identifier", "value": "sum" },
{ "type": "operator", "value": "=" },
{ "type": "identifier", "value": "x" },
{ "type": "operator", "value": "+" },
{ "type": "identifier", "value": "y" },
{ "type": "keyword", "value": "bol" },
{ "type": "identifier", "value": "sum" }
]
After lexing, the next step is parsing, where the tokens are organized into an Abstract Syntax Tree (AST). The AST represents the program’s structure.
For the above example, the generated AST looks like this:
{
"type": "Program",
"body": [
{
"type": "Declaration",
"name": "x",
"value": 10
},
{
"type": "Declaration",
"name": "y",
"value": 20
},
{
"type": "Declaration",
"name": "sum",
"value": "x + y"
},
{
"type": "Print",
"expression": "sum"
}
]
}
Once the AST is created, it is converted into executable JavaScript code. The generated JavaScript code for the above AST is:
const x = 10;
const y = 20;
const sum = x + y;
console.log(sum);
This JavaScript code is then executed in the Node.js environment, and the result will be:
30
To run a GujjuScript file, use the following command:
gujju index.gjs
This will compile and execute the file index.gjs.
To enable debugging while running a script, use the --gjs-debug flag:
gujju index.gjs --gjs-debug
This will output additional information such as the tokenized code, AST, and generated JavaScript code, which can be useful for debugging your code.
To start an interactive GujjuScript REPL (Read-Eval-Print-Loop), type:
gujju
This will start the REPL, where you can enter GujjuScript code line by line.
To exit the REPL, type:
exit
To run a file with debugging enabled, use:
gujju index.gjs -debug
This will show the debugging output, which includes the tokenization process, the AST, and the generated JavaScript code before execution.
Here’s an example of GujjuScript code that demonstrates variable declarations and printing:
jo a = 5
jo b = 10
jo sum = a + b
bol sum
[
{ "type": "keyword", "value": "jo" },
{ "type": "identifier", "value": "a" },
{ "type": "operator", "value": "=" },
{ "type": "number", "value": 5 },
{ "type": "keyword", "value": "jo" },
{ "type": "identifier", "value": "b" },
{ "type": "operator", "value": "=" },
{ "type": "number", "value": 10 },
{ "type": "keyword", "value": "jo" },
{ "type": "identifier", "value": "sum" },
{ "type": "operator", "value": "=" },
{ "type": "identifier", "value": "a" },
{ "type": "operator", "value": "+" },
{ "type": "identifier", "value": "b" },
{ "type": "keyword", "value": "bol" },
{ "type": "identifier", "value": "sum" }
]
{
"type": "Program",
"body": [
{
"type": "Declaration",
"name": "a",
"value": 5
},
{
"type": "Declaration",
"name": "b",
"value": 10
},
{
"type": "Declaration",
"name": "sum",
"value": "a + b"
},
{
"type": "Print",
"expression": "sum"
}
]
}
const a = 5;
const b = 10;
const sum = a + b;
console.log(sum);
15
GujjuScript is a simple, beginner-friendly programming language designed to help users learn about the process of creating a programming language from scratch. Through the lexer, parser, and code generation process, users can explore key concepts such as tokenization, abstract syntax trees (ASTs), and how programming languages are interpreted and executed.
With its easy-to-understand syntax and the possibility of extending functionality, GujjuScript is a great learning tool for anyone interested in programming languages or compilers.
FAQs
A simple programming language implementation
We found that gujjuscript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.