Giter Club home page Giter Club logo

pyrthon's Introduction

Pyrthon

A compiler built for my own programming language based on rural speech.

Instructions to execute:

Go to this path

cd compiler

Execute the main.py script and don't forget to include the .pyr script to run the program.

python3 main.py test_scripts/pyr_scripts/hello_world.pyr

or

python3 main.py test_scripts/pyr_scripts/{ANY_SCRIPT}

The Pyrthon scripts are located on

cd compiler/test_scripts/pyr_scripts/

EBNF

PROGRAM = (λ | DECLARATION);

DECLARATION = ("nurmero" | "tersto" | "vazi"), IDENTIFIER, "(", { ("nurmero" | "tersto"), IDENTIFIER, { "," | ("nurmero" | "tersto"), IDENTIFIER} }, ")", BLOCK;

BLOCK = ("[", STATEMENT, "]" | "[", "]");

STATEMENT =  (((λ | ASSIGNMENT | PRINT  | VAR_TYPE | RETURN), ";") | (BLOCK | IF | WHILE));

FACTOR = INT | STRING | (IDENTIFIER, { "(", { RELEXPRESSION, { "," | RELEXPRESSION } } ")" }) | (("maris" | "mernos" | "contra" FACTOR) | "(", RELEXPRESSION, ")" | SCANF;

TERM = FACTOR, { ("verzes" | "divirdido" | "tambem"), FACTOR };

EXPRESSION = TERM, { ("maris" | "mernos" | "ou"), TERM } ;

RELEXPRESSION = EXPRESSION , {("mernor" | "marior" | iguar") , EXPRESSION } ;

WHILE = "enquarto", "(", RELEXPRESSION ,")", STATEMENT;

IF = "si", "(", RELEXPRESSION ,")", STATEMENT, (("sirnao", STATEMENT) | λ );

ASSIGNMENT = (IDENTIFIER, "receba", RELEXPRESSION) | ( "(", { RELEXPRESSION, { "," | RELEXPRESSION } }, ")" );

RETURN = "vorte" , "(", RELEXPRESSION, ")";

PRINT = "aspresenti", "(", RELEXPRESSION, ")";

SCANF = "sorta", "(", ")";

IDENTIFIER = LETTER, { LETTER | DIGIT | "_" };

DIGIT = (0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9);

INT = DIGIT, { DIGIT };

VAR_TYPE = ("nurmero" | "tersto") , IDENTIFIER , (λ | {"," , IDENTIFIER });

STRING = """, (LETTER | DIGIT), """;

LETTER = ( a | ... | z | A | ... | Z ) ;

pyrthon's People

Contributors

antoniofuziy avatar

Stargazers

 avatar  avatar  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.