Giter Club home page Giter Club logo

syntax-analyzer-generator's Introduction

Simple Syntax Analyzer Genrator

Nicolás Viveros 
[email protected]

The following, is a simple syntax analyxer generator written completely in python. It can currently be tested and used with the lexer file located at the /Lexer folder. It works with LL(1) grammars ONLY.

Usage with other Lexer Analyzers

For usage with other lexers, you will have the change the name of the tokens according to the names of your lexer tokens. Aditionally, your have to provide the getNextToken() method, and the Control class.

How to use

In order to use the generator, you have to specify the grammar in the inputs.txt file, which has the following format:

  • All non terminals have to be in UPPECASE.
E.g:  

SUM is permitted
Sum is NOT permitted
  • Once you're done specifiyng the non termninal, you have to use an arrow -> to specify the end of the left part of the rule.
  • To specify the right part of the rule, you have to write a set of terminals and/or non terminals (terminals MUST be all lowercase)
E.g: 

abc is permitted
aBs is not permitted

  • Bot terminals and non terminals MUST be alphabetic characters only (a-z including _ )
Example grammars:

S -> A B C
S -> D E
A -> dos B tres
A -> EPSILON
B -> cuatro C cinco
B -> EPSILON
C -> seis
C -> EPSILON
D -> uno A E
D -> B
E -> tres A

Commentaries

The program supports commenaties in the inputs.txt file, and they must be in one of the two formats:

//Single line comments

/*
Multi line comments
*/

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.