view docs/examples/example-1.pseudocode @ 282:90946f87d77d

Rename RE group "character" -> "characters"
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 20 May 2026 17:28:22 +0200
parents 50bd1e91b822
children
line wrap: on
line source

// -*- coding: utf-8; indent-tabs-mode: nil -*-
\PROGRAM {The Pseudocode Lexer} \IS

  /*
   * The program is here, but it also could be an \ALGORITHM
   *
   * /* YES! Nested multi-line comments work! */
   */

  \PROC {A Procedure name} \IS
    \TBLOCK {A text block 1}
    \TBLOCK {A text block 2 with a nested expression: \expr{flag is FALSE}}
    \BLOCK {
        \REMARK  A remark on its own line within a "BLOCK"
    }
  \END-PROC {A Procedure name}

  \FUNCTION{A Function with {escaped\} text} \IS
    (1234567890 != what) or a and b xor (c in d)   \rem this is another remark
    \block {foo is not bar}
    \block {2 + 6 = 1 (mod 7)}

    \IF a is nil \THEN
      \text{Set something}
    \ELSEIF
      \text{Set some other thing}
    \END-IF
  \END FUNCTION{A Function with {escaped\} text}

  \CLASS{A Class} \IS
    // This is a one-line comment
    a and b xor (c in d)      \rem this is another remark

    # This is another one-line comment

    (* Here is a "block" of expressions.
       A block has a leading symbol. *)
    \block {foo ?= bar
      Bär >= Maus
        and Bär != Maus}
    \block{a 1.2 {x in X\} c}
    (* Analogous there is a variant that is in text-mode by default.
       It has an other leading symbol. *)
    \tstate{We will compute next \expr{a xor b or (\text{set} X is Empty)} \rem without c!
      or multiply it the \ttx-ges/other/ way.}

    \tstate{foo bar     \rem A remark within a text statement until LF!
      nextfoo nextbar
      nextnextfoo nextnextbar}
  \ENDCLASS{A Class}

  @A_XXX
  FOO BAR
\ENDPROG