Skip to content
This repository has been archived by the owner on Aug 28, 2022. It is now read-only.
/ strex-lang Public archive

The "Strange expression language" is only used to train regular expressions in JavaScript. Also a bit of parser design in a hopefully not so boring way.

License

Notifications You must be signed in to change notification settings

MartinHelmut/strex-lang

Repository files navigation

StrexLang

Build Status Commitizen friendly code style: prettier

Update: I will no longer maintain this project. Nevertheless, it is still usable and can serve the same purpose.

StrexLang ("Strange expression language") is used to train regular expressions in JavaScript. Also a bit of parser design in a hopefully not so boring way. It is a project where a mentor and trainee can work together in a predefined environment.

Contents


Goal

The Goal is to create an AST in JavaScript that can be serialized. Also to get to know regular expressions in combination with .replace (and what ever fits your needs as well). To get into it you should start with regular expressions that you can rewrite later with a tokenizer.

To test regular expressions the website https://regex101.com/ can be used (in JavaScript mode). Later on (phase 8) the regular expressions are replaced with a tokenizer for a process called "lexical analysis" to give more control over the parser.

Language

An overview of the StrexLang can be found in docs/language.md.

How to start

Installation

Clone this repository locally:

git clone git@github.com:MartinHelmut/strex-lang.git && cd strex-lang

or even better fork this repository. This also makes it easier to update your repository later.

After this install the necessary NPM dependencies:

npm i

Note: If you forked this repository to implement your parser, it would be lovely if you send a PR to add it to the list of possible implementations 🎉

Start development

Open the file src/parser/index.js in your favorite code editor and read the comments included for further guidance.

To test your progress you can execute npm test and see how many green you get 🚀. All tests for the parser, separated by the phases, can be found in the folder src/parser/__tests__. Tests can also provide further documentation.

Phases

Development can be done in phases to get step by step to a more sophisticated language.

  1. Basic language
  2. Advanced types and calculations
  3. Error handling
  4. If expressions
  5. Nested if expressions
  6. "And" and "or" if expressions
  7. Error messages for if expressions
  8. Human readable error messages
  9. Multi line expressions

Phases can also be tested running npm test -- phase-01 (for the first phase). If a later phase is tested all phases before are executed as well to ensure nothing broke.

Note: running npm test will execute not only all phases but the compiler tests as well. If you only want to execute compiler tests you can run npm test -- compiler.

About

The "Strange expression language" is only used to train regular expressions in JavaScript. Also a bit of parser design in a hopefully not so boring way.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •