blenderskool / vyaakaran Goto Github PK
View Code? Open in Web Editor NEW๐ Visualize formal languages and automata
Home Page: https://vyaakaran.now.sh
License: MIT License
๐ Visualize formal languages and automata
Home Page: https://vyaakaran.now.sh
License: MIT License
A CLI tool over the existing Vyaakaran compiler which exposes similar functionality to the Vyaakaran editor.
The CLI tool would take source grammar file as input and generate an output based on the type of grammar:
test
and strings
command from the console that would work for all the above grammar types.For someone interested to work on this:
compiler
and editor
code to familiarize yourself with various functions exposed by compiler
to process grammars.cli
directory at the root of the project and add it to the pnpm-workspace.yaml
file.@vyaakaran/compiler
as a dependency in the cli
project to use all the functions exposed by the compiler
.Rough idea that occurred to me while using Vyaakaran
The way I write grammars usually has following iterations:
This approach makes writing complex grammars simpler as you don't have to think about fine details at the start. But it also has a downside of causing unexpected changes in the intended language the grammar represents as you extend it in every iteration.
With a TDD approach, I would be able to define some sample tests of strings that I'd always want my language to accept / reject.
These tests would always run when I compile the grammar and let me know if any of my tests are failing. In case a test fails, it indicates my grammar has deviated somewhere and is no longer representing the language I intend it to.
For someone interested to work on this:
Take references from:
Vyaakaran already has the pieces in the compiler to test whether a string gets accepted, rejected, or accepted with ambiguity by the grammar. Thus, no new functionality needs to be added in the compiler itself. Check the existing console code to see how the test
command works:
vyaakaran/editor/src/config/console.ts
Lines 125 to 138 in c541405
A new section in the UI must be added for Regular Grammars and Context Free Grammars where the user can define a list of test strings (acceptable / unacceptable) and whenever the user compiles their grammar, all the test strings are tested against the grammar and the result is visually displayed for each test with appropriate colors.
Defining example strings that are a part of your language is easier than writing the grammar directly.
There can be a feature in Vyaakaran that allows the user to enter strings that are a part of the language and Vyaakaran generates the grammar code directly from that.
Not sure about feasibility and complexity of this, but it should possibly be explored in following order:
The string validator's input and example string generator's output are inconsistent in some edge cases. Ideally, an output of the generator should also be a valid input to the validator.
""
, whereas the generator outputs ""
for empty strings.This issue can be updated with further edge cases that have inconsistencies.
Description:
We propose the following enhancements to improve the efficiency of regular language processing:
NFA to DFA Conversion: Implement the subset construction algorithm to convert Non-deterministic Finite Automata (NFA) to Deterministic Finite Automata (DFA).
DFA State Minimization: Add an algorithm to minimize DFA states by merging equivalent states, producing a more efficient automaton.
Optimization Algorithms:
Following Parse table generators can be added in the CFG playground:
Syntax cheat sheet is currently available as comments in the editor. A better UI should be created for it to keep the editor clean and the cheat sheet always accessible.
Set up GitHub Actions for CI (tests on PRs) and CD (deploy on pushes).
Tokenization currently doesn't use look-forward to create tokens. It groups tokens based on their individual classification.
This causes -
symbol to be treated as a Separator
even though it could be Literal
(as there is no special meaning with just -
symbol in the syntax apart from its usage in ->
symbol).
The parser should be updated to return a parse tree rather than array of productions.
All the core Vyaakaran processing happens on the main thread which may lead to blocked UI in some heavy and long-running algorithms. Explore ways of moving these algorithm calls to maybe Web Workers which can be physically terminated by the user if they don't prefer waiting.
Unit testing setup with possibly Vitest for the compiler and editor module that will allow us to write unit tests for different parts of the codebase.
Why Vitest
Error messages returned from the parser can be further improved for readability.
Ctrl + Enter
running the renderer would be a great UX addition.
PS: Killer app!
Think about whether saving some editor data in localStorage
would help users continue where they left off. This data can include:
Unacceptable strings generated for the following grammar are incorrect.
S -> # | a S.
No unacceptable strings are generated as the above grammar matches all strings with symbol a.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.