Skip to content

Commit

Permalink
Merge pull request #1 from natanfeitosa/inicial
Browse files Browse the repository at this point in the history
Codigo inicial
  • Loading branch information
natanfeitosa authored Dec 16, 2023
2 parents 0df44e8 + 68b59f8 commit e05bc53
Show file tree
Hide file tree
Showing 78 changed files with 4,636 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
# *.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
.antlr
49 changes: 49 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

# yaml-language-server: $schema=https://goreleaser.com/static/schema.json

version: 1

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
ldflags: -s -w -X build.Version={{.Version}} -X build.Commit={{.Commit}} -X build.Datetime={{.Date}} -X main.builtBy=goreleaser

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip

changelog:
sort: asc
filters:
exclude:
- "^doc:"
- "^test:"
- "^exemplo:"
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# PortuScript

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

## Sobre

**PortuScript** é uma linguagem de programação brasileira, desenvolvida por brasileiros, totalmente em português. Mais do que uma simples linguagem para treino de lógica, o PortuScript visa proporcionar uma experiência de programação acessível e envolvente para a comunidade de língua portuguesa.

### Características Principais

- **Brasileira por Natureza**: Desenvolvida com o objetivo de ser inclusiva e acessível para falantes de português.
- **Simples e Poderosa**: Projetada para facilitar o aprendizado de programação, mantendo a capacidade de lidar com tarefas complexas.
- **Comunidade Ativa**: Contribua e faça parte de uma comunidade que apoia o crescimento e desenvolvimento do PortuScript.

## Como Começar

### Baixar Binários (Recomendado)

Os binários pré-compilados estão disponíveis para os seguintes sistemas operacionais e arquiteturas:

#### Arquivos binários direto
| Arquitetura | Darwin (macOS) | Linux | Windows |
|-------------|----------------|-------|---------|
| arm64 | [portuscript](dist/portuscript_darwin_arm64/portuscript) | [portuscript](dist/portuscript_linux_arm64/portuscript) | [portuscript.exe](dist/portuscript_windows_arm64/portuscript.exe) |
| i386 | N/A | [portuscript](dist/portuscript_linux_386/portuscript) | [portuscript.exe](dist/portuscript_windows_386/portuscript.exe) |
| amd64_v1 | [portuscript](dist/portuscript_darwin_amd64_v1/portuscript) | [portuscript](dist/portuscript_linux_amd64_v1/portuscript) | [portuscript.exe](dist/portuscript_windows_amd64_v1/portuscript.exe) |


#### Arquivo binário e README compactados

| Arquitetura | Darwin (macOS) | Linux | Windows |
|-------------|--------------------------------------|----------------------------------------|----------------------------------------|
| arm64 | [Darwin_arm64.tar.gz](dist/Darwin_arm64.tar.gz) | [Linux_arm64.tar.gz](dist/Linux_arm64.tar.gz) | [Windows_arm64.zip](dist/Windows_arm64.zip) |
| i386 | N/A | [Linux_i386.tar.gz](dist/Linux_i386.tar.gz) | [Windows_i386.zip](dist/Windows_i386.zip) |
| amd64_v1 | [Darwin_x86_64.tar.gz](dist/Darwin_x86_64.tar.gz) | [Linux_x86_64.tar.gz](dist/Linux_x86_64.tar.gz) | [Windows_x86_64.zip](dist/Windows_x86_64.zip) |

Escolha o binário correspondente ao seu sistema operacional e arquitetura, faça o download e comece a usar o PortuScript imediatamente.

### Compilar a partir do Código Fonte

Se preferir compilar a partir do código fonte, certifique-se de ter o [Go](https://golang.org/doc/install) instalado. Em seguida, execute os seguintes comandos:

```bash
git clone https://github.com/natanfeitosa/portuscript.git
cd portuscript
# Instruções de compilação aqui
```

## CLI - Utilização Básica

A CLI do PortuScript oferece as seguintes funcionalidades:

- **Abrir o Playground**: Se nenhum argumento for passado, a CLI abrirá o Playground interativo.
```bash
portuscript
```

- **Executar Arquivo `*.ptst`**: Se o caminho de um arquivo `.ptst` for fornecido como argumento, o PortuScript executará o script contido no arquivo.

```bash
portuscript caminho/do/arquivo.ptst
```

- **Executar Código Inline**: Se a flag `-c` ou `--codigo` for usada, é possível executar código inline diretamente na linha de comando.

```bash
portuscript -c "seu código aqui"
```

## Exemplos de Uso

Explore o diretório [exemplos](/exemplos/) para encontrar uma variedade de scripts de exemplo que demonstram a versatilidade do PortuScript.

## Gramática

O diretório gramatica contém informações detalhadas sobre a gramática da linguagem. Consulte para uma compreensão mais profunda da estrutura da linguagem.

## Contribuindo
Sinta-se à vontade para contribuir para o desenvolvimento do PortuScript. Para mais informações, consulte o Guia de Contribuição.

> Este projeto está em constante evolução. Se você encontrar problemas ou tiver sugestões, por favor, abra uma [issue](https://github.com/natanfeitosa/portuscript/issues).
Agradecemos pela sua contribuição!
22 changes: 22 additions & 0 deletions anotacoes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Anotações

Algumas anotações possivelmente relevantes

## O que ela suporta?
* - [x] Declaração de variáveis
* * - [ ] Tipagem. _**(opcional)**_
* * - [ ] Inicializador. _**(opcional)**_ **- (Um dos dois deve ser definido)**
* - [ ] Declaração de constantes
* * - [ ] Tipagem. _**(opcional)**_
* * - [ ] Inicializador obrigatorio
* - [x] Declaração de funçoes
* * - [ ] Tipagem de retorno. _**(opcional)**_
* * - [x] Argumentos. _**(opcional)**_
* * * - [ ] Tipagem. _**(opcional)**_
* * * - [ ] Posicionais. _**(opcional)**_
* * * - [ ] Valores padrão. _**(opcional)**_
* - [x] Chamada de função
* * - [ ] Parâmetros nomeados. **_ex.: funcao(1, arg2=2)_**
* - [ ] Classes. **Ainda sendo estudado**
* - [ ] Importação/exportação
* - [ ] Decoradores de funções, classes e/ou atributos
7 changes: 7 additions & 0 deletions build/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package build

var (
Commit string = "-"
Datetime string = "0000-00-00T00:00:00"
Version string = "dev"
)
39 changes: 39 additions & 0 deletions compartilhado/strings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package compartilhado

import (
"unicode"
"unicode/utf8"
)

func ContemApenasLetras(str string) bool {
for _, char := range str {
if !unicode.IsLetter(char) {
return false
}
}
return true
}

func ContemApenasDigitos(str string) bool {
for _, char := range str {
if !unicode.IsDigit(char) {
return false
}
}
return true
}

func IndiceCaractereParaByte(str string, indice int) int {
byteIndex := 0
for i := 0; i < indice; i++ {
_, tamanho := utf8.DecodeRuneInString(str[byteIndex:])
byteIndex += tamanho
}
return byteIndex
}

func ObtemLetraPorIndice(str string, indice int) string {
byteIndex := IndiceCaractereParaByte(str, indice)
letra, _ := utf8.DecodeRuneInString(str[byteIndex:])
return string(letra)
}
Binary file added dist/Darwin_arm64.tar.gz
Binary file not shown.
Binary file added dist/Darwin_x86_64.tar.gz
Binary file not shown.
Binary file added dist/Linux_arm64.tar.gz
Binary file not shown.
Binary file added dist/Linux_i386.tar.gz
Binary file not shown.
Binary file added dist/Linux_x86_64.tar.gz
Binary file not shown.
Binary file added dist/Windows_arm64.zip
Binary file not shown.
Binary file added dist/Windows_i386.zip
Binary file not shown.
Binary file added dist/Windows_x86_64.zip
Binary file not shown.
1 change: 1 addition & 0 deletions dist/artifacts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"name":"portuscript","path":"dist/portuscript_linux_amd64_v1/portuscript","goos":"linux","goarch":"amd64","goamd64":"v1","internal_type":4,"type":"Binary","extra":{"Binary":"portuscript","Ext":"","ID":"portuscript"}},{"name":"portuscript","path":"dist/portuscript_linux_arm64/portuscript","goos":"linux","goarch":"arm64","internal_type":4,"type":"Binary","extra":{"Binary":"portuscript","Ext":"","ID":"portuscript"}},{"name":"portuscript","path":"dist/portuscript_linux_386/portuscript","goos":"linux","goarch":"386","internal_type":4,"type":"Binary","extra":{"Binary":"portuscript","Ext":"","ID":"portuscript"}},{"name":"portuscript.exe","path":"dist/portuscript_windows_amd64_v1/portuscript.exe","goos":"windows","goarch":"amd64","goamd64":"v1","internal_type":4,"type":"Binary","extra":{"Binary":"portuscript","Ext":".exe","ID":"portuscript"}},{"name":"portuscript.exe","path":"dist/portuscript_windows_arm64/portuscript.exe","goos":"windows","goarch":"arm64","internal_type":4,"type":"Binary","extra":{"Binary":"portuscript","Ext":".exe","ID":"portuscript"}},{"name":"portuscript.exe","path":"dist/portuscript_windows_386/portuscript.exe","goos":"windows","goarch":"386","internal_type":4,"type":"Binary","extra":{"Binary":"portuscript","Ext":".exe","ID":"portuscript"}},{"name":"portuscript","path":"dist/portuscript_darwin_amd64_v1/portuscript","goos":"darwin","goarch":"amd64","goamd64":"v1","internal_type":4,"type":"Binary","extra":{"Binary":"portuscript","Ext":"","ID":"portuscript"}},{"name":"portuscript","path":"dist/portuscript_darwin_arm64/portuscript","goos":"darwin","goarch":"arm64","internal_type":4,"type":"Binary","extra":{"Binary":"portuscript","Ext":"","ID":"portuscript"}},{"name":"Darwin_x86_64.tar.gz","path":"dist/Darwin_x86_64.tar.gz","goos":"darwin","goarch":"amd64","goamd64":"v1","internal_type":1,"type":"Archive","extra":{"Binaries":["portuscript"],"Checksum":"sha256:b58bfd028b7e1ddc3669554762e6663ec535eb7c23fd25913e0248b1793dabe1","Format":"tar.gz","ID":"default","Replaces":null,"WrappedIn":""}},{"name":"Darwin_arm64.tar.gz","path":"dist/Darwin_arm64.tar.gz","goos":"darwin","goarch":"arm64","internal_type":1,"type":"Archive","extra":{"Binaries":["portuscript"],"Checksum":"sha256:147991e76c5dc660451cdabeee545768e6f11d8030a4c34ed3a8c8e69934a82e","Format":"tar.gz","ID":"default","Replaces":null,"WrappedIn":""}},{"name":"Linux_arm64.tar.gz","path":"dist/Linux_arm64.tar.gz","goos":"linux","goarch":"arm64","internal_type":1,"type":"Archive","extra":{"Binaries":["portuscript"],"Checksum":"sha256:9b341f836415369f5d2f4f6c0a278852aab5763448a386688304c775f0bfe329","Format":"tar.gz","ID":"default","Replaces":null,"WrappedIn":""}},{"name":"Linux_x86_64.tar.gz","path":"dist/Linux_x86_64.tar.gz","goos":"linux","goarch":"amd64","goamd64":"v1","internal_type":1,"type":"Archive","extra":{"Binaries":["portuscript"],"Checksum":"sha256:270c8cf7c25396037bc3888708dc9883c4e77a54f7aacdd2279265519fd959cf","Format":"tar.gz","ID":"default","Replaces":null,"WrappedIn":""}},{"name":"Linux_i386.tar.gz","path":"dist/Linux_i386.tar.gz","goos":"linux","goarch":"386","internal_type":1,"type":"Archive","extra":{"Binaries":["portuscript"],"Checksum":"sha256:c12d392b9b9344194e1b550062dd0b5a7443abb53bd4c44961b55b535a2afdb1","Format":"tar.gz","ID":"default","Replaces":null,"WrappedIn":""}},{"name":"Windows_x86_64.zip","path":"dist/Windows_x86_64.zip","goos":"windows","goarch":"amd64","goamd64":"v1","internal_type":1,"type":"Archive","extra":{"Binaries":["portuscript.exe"],"Checksum":"sha256:72c6d5b7b406be88aea46f746302745b132c32a93266de3471b9422e49b01de7","Format":"zip","ID":"default","Replaces":null,"WrappedIn":""}},{"name":"Windows_i386.zip","path":"dist/Windows_i386.zip","goos":"windows","goarch":"386","internal_type":1,"type":"Archive","extra":{"Binaries":["portuscript.exe"],"Checksum":"sha256:3594dbfeffca70f07f522fd2cc58b30d306901ff35b2b651c66b898e4b109b99","Format":"zip","ID":"default","Replaces":null,"WrappedIn":""}},{"name":"Windows_arm64.zip","path":"dist/Windows_arm64.zip","goos":"windows","goarch":"arm64","internal_type":1,"type":"Archive","extra":{"Binaries":["portuscript.exe"],"Checksum":"sha256:3507c46ea4ecf058d067189042b60f958bc79012fef1ba97ea4d903d58928143","Format":"zip","ID":"default","Replaces":null,"WrappedIn":""}},{"name":"portuscript_0.0.0-SNAPSHOT-none_checksums.txt","path":"dist/portuscript_0.0.0-SNAPSHOT-none_checksums.txt","internal_type":12,"type":"Checksum","extra":{}}]
128 changes: 128 additions & 0 deletions dist/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
version: 1
project_name: portuscript
release:
github:
owner: natanfeitosa
name: portuscript
name_template: '{{.Tag}}'
builds:
- id: portuscript
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
- "386"
goarm:
- "6"
gomips:
- hardfloat
goamd64:
- v1
targets:
- linux_amd64_v1
- linux_arm64
- linux_386
- windows_amd64_v1
- windows_arm64
- windows_386
- darwin_amd64_v1
- darwin_arm64
dir: .
main: .
binary: portuscript
builder: go
gobinary: go
command: build
ldflags:
- -s -w -X build.Version={{.Version}} -X build.Commit={{.Commit}} -X build.Datetime={{.Date}} -X main.builtBy=goreleaser
env:
- CGO_ENABLED=0
archives:
- id: default
name_template: '{{ title .Os }}_ {{- if eq .Arch "amd64" }}x86_64 {{- else if eq .Arch "386" }}i386 {{- else }}{{ .Arch }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }}'
format: tar.gz
format_overrides:
- goos: windows
format: zip
files:
- src: license*
- src: LICENSE*
- src: readme*
- src: README*
- src: changelog*
- src: CHANGELOG*
snapshot:
name_template: '{{ .Version }}-SNAPSHOT-{{ .ShortCommit }}'
checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt'
algorithm: sha256
changelog:
filters:
exclude:
- '^doc:'
- '^test:'
- '^exemplo:'
sort: asc
dist: dist
env_files:
github_token: ~/.config/goreleaser/github_token
gitlab_token: ~/.config/goreleaser/gitlab_token
gitea_token: ~/.config/goreleaser/gitea_token
before:
hooks:
- go mod tidy
- go generate ./...
source:
name_template: '{{ .ProjectName }}-{{ .Version }}'
format: tar.gz
gomod:
gobinary: go
announce:
twitter:
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
mastodon:
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
server: ""
reddit:
title_template: '{{ .ProjectName }} {{ .Tag }} is out!'
url_template: '{{ .ReleaseURL }}'
slack:
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
username: GoReleaser
discord:
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
author: GoReleaser
color: "3888754"
icon_url: https://goreleaser.com/static/avatar.png
teams:
title_template: '{{ .ProjectName }} {{ .Tag }} is out!'
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
color: '#2D313E'
icon_url: https://goreleaser.com/static/avatar.png
smtp:
subject_template: '{{ .ProjectName }} {{ .Tag }} is out!'
body_template: 'You can view details from: {{ .ReleaseURL }}'
mattermost:
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
title_template: '{{ .ProjectName }} {{ .Tag }} is out!'
username: GoReleaser
linkedin:
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}'
telegram:
message_template: '{{ .ProjectName }} {{ mdv2escape .Tag }} is out! Check it out at {{ mdv2escape .ReleaseURL }}'
parse_mode: MarkdownV2
webhook:
message_template: '{ "message": "{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}"}'
content_type: application/json; charset=utf-8
opencollective:
title_template: '{{ .Tag }}'
message_template: '{{ .ProjectName }} {{ .Tag }} is out!<br/>Check it out at <a href="{{ .ReleaseURL }}">{{ .ReleaseURL }}</a>'
git:
tag_sort: -version:refname
github_urls:
download: https://github.com
gitlab_urls:
download: https://gitlab.com
1 change: 1 addition & 0 deletions dist/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"project_name":"portuscript","tag":"v0.0.0","previous_tag":"","version":"0.0.0-SNAPSHOT-none","commit":"none","date":"2023-12-16T06:15:03.599377354-03:00","runtime":{"goos":"linux","goarch":"amd64"}}
8 changes: 8 additions & 0 deletions dist/portuscript_0.0.0-SNAPSHOT-none_checksums.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
147991e76c5dc660451cdabeee545768e6f11d8030a4c34ed3a8c8e69934a82e Darwin_arm64.tar.gz
b58bfd028b7e1ddc3669554762e6663ec535eb7c23fd25913e0248b1793dabe1 Darwin_x86_64.tar.gz
9b341f836415369f5d2f4f6c0a278852aab5763448a386688304c775f0bfe329 Linux_arm64.tar.gz
c12d392b9b9344194e1b550062dd0b5a7443abb53bd4c44961b55b535a2afdb1 Linux_i386.tar.gz
270c8cf7c25396037bc3888708dc9883c4e77a54f7aacdd2279265519fd959cf Linux_x86_64.tar.gz
3507c46ea4ecf058d067189042b60f958bc79012fef1ba97ea4d903d58928143 Windows_arm64.zip
3594dbfeffca70f07f522fd2cc58b30d306901ff35b2b651c66b898e4b109b99 Windows_i386.zip
72c6d5b7b406be88aea46f746302745b132c32a93266de3471b9422e49b01de7 Windows_x86_64.zip
Binary file added dist/portuscript_darwin_amd64_v1/portuscript
Binary file not shown.
Binary file added dist/portuscript_darwin_arm64/portuscript
Binary file not shown.
Binary file added dist/portuscript_linux_386/portuscript
Binary file not shown.
Binary file added dist/portuscript_linux_amd64_v1/portuscript
Binary file not shown.
Binary file added dist/portuscript_linux_arm64/portuscript
Binary file not shown.
Binary file added dist/portuscript_windows_386/portuscript.exe
Binary file not shown.
Binary file added dist/portuscript_windows_amd64_v1/portuscript.exe
Binary file not shown.
Binary file added dist/portuscript_windows_arm64/portuscript.exe
Binary file not shown.
13 changes: 13 additions & 0 deletions exemplos/aritmetica.ptst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const ano = 2023;

imprima("2023 + 2023 =", ano + ano)
imprima("2023 + 2023 + 10 =", ano + ano + 10)
imprima()

imprima("2023 * 2023 =", ano * ano)
imprima("2023 * 2023 * 10 =", ano * ano * 10)
imprima()

imprima("2023 - 2023 =", ano - ano)
imprima("2023 - 2023 - 2023 =", ano - ano - ano)
imprima()
Loading

0 comments on commit e05bc53

Please sign in to comment.