0.1.8 • Published 2 years ago

tropwer v0.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Tropwer

Developed in and

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

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.8

2 years ago

0.0.9

2 years ago

0.1.7

2 years ago

0.0.8

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.0.7

2 years ago

0.1.5

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago