1.0.7 • Published 4 years ago

jsm-parser v1.0.7

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

JSM

A language that allows you to write mathematics.

How to install

To install JSM package, you'll need NPM. Afterward, you can run that command from a terminal:

npm i jsm-parser

You're now ready to code in JSM.

How to listen to file

With JSM, it's quite simple to make it work, you will only need a few lines in Javascript :

const jsm = require('jsm-parser')

jsm.parse('<YOUR FILE>.fs').then(jsm_content => console.log(jsm_content))

That code will parse the file content and console log it.

How does it work

JSM will read each line of your code and transpile its into Javascript.

> 4 + 5 + 10 * 2

As you can see, this is a sample JSM line. It will give you that Javascript code :

const  _4yjqps = 4 + 5 + 10 * 2

For each instruction line, an ID is generated to avoid double. That ID isn't random.

Now, let's introduce the new keyword.

> new function test of x = 5x + 2 - 2x

You can see an example use of the new keyword. Here, we generated a sample function called test that has x as a variable. In mathematics, that would be : test(x) = 5x + 2 - 2x. As you can see here, the multiplication sign isn't required.

This is the Javascript code generated :

const  _3vubcw_test = (x) =>  5*x + 2 - 2*x

There's also an ID that represent the function name.

When you have these functions, you can ask : how to call theses? The call keyword is your solution. With that keyword, you can call any function you want like that :

> call test for x = 2

As you can see, we have the keyword that allows us to call the function called test for the variable x which we assign value of 2.

That will generate the following code :

_3vubcw_test(2)

You can see that the parser add automatically the function ID.

1.0.7

4 years ago

1.0.6

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago