Git Product home page Git Product logo

bralang's Introduction

BraLang

BraLang

BraLang é uma linguagem de programação adaptada para falantes nativos do português, sobretudo estudantes de escolas públicas, os quais historicamente possuem acesso precário ou ineficiente à língua inglesa e encontram nisso um obstáculo no aprendizado de programação. A BraLang ataca justamente essa dor e foi projetada com o objetivo de quebrar a barreira linguística, visando fornecer uma abordagem mais intuitiva e culturalmente relevante para estudantes e educadores que se sentem mais confortáveis com palavras-chave e estruturas baseadas no português.

A apresentação completa da BraLang no formato .pdf está disponível na raiz deste repositório, no arquivo "Apresentacao_BraLang.pdf"

EBNF:

PROGRAM = { STATEMENT };

BLOCK = { "{", STATEMENT, "}" };

STATEMENT = ( λ | ASSIGNMENT  | IF_STATEMENT | PRINT | FOR | COMMENT ), "\n" ;

ASSIGN = IDENTIFIER, "=", EXPRESSION;

PRINT = "mostre", "(", EXPRESSION, ")";

FOR = "para", IDENTIFIER, EXPRESSION, EXPRESSION, BLOCK;

IF = "se", EXPRESSION, BLOCK, ["senao", BLOCK];

EXPRESSION = TERM, {("+" | "-" ), TERM};

TERM = FACTOR, {("==" | "!=" | ">" | "<" | ">=" | "<="), FACTOR};

FACTOR = (("+" | "-" | "!" | "*" | "/"), FACTOR | DIGIT | "(", EXPRESSION, ")" | IDENTIFIER);

TYPE = ("int" | "string");

COMMENT = "//", { Any valid character }, "\n";

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

NUMBER = DIGIT, { DIGIT }, [".", {DIGIT}];

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

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

Testando a linguagem:

Flex & Bison:

flex flex.l
bison -d bralang.y
gcc lex.yy.c bralang.tab.c -o bralang
./bralang < teste.bl

Compilador:

cd Compilador
python main.py main.bl

Exemplos:

Exemplo (1) de código escrito em BraLang:

variavel y int = 2
variavel z int
z = (y == 2)   // comparação booleana
mostre(y+z)    // 3
mostre(y-z)    // 1
mostre(y*z)    // 2
mostre(y/z)    // 2
mostre(y == z) // 0
mostre(y < z)  // 0
mostre(y > z)  // 1

Exemplo (2) de código escrito em BraLang:

mostre("- - - BraLang - - -")

mostre("Olá, tudo bem?")
mostre("Para mostrar algo na tela, utilize o mostre()")

mostre("- - - BraLang - - -")

Exemplo (3) de código escrito em BraLang:

variavel x int = 0
variavel y int = 2
para x = 0; x < 5 && y == 2; x = x + 1 {
    mostre("Ola!")
}
mostre("Você chegou ao fim do seu programa BraLang!!")

Exemplo (4) de código escrito em BraLang:

variavel x_1 int = 3
se (x_1 > 1 && !!!(x_1 < 1)) || x_1 == 3 {
    x_1 = 2
    mostre(x_1)
} senao {
    mostre(x_1+1)
}
mostre("Fim!")

Exemplo (5) de código escrito em BraLang:

variavel a string
variavel b string
variavel x_1 int = 1

x_1 = 1
y = 1
z = 2
a = "abc"
b = "defg"
mostre(a.b) //concatenacao
mostre(a.x_1)
mostre(x_1.a)
mostre(y.z)
mostre(a.(x_1==1))
mostre(a == a)
mostre(a < b)
mostre(a > b)

bralang's People

Contributors

listerogusuku avatar

Watchers

 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.