Package Exports
- treste
- treste/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (treste) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Trest - Linguagem de Programação com Suporte a Cirílico
Linguagem de programação moderna e profissional, estruturalmente organizada e compilável para Web e Desktop (.exe) com suporte completo a cirílico (alfabeto russo).
🎯 Característica Única: Trest permite programar usando palavras-chave em cirílico ou latino, mantendo a mesma sintaxe e funcionalidades.
🚀 Principais Funcionalidades
- ✅ Execução Inline - Execute código direto na linha de comando com
-e - ✅ Compilação para Web - Gera JavaScript otimizado
- ✅ Compilação para Desktop - Cria executáveis .exe nativos
- ✅ Sistema de Módulos - Import/Export de módulos
- ✅ Biblioteca Padrão - std com funções matemáticas, strings, arrays e I/O
- ✅ Tratamento de Erros - Try/Catch/Throw estendido
- ✅ Sintaxe em Cirílico - Palavras-chave em russo
- ✅ Tipagem Dinâmica - Tipos inferidos automaticamente
- ✅ Sistema de Build - Ferramentas de compilação profissionais
📦 Instalação
Instalação via npm (recomendado)
Instalação global:
npm install -g tresteApós a instalação, os comandos trest e trestc estarão disponíveis globalmente:
trest --version
trestc --helpInstalação local em projeto:
npm install tresteUse via npx:
npx trest programa.trest
npx trestc programa.trest --mode webInstalação a partir do código-fonte
Se você quiser instalar a partir do código-fonte ou fazer modificações:
# Clonar o repositório
git clone https://github.com/trest-language/trest.git
cd trest
# Instalar dependências
npm install
# Compilar o projeto
npm run build
# (Opcional) Criar links globais para testes
npm linkRequisitos
- Node.js: >= 18.0.0
- npm: >= 9.0.0
- TypeScript: 5.0+ (para desenvolvimento)
Verifique sua versão:
node --version # deve ser >= v18
npm --version # deve ser >= 9🎯 Guia Rápido
Executar código inline (sem arquivo)
trest -e "печать('Olá, Mundo!')"
trest -e "пусть x = 10; печать(x)"Executar arquivo (interpretador)
trest exemplos/hello_cyrillic.trestCompilar para Web (JavaScript)
npm run compile:web -- exemplos/hello_cyrillic.trest
# ou
trestc exemplos/hello_cyrillic.trest --mode web --output app.jsCompilar para executável (.exe)
npm run compile:exe -- exemplos/hello_cyrillic.trest
# ou
trestc exemplos/hello_cyrillic.trest --mode exe --output app.exe📚 Sintaxe da Linguagem
Todos os exemplos abaixo usam a sintaxe em cirílico (palavras-chave em russo), que é a forma nativa do Trest:
Variáveis
перем имя = "Trest"
пусть возраст = 25
конст pi = 3.14159Funções
функция сложить(a, b) {
вернуть a + b
}
пусть результат = сложить(5, 3)
печать(результат)Condicionais
если (возраст >= 18) {
печать("Совершеннолетний")
} иначе {
печать("Несовершеннолетний")
}Loops
While (Enquanto):
пусть i = 0
пока (i < 10) {
печать(i)
i = i + 1
}For (Para):
для (пусть i = 0; i < 10; i = i + 1) {
печать(i)
}Tratamento de Erros
попытаться {
пусть результат = разделить(10, 0)
} перехватить (ошибка) {
печать("Ошибка:", ошибка)
} наконец {
печать("Операция завершена")
}Módulos
Import (Importar):
импорт { max, min } измодуля "std/math"
импорт * как Math измодуля "std/math"Export (Exportar):
экспорт функция мояФункция() {
вернуть "Привет"
}
экспорт конст константа = 42Objetos
пусть человек = {
имя: "Иван",
возраст: 30,
город: "Москва"
}
печать(человек.имя) # "Иван"Arrays
пусть числа = [1, 2, 3, 4, 5]
печать(числа[0]) # 1
числа[0] = 10
печать(числа) # [10, 2, 3, 4, 5]📖 Biblioteca Padrão (std)
Trest inclui uma biblioteca padrão rica com 11 módulos:
Math (Matemática)
импорт * как Math измодуля "std/math"
пусть x = Math.abs(-5) # 5
пусть y = Math.max(10, 20) # 20
пусть z = Math.sqrt(16) # 4
пусть pi = Math.PI # 3.14159...String (Cadeias de Texto)
импорт * как String измодуля "std/string"
пусть текст = "Привет Мир"
пусть размер = String.размер(текст) # 11
пусть верхний = String.верхний(текст) # "ПРИВЕТ МИР"Array (Arrays)
импорт * как Array измодуля "std/array"
пусть arr = [1, 2, 3]
Array.добавить(arr, 4) # [1, 2, 3, 4]
пусть обратный = Array.обратить(arr) # [4, 3, 2, 1]
пусть отсортированный = Array.отсортировать([3, 1, 2]) # [1, 2, 3]HTTP (Client e Server)
импорт * как HTTP измодуля "std/http"
пусть resposta = HTTP.GET("https://api.example.com")
HTTP.POST("https://api.example.com", данные)
HTTP.создатьСервер(3000, обработчик)Crypto (Criptografia)
импорт * как Crypto измодуля "std/crypto"
пусть hash = Crypto.md5("текст")
пусть sha = Crypto.sha256("данные")
пусть encrypted = Crypto.зашифровать("секрет", "ключ")FileSystem (Sistema de Arquivos)
импорт * как FS измодуля "std/filesystem"
пусть содержимое = FS.читатьФайл("файл.txt")
FS.писатьФайл("выход.txt", "Содержимое")
пусть существует = FS.существуетФайл("файл.txt")JSON (Manipulação de JSON)
импорт * как JSON измодуля "std/json"
пусть obj = JSON.парсить('{"имя": "Иван"}')
пусть str = JSON.строка({имя: "Иван"})Date (Datas)
импорт * как Date измодуля "std/date"
пусть agora = Date.сейчас()
пусть formatado = Date.форматировать(agora, "YYYY-MM-DD")Database (Base de Dados)
импорт * как DB измодуля "std/database"
DB.подключить("sqlite", "dados.db")
DB.выполнить("SELECT * FROM usuarios")RegEx (Expressões Regulares)
импорт * как RegEx измодуля "std/regex"
пусть matches = RegEx.найти("olá mundo", /olá/)
пусть replaced = RegEx.заменить("olá", /olá/, "привет")Path (Caminhos de Arquivo)
импорт * как Path измодуля "std/path"
пусть dir = Path.директория("/caminho/arquivo.txt") # "/caminho"
пусть name = Path.имя("arquivo.txt") # "arquivo.txt"Process (Variáveis de Ambiente)
импорт * как Process измодуля "std/process"
пусть user = Process.получитьEnv("USER")
пусть envs = Process.получитьEnvVars()🏗️ Estrutura do Projeto
treste/
├── src/
│ ├── lexer.ts # Analisador léxico
│ ├── parser.ts # Analisador sintático
│ ├── ast.ts # Definições AST
│ ├── interpreter.ts # Interpretador
│ ├── compiler.ts # CLI do compilador
│ ├── compiler/
│ │ ├── web.ts # Compilador para Web
│ │ └── exe.ts # Compilador para executável
│ ├── std/ # Biblioteca padrão
│ │ ├── math.trest
│ │ ├── string.trest
│ │ ├── array.trest
│ │ ├── http.trest
│ │ ├── crypto.trest
│ │ ├── filesystem.trest
│ │ ├── json.trest
│ │ ├── date.trest
│ │ ├── database.trest
│ │ ├── regex.trest
│ │ ├── path.trest
│ │ ├── process.trest
│ │ └── io.trest
│ ├── types.ts # Sistema de tipos
│ ├── errors.ts # Tratamento de erros
│ └── module.ts # Sistema de módulos
├── exemplos/ # Exemplos de programas
├── docs/ # Documentação completa
├── dist/ # Código compilado
└── package.json🔧 Scripts Disponíveis
npm run build # Compilar TypeScript
npm run build:watch # Compilar em modo watch
npm start <arquivo> # Executar arquivo Trest
npm run compile:web # Compilar para JavaScript
npm run compile:exe # Compilar para executável
npm run bundle # Criar bundle executável📝 Palavras-Chave
Cirílico (Russo) - Sintaxe Principal
| Trest | Equivalente |
|---|---|
если |
if |
иначе |
else |
пока |
while |
для |
for |
функция |
function |
вернуть |
return |
перем, пусть, конст |
var, let, const |
печать |
print/console.log |
импорт |
import |
экспорт |
export |
измодуля |
from |
попытаться |
try |
перехватить |
catch |
бросить |
throw |
наконец |
finally |
прервать |
break |
продолжить |
continue |
истина |
true |
ложь |
false |
Nota: Embora Trest suporte palavras-chave em latino, o uso de cirílico é a forma recomendada e nativa da linguagem.
🌐 Compilação para Web
O compilador para web gera JavaScript moderno que pode ser usado em:
- Navegadores (via
<script>ou bundler) - Node.js
- React/Vue/Angular
- Qualquer ambiente JavaScript
Exemplo:
trestc программа.trest --mode web --output app.js💻 Compilação para Executável
O compilador para executável cria arquivo .exe que:
- Não requer Node.js instalado
- É autossuficiente (inclui todas as dependências)
- Executa diretamente no Windows
Exemplo:
trestc программа.trest --mode exe --output app.exe🎓 Exemplos
Veja a pasta exemplos/ para programas completos demonstrando:
- Operações básicas
- Funções e closures
- Estruturas de controle
- Arrays e objetos
- Módulos e imports
- Tratamento de erros
Exemplos em cirílico:
exemplos/crypto_demo.trest- Demonstração de criptografiaexemplos/http_demo.trest- Cliente HTTP e servidorexemplos/database_demo.trest- Operações de banco de dadosexemplos/filesystem_demo.trest- Operações de arquivoexemplos/todas_funcionalidades.trest- Exemplo completo
📚 Documentação Completa
Para mais informações, consulte a documentação completa em docs/:
- README.md - Guia completo
- FEATURES.md - Todas as funcionalidades
- API.md - Referência da API
- ARCHITECTURE.md - Arquitetura técnica
- WHY_TREST.md - Por que usar Trest
Ou visite o site oficial: https://trest-site.vercel.app
📄 Licença
MIT
👤 Autor
PoktWeb
- Site de documentação: https://trest-site.vercel.app
- GitHub: @poktweb
🤝 Contribuições
Contribuições são bem-vindas! Sinta-se à vontade para abrir issues e pull requests.