-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(*): refaz o lexer e melhora a performance
- Loading branch information
1 parent
23cae2b
commit 794c9bd
Showing
17 changed files
with
518 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package compartilhado | ||
|
||
func ContemApenasAlfaNum(str string) bool { | ||
return ContemApenasDigitos(str) || ContemApenasLetras(str) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package lexer | ||
|
||
var tokensSimples = map[string]TokenType{ | ||
"\n": TokenNovaLinha, | ||
|
||
"=": TokenIgual, | ||
"+": TokenMais, | ||
"-": TokenMenos, | ||
"*": TokenAsterisco, | ||
"**": TokenPotencia, | ||
"/": TokenDivisao, | ||
"//": TokenDivisaoInteira, | ||
"%": TokenModulo, | ||
"<": TokenMenorQue, | ||
"<=": TokenMenorOuIgual, | ||
"==": TokenIgualIgual, | ||
"!=": TokenDiferente, | ||
">": TokenMaiorQue, | ||
">=": TokenMaiorOuIgual, | ||
"(": TokenAbreParenteses, | ||
")": TokenFechaParenteses, | ||
";": TokenPontoEVirgula, | ||
",": TokenVirgula, | ||
"{": TokenAbreChaves, | ||
"}": TokenFechaChaves, | ||
"[": TokenAbreColchetes, | ||
"]": TokenFechaColchetes, | ||
":": TokenDoisPontos, | ||
|
||
// Reatribuicao | ||
"+=": TokenMaisIgual, | ||
"-=": TokenMenosIgual, | ||
"*=": TokenAsteriscoIgual, | ||
"/=": TokenBarraIgual, | ||
|
||
"|": TokenBitABitOu, | ||
"^": TokenBitABitExOu, | ||
"&": TokenBitABitE, | ||
"~": TokenBitABitNao, | ||
"<<": TokenDeslocEsquerda, | ||
">>": TokenDeslocDireita, | ||
|
||
".": TokenPonto, | ||
} | ||
|
||
var tokensIdentificadores = map[string]TokenType{ | ||
"se": TokenSe, | ||
"senao": TokenSenao, | ||
"enquanto": TokenEnquanto, | ||
"para": TokenPara, | ||
"retorne": TokenRetorne, | ||
"pare": TokenPare, | ||
"continue": TokenContinue, | ||
|
||
"de": TokenDe, | ||
"importe": TokenImporte, | ||
|
||
"Verdadeiro": TokenVerdadeiro, | ||
"Falso": TokenFalso, | ||
"Nulo": TokenNulo, | ||
|
||
"var": TokenVar, | ||
"const": TokenConst, | ||
"func": TokenFunc, | ||
|
||
// Operadores booleanos | ||
|
||
"ou": TokenBoolOu, | ||
"e": TokenBoolE, | ||
"nao": TokenBoolNao, | ||
} |
Oops, something went wrong.