ivprog.ts 2.1 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: "int",
  15. RK_BOOLEAN: "bool",
  16. RK_CHARACTER: "char",
  17. RK_STRING: "string",
  18. RK_VOID: "void",
  19. };
  20. const commands: I18N_LEXER_COMMANDS = {
  21. // commands
  22. RK_PROGRAM: "program",
  23. RK_SWITCH: "switch",
  24. RK_CASE: "case",
  25. RK_DEFAULT: "otherwise",
  26. RK_CONST: "const",
  27. RK_FUNCTION: "function",
  28. RK_RETURN: "return",
  29. RK_FOR: "for",
  30. RK_FOR_ALT: "repeat_for",
  31. RK_FOR_FROM: "from",
  32. RK_FOR_TO: "to",
  33. RK_FOR_PASS: "pass",
  34. RK_BREAK: "break",
  35. RK_DO: "repeat",
  36. RK_DO_UNTIL: "until",
  37. RK_WHILE: "while",
  38. RK_WHILE_ALT: "repeat_while",
  39. RK_IF: "if",
  40. RK_ELSE: "else",
  41. RK_REFERENCE: "&",
  42. };
  43. const boolVal: I18N_LEXER_BOOLVAL = {
  44. RK_FALSE: "false",
  45. RK_TRUE: "true",
  46. };
  47. const logicOp: I18N_LEXER_LOGICOP = {
  48. RK_LOGICAL_NOT: "not",
  49. RK_LOGICAL_AND: "AND",
  50. RK_LOGICAL_OR: "OR",
  51. };
  52. const langLibs: I18N_LANG_LIBS = {
  53. $mathLib: "Mathematics",
  54. $ioLib: "IO",
  55. $strLib: "Text",
  56. $arrayLib: "Array",
  57. $langLib: "Conversion",
  58. };
  59. const langFuncs: I18N_LANG_FUNCS = {
  60. main_function: "main",
  61. $read: "read",
  62. $write: "write",
  63. $numElements: "total_of_elements",
  64. $matrixLines: "total_of_lines",
  65. $matrixColumns: "total_of_columns",
  66. $substring: "substring",
  67. $length: "length",
  68. $uppercase: "uppercase",
  69. $lowercase: "lowercase",
  70. $charAt: "char_at",
  71. $isReal: "is_real",
  72. $isInt: "is_integer",
  73. $isBool: "is_logic",
  74. $castReal: "to_real",
  75. $castInt: "to_integer",
  76. $castBool: "to_logic",
  77. $castString: "to_string",
  78. $castChar: "to_char",
  79. $sin: "sin",
  80. $cos: "cos",
  81. $tan: "tan",
  82. $sqrt: "sqrt",
  83. $pow: "pow",
  84. $log: "log",
  85. $abs: "abs",
  86. $negate: "negate",
  87. $invert: "invert",
  88. $max: "maximum",
  89. $min: "minimum",
  90. $rand: "random",
  91. };
  92. // END i18n lexer strings
  93. export const enLexer = makeLexer({
  94. commands,
  95. boolVal,
  96. logicOp,
  97. types,
  98. langLibs,
  99. langFuncs,
  100. });