ivprog.ts 2.3 KB

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