ivprog.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import {
  2. I18N_LEXER_TYPES,
  3. I18N_LEXER_COMMANDS,
  4. I18N_LEXER_BOOLVAL,
  5. I18N_LEXER_LOGICOP,
  6. makeLexer,
  7. I18N_LANG_LIBS,
  8. I18N_LANG_FUNCS,
  9. } from "../lexer";
  10. // i18n lexer strings for the language.
  11. const types: I18N_LEXER_TYPES = {
  12. // types
  13. RK_REAL: "real",
  14. RK_INTEGER: "inteiro",
  15. RK_BOOLEAN: "logico",
  16. RK_CHARACTER: "caractere",
  17. RK_STRING: "cadeia",
  18. RK_VOID: "vazio",
  19. };
  20. const commands: I18N_LEXER_COMMANDS = {
  21. // commands
  22. RK_PROGRAM: "programa",
  23. RK_SWITCH: "escolha",
  24. RK_CASE: "caso",
  25. RK_DEFAULT: "contrario",
  26. RK_CONST: "const",
  27. RK_FUNCTION: "funcao",
  28. RK_RETURN: "devolva",
  29. RK_FOR: "para",
  30. RK_FOR_ALT: "repita_para",
  31. RK_FOR_FROM: "de",
  32. RK_FOR_TO: "ate",
  33. RK_FOR_PASS: "passo",
  34. RK_BREAK: "pare",
  35. RK_DO: "repita",
  36. RK_DO_UNTIL: "ate_que",
  37. RK_WHILE: "enquanto",
  38. RK_WHILE_ALT: "repita_enquanto",
  39. RK_IF: "se",
  40. RK_ELSE: "senao",
  41. RK_REFERENCE: "&",
  42. };
  43. const boolVal: I18N_LEXER_BOOLVAL = {
  44. RK_FALSE: "falso",
  45. RK_TRUE: "verdadeiro",
  46. };
  47. const logicOp: I18N_LEXER_LOGICOP = {
  48. RK_LOGICAL_NOT: "nao",
  49. RK_LOGICAL_AND: "E",
  50. RK_LOGICAL_OR: "OU",
  51. };
  52. const langLibs: I18N_LANG_LIBS = {
  53. $mathLib: "Matematica",
  54. $ioLib: "ES",
  55. $strLib: "Texto",
  56. $arrayLib: "Arranjo",
  57. $langLib: "Conversao",
  58. };
  59. const langFuncs: I18N_LANG_FUNCS = {
  60. main_function: "inicio",
  61. $read: "leia",
  62. $write: "escreva",
  63. $numElements: "total_de_elementos",
  64. $matrixLines: "total_de_linhas",
  65. $matrixColumns: "total_de_colunas",
  66. $substring: "subcadeia",
  67. $length: "comprimento",
  68. $uppercase: "caixa_alta",
  69. $lowercase: "caixa_baixa",
  70. $charAt: "caractere_na_posicao",
  71. $isReal: "e_real",
  72. $isInt: "e_inteiro",
  73. $isBool: "e_logico",
  74. $castReal: "como_real",
  75. $castInt: "como_inteiro",
  76. $castBool: "como_logico",
  77. $castString: "como_cadeia",
  78. $castChar: "como_caractere",
  79. $sin: "seno",
  80. $cos: "cosseno",
  81. $tan: "tangente",
  82. $sqrt: "raiz_quadrada",
  83. $pow: "potencia",
  84. $log: "logaritmo",
  85. $abs: "modulo",
  86. $negate: "trocar_sinal",
  87. $invert: "inverter_valor",
  88. $max: "maximo",
  89. $min: "minimo",
  90. $rand: "numero_aleatorio",
  91. };
  92. // END i18n lexer strings
  93. export const ptLexer = makeLexer({
  94. commands,
  95. boolVal,
  96. logicOp,
  97. types,
  98. langLibs,
  99. langFuncs,
  100. });