Coder Social home page Coder Social logo

analyzer-syntactic-for-operator-grammar's Introduction

☀️ Analyzer syntactic for operator grammar

Analyzer syntactic for operator grammar in Python.

💻 Requirements

Python3 and pip3.

(opcional) If you want, you can create a virtual environment:

python3 -m venv env

Activate virtual environment:

  • Unix/macOS
source env/bin/activate
  • Windows
./env\Script\activate

Install requirements:

pip3 install -r requirements.txt

For install coverage

🔥 For run it

python3 main.py

💡 How to use it

  1. RULE <no-terminal> [<symbol>]

Define a new rule in the grammar for the symbol. The list of symbols in [<symbol>] is a space-separated (potentially empty) list of terminal symbols or not terminals.

For example:

RULE A a A b - Represents the rule: A → a A b

RULE B - Represents the rule: B → λ

The program should report an error and ignore the action if the symbol placed on the left side of the rule is not non-terminal or if the expressed rule does not correspond to a grammar of operators.

  1. INIT <no-terminal>

Sets the initial symbol of the grammar to be the symbol in . For example: INIT B - Sets the symbol B as the initial symbol of the grammar. The program should report an error and ignore the action if the symbol is not non-terminal.

  1. PREC <terminal> <op> <terminal>

Establishes the relationship between two terminals (or $). This <op> operation can be:

< when the first terminal has lower precedence than the second

> when the first terminal has higher precedence than the second

= when the first terminal has the same precedence as the second

For example:

PREC + < * - Sets that + has lower precedence than *

PREC (=) - Sets that (has the same precedence as)

PREC $ > n - Sets that $ (border marker) has higher precedence than n

The program should report an error and ignore the action if the symbols involved are not symbols terminals or if the operator in <op> is invalid.

  1. BUILD

Build a parser with the information provided so far. Must report calculated values for functions f and g (views in class) or report what to build such functions is impossible, showing evidence for it.

  1. PARSE <string>

It performs the parsing process on the string supplied in <string>. Must show each of the steps, including:

Stack - Current status of the stack

Input - Current status of the input. This statement should clearly show the relationships of precedents and the point where it is currently being read (see example).

Action - Action taken (read or reduce by a particular rule)

For example:

PARSE n + n * n - Perform the process on the string n + n * n

The program should report an error and ignore the action if the symbols involved are not symbols terminals, there are non-comparable symbols or if you have not BUILD previously. Between each to symbol terminals in <string> there can be any (potentially zero) amount of Blanks.

  1. EXIT

You must exit the simulator.

🔍 For run the tests

coverage3 run --source=analyzer -m unittest test.py

Coverage of the tests

coverage3 report -m
Module Coverage
Analyzer 65%

analyzer-syntactic-for-operator-grammar's People

Contributors

mafermazu avatar

Watchers

 avatar  avatar

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.