Skip to content

Instantly share code, notes, and snippets.

View Adib23704's full-sized avatar
:octocat:
Available for Hire!

Zahin A. Adib Adib23704

:octocat:
Available for Hire!
View GitHub Profile
@Adib23704
Adib23704 / LR.js
Last active October 31, 2024 16:22
LR(0) Grammer Parser Algorithm
// Define the grammar
const grammar = {
nonTerminals: ['S', 'A'],
terminals: ['a', 'b'],
productions: [
{ left: 'S', right: ['A', 'a'] },
{ left: 'S', right: ['b'] },
{ left: 'A', right: ['a', 'A'] },
{ left: 'A', right: [] }
]
@Adib23704
Adib23704 / LL.js
Last active June 6, 2023 18:59
LL(1) Grammer Parser Algorithm
class LL1Parser {
constructor() {
this.index = 0;
}
parse(input) {
this.tokens = input.split(' ');
this.index = 0;
try {
@Adib23704
Adib23704 / DFA.js
Last active June 6, 2023 19:03
Regular Expression to NFA, NFA to DFA Conversion Algorithm.
class State {
constructor(name) {
this.name = name;
this.transitions = {}; // Holds the transitions from this state
this.isFinal = false; // Indicates whether this state is a final state
}
}
class DFA {
constructor() {