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