浏览代码

Strings comments

Arthur Yefimov 2 年之前
父节点
当前提交
e11d6dcc41
共有 1 个文件被更改,包括 52 次插入18 次删除
  1. 52 18
      src/Strings.Mod

+ 52 - 18
src/Strings.Mod

@@ -1,23 +1,27 @@
 MODULE Strings;
-(** Strings provides a set of operations on strings (i.e., on string
-    constants and character arrays, both of which contain the character
-    0X as a terminator).
-     All positions in strings start at 0. *)
+(** This module provides a set of operations on strings (character arrays),
+    that must contain 0X as a terminator.
+     All positions in strings start at 0.
+%RU Этот модуль предоставляет набор операций над строками (массивами литер),
+    которые должны содержать нуль-терминатор (литеру 0X).
+     Все позиции в строках начинаются с 0. *)
 IMPORT Reals, SYSTEM, Out;
 
 TYPE
   REAL = SYSTEM.REAL32;
   LONGREAL = SYSTEM.REAL64;
 
-(** Returns the number of characters in `s`
-    up to and excluding the first 0X *)
+(** Returns the number of characters in `s` up to and excluding the first 0X
+%RU Возвращает количество литер в `s` до первого 0X не включительно *)
 PROCEDURE Length*(IN s: ARRAY OF CHAR): INTEGER;
 VAR i: INTEGER;
 BEGIN i := 0; WHILE (i < LEN(s)) & (s[i] # 0X) DO INC(i) END ;
 RETURN i END Length;
 
 (** Appends string `s` to the end of string `dst`.
-     Has the same effect as Insert(s, Length(s), dst) *)
+     Has the same effect as Insert(s, Length(s), dst)
+%RU Дописывает строку `s` в конец строки `dst`.
+     Имеет тот же эффект, что и Insert(s, Length(s), dst) *)
 PROCEDURE Append*(IN s: ARRAY OF CHAR; VAR dst: ARRAY OF CHAR);
 VAR n1, n2, i: INTEGER;
 BEGIN
@@ -33,7 +37,12 @@ END Append;
      If pos >= Length(dst), src is appended to dst.
      If the size of dst is not large enough to hold the result of the
     operation, the result is truncated so that dst is always terminated
-    with a 0X. *)
+    with a 0X.
+%RU Вставляет строку `src` в строку `dst` в позиции `pos`.
+    (0 <= pos <= Length(dst)).
+     Если pos >= Length(dst), src дописывается к dst.
+     Если размер dst недостаточно велик, чтобы вместить результат операции,
+    результат усекается так, чтобы dst всегда завершался литерой 0X. *)
 PROCEDURE Insert*(IN src: ARRAY OF CHAR; pos: INTEGER; VAR dst: ARRAY OF CHAR);
 VAR n1, n2, len, i, j: INTEGER;
 BEGIN
@@ -59,7 +68,10 @@ END Insert;
 
 (** Deletes `n` characters from `s` starting at position `pos`
     (0 <= pos < Length(s)).
-     If n > Length(s) - pos, the new length of s is pos. *)
+     If n > Length(s) - pos, the new length of s is pos.
+%RU Удаляет `n` символов из `s`, начиная с позиции `pos`.
+    (0 <= pos < Length(s)).
+     Если n > Length(s) - pos, то новая длина s равна pos. *)
 PROCEDURE Delete*(VAR s: ARRAY OF CHAR; pos, n: INTEGER);
 VAR len, i: INTEGER;
 BEGIN
@@ -73,7 +85,9 @@ BEGIN
 END Delete;
 
 (** Has the same effect as Delete(dst, pos, Length(src)) followed by an
-    Insert(src, pos, dst) *)
+    Insert(src, pos, dst)
+%RU Имеет тот же эффект, что и Delete(dst, pos, Length(src)), за которым
+    следует команда Insert(src, pos, dst) *)
 PROCEDURE Replace*(IN src: ARRAY OF CHAR;
     pos: INTEGER; VAR dst: ARRAY OF CHAR);
 BEGIN
@@ -81,13 +95,19 @@ BEGIN
   Insert(src, pos, dst)
 END Replace;
 
-(** Extracts a substring `dst` with `n` characters from position `pos`
-    (0 <= pos < Length(src)) in `src`.
+(** Extracts a substring `dst` with `n` characters from position `pos` in `src`
+    (0 <= pos < Length(src)).
      If n > Length(src) - pos, dst is only the part of src from pos to
     Length(src) - 1.
      If the size of dst is not large enough to hold the result of the
     operation, the result is truncated so that dst is always terminated
-    with a 0X. *)
+    with a 0X.
+%RU Извлекает подстроку `dst` длиной `n` литер из позиции `pos` в `src`
+    (0 <= pos < Length(src)).
+     Если n > Length(src) - pos, то в dst помещается только часть src от pos
+    до Length(src) - 1.
+     Если длина dst недостаточна, чтобы вместить результат операции, он
+    усекается так, чтобы dst всегда завершался литерой 0X. *)
 PROCEDURE Extract*(IN src: ARRAY OF CHAR; pos, n: INTEGER;
     VAR dst: ARRAY OF CHAR);
 VAR len, dstLen, i: INTEGER;
@@ -103,8 +123,14 @@ BEGIN len := Length(src);
   END
 END Extract;
 
-(** Copies `src` to `dst`. If there is no space, truncates it with 0X.
-     Has the same effect as Extract(src, 0, LEN(dst), dst) *)
+(** Copies `src` to `dst`.
+     If the size of dst is not large enough to hold the copy, the result is
+    truncated so that dst is always terminated with a 0X.
+     Has the same effect as Extract(src, 0, LEN(dst), dst)
+%RU Копирует `src` в `dst`.
+     Если длина dst недостаточна, чтобы вместить копию, он усекается так,
+    чтобы dst всегда завершался литерой 0X.
+     Имеет тот же эффект, что и Extract(src, 0, LEN(dst), dst) *)
 PROCEDURE Copy*(IN src: ARRAY OF CHAR; VAR dst: ARRAY OF CHAR);
 VAR i, len: INTEGER;
 BEGIN
@@ -116,7 +142,10 @@ END Copy;
 
 (** Returns the position of the first occurrence of `pat` in `s` after
     position `pos` (inclusive).
-     If pat is not found, -1 is returned. *)
+     If pat is not found, returns -1.
+%RU Возвращает позицию первого вхождения `pat` в `s` после позиции `pos`
+    (включительно).
+     Если pat не найден, возвращает -1. *)
 PROCEDURE Pos*(IN pattern, s: ARRAY OF CHAR; pos: INTEGER): INTEGER;
 VAR n1, n2, i, j: INTEGER;
 BEGIN
@@ -134,7 +163,9 @@ BEGIN
 END Pos;
 
 (** Replaces each lower case latin letter
-    in `s` by its upper case equivalent. *)
+    in `s` by its upper case equivalent.
+%RU Заменяет каждую строчную латинскую букву в `s` на
+    её эквивалент в верхнем регистре. *)
 PROCEDURE Cap*(VAR s: ARRAY OF CHAR);
 VAR i: INTEGER;
 BEGIN
@@ -146,7 +177,10 @@ BEGIN
 END Cap;
 
 (** Performs a pattern match on a given string. Returns TRUE on match.
-     Parameter pattern may include wildcard characters '*'. *)
+     Parameter pattern may include wildcard characters '*'.
+%RU Выполняет поиск совпадения шаблона для заданной строки. Возвращает TRUE
+    при совпадении.
+     Параметр шаблона может включать литеры подстановки '*'. *)
 PROCEDURE Match*(IN string, pattern: ARRAY OF CHAR): BOOLEAN;
 
   PROCEDURE M (IN name, mask: ARRAY OF CHAR; n, m: INTEGER): BOOLEAN;