tropwer

0.1.8 • Public • Published

Tropwer

Developed in javascript and typescript

How use?

To start with (Tropwer) we must have 3 files

  • index.js or index.ts
  • lexer.js or lexer.ts
  • grammar.tr

In index.js or (index.ts) we do:

const grammar = require('./grammar')

const { name, type, value, data } = grammar.feed("x=1")

console.log(`==${name}==\n\nVariable name : ${data[0]}\n Variable value : ${data[1]}`)

In lexer.js or (lexer.ts) we do:

const moo = require("moo");

const lexer = moo.compile({
  equals: "=",
  identifier: /[a-zA-Z]+/,
  number: /[0-9]+/
})

module.exports = lexer;

In grammar.tr we do:

# Declare a token with (name: variable, type: variable)
variable -> %identifier %equals %number 

Now we just have to compile the grammar.tr to a javascript or a typescript

npx tropwer grammar.tr --o=grammar.js --lexer=lexer.js

and finally run

node index.js

Why Tropwer was created?

Because I had a lot of problems with nearley and that's why I created my own parser (Tropwer) with the purpose of simplicity and ease

Why name (tropwer):

Yes this name came from the head I don't even know where I was thinking when I put this name

Readme

Keywords

none

Package Sidebar

Install

npm i tropwer

Weekly Downloads

2

Version

0.1.8

License

MIT

Unpacked Size

79.1 kB

Total Files

18

Last publish

Collaborators

  • florest