Skip to content

Commit d251e95

Browse files
committed
isnot and equals
1 parent 4b8b0d5 commit d251e95

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

README.md

+18-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
# About
3232

33-
Nova is an opensource programming language built on node. The purpose of Nova is to make a pure psuedo-code language that is the perfect introduction into computer science. Completely built on [node](https://github.com/node/nodejs) v12, Nova is optimized for running on mac, linux and windows!
33+
Nova is an opensource programming language built on node. The purpose of Nova is to make a pure psuedo-code language that is the perfect introduction into computer science. Completely built on [node](https://github.com/node/nodejs) v12 and connected to NPM packages, Nova is optimized for running on mac, linux and windows!
3434

3535
To get started go to [usage](#usage) and start your Nova journey today.
3636

@@ -42,29 +42,43 @@ To get started go to [usage](#usage) and start your Nova journey today.
4242
npm i -g cli-nova
4343
```
4444

45-
## Run file
45+
## Run
46+
47+
```bash
48+
nova [options] [file]
49+
```
50+
51+
## Example runs
4652

4753
```bash
4854
nova test.ns
4955
```
5056

57+
```bash
58+
nova --verbose test.ns
59+
```
60+
5161
## Examples
5262

5363
```javascript
5464
set variable as "hello"; // "Strings"
5565
log variable; // Logging
5666

5767
set two as 1 + 1; // Numbers
68+
set array as [1,2,3,4,5];
5869

5970
set chalk as require("chalk"); // Npm integration
6071
log chalk.red("Red text"); // Logs red
6172

6273
log 12 / 2 % 2 + 1; // Logs 3
6374

64-
if two == 2 then log "two is equal to 2";
75+
if two equals 2 then log "two is equal to 2";
6576

66-
if two != 2 then log "won't be logged" else log "two is not not equal to 2";
77+
if two isnot 2 then log "won't be logged" else log "two is not not equal to 2";
6778

79+
array.forEach(x => {
80+
log x;
81+
})
6882
```
6983

7084
## Author

src/utils/parse/parse.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ function clean(data) {
44

55
const keywords = require("./keywords");
66
const { debug, error } = require("../log/all");
7-
7+
const rewords = [
8+
{ name: "equals", val: "==" },
9+
{ name: "isnot", val: "!=" }
10+
];
11+
const vars = require("./handlers/variables");
812
module.exports = function(fileData, file, cb) {
913
var parsedData = "";
1014
const cleanData = clean(fileData);
@@ -37,11 +41,20 @@ module.exports = function(fileData, file, cb) {
3741
if (line.startsWith(" ")) {
3842
line = line.slice(1);
3943
}
40-
let keyword = keywords[line.split(" ")[0]];
44+
let words = line.split(" ");
45+
words.forEach((word, index) => {
46+
let reword = rewords.find(re => re.name == word);
47+
if (reword) {
48+
words[index] = reword.val;
49+
}
50+
});
51+
line = words.join(" ");
52+
let firstToken = words[0];
53+
let keyword = keywords[firstToken];
4154
if (keyword) {
4255
keyword(line, file, ogLine, index);
4356
} else {
44-
debug()("no def line:", line.split(" ")[0]);
57+
debug()("no def line:", firstToken);
4558
error.runtime(new Error("Unexpected token, no definitions found"), {
4659
full: ogLine,
4760
index: 0,

test.ns

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
set variable as "hello"; // "Strings"
2-
log variable; // Logging
3-
4-
set two as 1 + 1; // Numbers
5-
6-
set chalk as require("chalk"); // Npm integration
7-
log chalk.red("Red text"); // Logs red
8-
9-
log 12 / 2 % 2 + 1; // Logs 3
10-
11-
if two == 2 then log "two is equal to 2";
12-
13-
if two != 2 then log "won't be logged" else log "two is not not equal to 2";
1+
log 1 isnot 1;

0 commit comments

Comments
 (0)