-
Notifications
You must be signed in to change notification settings - Fork 0
Syntax and semantics
EM CONSTRUÇÃO
The variables work with optional typing similar to TypeScript, but with the possibility to use the types available through C# language.
types of scope
You can use 'del' to remove the variable, constants and objects from memory when you want, this is a cool and flexible Python resource that some other languages haven't. It increase your control, but remember that you have garbage collector to help you.
Syntax:
del <variable | constant | object>
Sample:
int number = 10
println(number)
del number
println(number)
# Output
> 10
> The variable 'b' was not declared.
To set a variable value as null in some languages, you can do it using the keyword 'nil' (ruby) or 'none' (python), but it's ugly and not objective, because when you think to set a null value you think in 'null' keyword. So Kymera use the key 'null' like C# to it.
Syntax:
<variable | constant | object> = null
Sample: int number = 42 println(number)
number = null
println(number)
# Output
> 42
> null
To print something on console you can use the 'Console' class methods, that is 'print' and 'println'. This is based on Java and C#. The 'Console' class can be implicit.
- Console.print - Just print a text in your console.
- Console.println - Print a text in your console and break line.
Syntaxe:
Console.print(<value_to_print>)
Console.println(<value_to_print>)
Sample:
Console.print("Hello ")
Console.print("Universe!")
# Output
> Hello Universe!
Console.println("Hello ")
Console.println("Universe!")
# Output
> Hello
> Universe!
or
print("Hello ")
print("Universe!")
# Output
> Hello Universe!
println("Hello ")
println("Universe!")
# Output
> Hello
> Universe!
readKey readLine readLines readOptions
Exist two types of comments:
- One-line comment - Use # or // to comment just actual line.
Sample:
# Commented line
// Other commented line
- Multi line comment - Use /* to start a block comment line and use */ to end the comment block.
Sample:
/*
* This
* is
* commented!
*/
In Kymera constants can be declared explicitly with the keyword const than most languages.
Syntaxe:
const PI = <value>
Sample:
const PI = 3.141592653589793
or implicit form using a word that start with uppercase like Ruby Lang.
Note: We recommend that all characters must be in the upper case.
Syntaxe:
<CONSTANT NAME WITH UPPERCASE> = <value>
Sample:
PI = 3.141592653589793
if-else Statement switch Statement
switch(<expression>) {
case <>:
<commands>
break
case <>:
<commands>
break
case <>:
<commands>
break
default:
<commands>
break
}
while Loop while() { }
do-while Loop do { } while())
Blocos serão por chaves {} da mesma forma que o C/C++, Dart, Go, Java, C# e JS usam, pois o uso de begin e end são desnecessários.
--Variáveis: ---A declaração é opcional assim como no GoLang. a //igual ao var, mas é de forma implícita. var a //simplesmente declara a variável como qualquer tipo smallint a int a float a double a char a string a bool a struct a dic a // a{ 'b' : 1; 'c' : 2} tuple a // a() array a // a[] // a const A enum a *ponteiro **ponteiro_de_ponteiro global int a
--Estruturas de repetição:
for elemento in elementos { //procedimento }
for (int x; x<10; x++) { //procedimento }
while ( x < y ) { //procedimento }
do { //procedimento } while ( x < y )
until( x < y ) { yield //procedimento
}
--Comentários:
#comentário de unica linha
//comentário de unica linha
/* comentário de */multiplas linhas
--Funções: func correr (var a) { //faz algo return algo } .sucess { } .error { } .then { } .catch { } .finally { }
funcao () { //do anything }
--Tratamento de erros try{ } execept { } finally { }
--Fluxo
if (condição) { } else { }
if (condicao 1) { } elif { }
switch (valor) { case 1: //faça x //break não é necessário case 2, 3: default: }
unless (condicao) { }
label a goto a
--Orientação a objetos: class Animal { constructor(var a, var b) { this.a = a this.b = b }
func voar () { } }
class Cachorro extends Animal, Outro { }
class Gato implements Animal, Outro { super(a) //permite sobrescrita de métoco }
gato = Gato(var a, var b) //instanciação
static class Veiculo { }
abstract class Veiculo {
}
--Documentação: doc ('texto documentado') //receber um texto simples, caso precise de muitas linhas, passe como parâmetro um arquivo txt.
--Modificadores de acesso: ---em class, os atributos são privados e métodos são privados por padrão. funções em geral são públicas. ---public: blabla ---private: blabla ---protected: blabla
--Métodos padrão
map () lambda () int(), str(), double(), float(), ... find_one() find_all() exist() empty()
^ / %
<=
= === or // || and // && xor nor // !|| nand // !&& not // !
--Operadores de atribuição:
funções: -pass