Giter VIP home page Giter VIP logo

cfg-to-pda's Introduction

CFG to PDA Converter

A context free grammar to pushdown automaton converter that operates with Greibach Normal Form inputs.

Use

Run cfgToPda.py to import grammar, after conversion, type in 'y' if you wish to parse strings.

Sample grammars are stored in ./Samples/, each are a set of two files; sample strings to parse (and their results) and the main grammar file.

Grammar file structure:

  • first line: single initial variable (e.g. S)
  • second line: comma seperated list of terminals
  • next lines: each line contains Greibach rules of a grammar in the format A->aBC|aBB

There is a debug mode flag in cfgToPda.py that shows stack contents while parsing (global variable).

cfg-to-pda's People

Contributors

af4rinz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cfg-to-pda's Issues

adding epsilon to grammer.txt?

How would you represent the following CFG?

S → a T X b
T → X T S | ε
X → a | b

I am confused on how to represent the EPSILON in the grammer.txt file that is read. Everything I have tried as rejected 'abb' which should be a part of the language.

Thanks for any help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.