10000 GitHub - sps014/Parsers
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

sps014/Parsers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parsers

A parse tree generator.
CFG should be Left Recusion free and no left factoring should be there at all.

using static System.Console;
using Parsers.Grammar;
using System.Collections.Generic;
using Parsers.TopDown;
using System;


var input = @"Exp:= int | esp
Exp2:=int * Exp | esp";
//K->ε


var grammer = GrammarBuilder.Build(input);

WriteLine("Productions are:");
grammer.PrintProductions();

WriteLine();
LL1 lL1 = new(grammer);
if (lL1.CreateParseTable())
{
    WriteLine("Parse Table is :");
    lL1.PrintParseTable();
    if (lL1.StackImpl(GrammarBuilder.BuildTerminals("int")))
    {
        WriteLine("\nParse Tree is :");
        lL1.Tree.Print();
    }
}
WriteLine();

Output

output

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0