Project status

  • Partially completed: string-based floating-point addition for the the Chaga string arithmetic library.
  • Partially completed: implementing selection statements in Chaga compiler.
  • COMPLETED: data structure to store floating point numbers in the Chaga string arithmetic library.
  • COMPLETED: implementing Boolean datatypes in Chaga compiler.
  • COMPLETED: string-based integer remainder (modulo function) in Chaga string arithmetic library.
  • COMPLETED: string-based integer division added to Chaga string arithmetic library.
  • COMPLETED: string-based integer multiplication added to Chaga string arithmetic library.
  • COMPLETED: string-based integer subtraction added to Chaga string arithmetic library.
  • COMPLETED: string-based integer addition added to Chaga string arithmetic library.
  • COMPLETED: The Chaga compiler is now generating Intel x86 assembler instructions for simple Chaga programs that write text to the screen. I can assemble and link these instructions to make executable Chaga programs.
  • COMPLETED: tokenizer.
  • COMPLETED: symbol table.
  • Partially completed: Concrete Syntax Tree (CST). The CST is a gigantic deterministic finite automaton using recursive descent parsing. Thus far I'm completely parsing the following statements:
    • define (for functions, procedures)
    • declare (for variable)
    • print (for integer and Boolean datatypes and static strings)
    • set (for integer and Boolean datatypes only)
  • Partially completed: Abstract Syntax Tree (AST) and intermediate code generation.
  • Partially completed: x86 assembly language subroutines to access argv and argc variables from GNU/Linux operating system, Also have x86 assembly language to read from standard input and write to standard output with a character buffer. Lastly, I have x86 code to generate output from static character string buffers. All assembly language programs run under GNU/Linux.
  • To do: Brainstorming on techniques for automatic garbage collection (memory management for memory requested on-the-fly from the heap). I would like applications written in Chaga to be safe from memory-leaks.

Tentative features to add

  • Allow main procedure to accept environment variables, argv and argc from the operating system.
  • Add built-in support for coroutines
  • Add built-in support for blocking and non-blocking threads
  • Add support for new datatype: pipes.
  • Add support for new datatype: socket.
  • Add support for new datatype: shared memory.

The Chaga string arithmetic library

About the string library

The Chaga string arithmetic library manages the numerical datatypes (int, float, complex, and imaginary) supported in the Chaga programming language. I documented the functions below because they are part of the Chaga compiler (i.e. internal infrastructure).

Internal typedef structures

  • Structure of stringint (string-based integer)
  • Structure of stringfloat (string-based real number)
  • Structure of stringcomplex (string-based complex number containing a real and imaginary component)
  • Structure of stringimaginary (string-based imaginary number)

Stringint management functions

  • display_stringint_structure: a diagnostic subroutine meant for debugging purposes only. This subroutine displays the structure of a stringint.
  • stringint_release_memory: release the memory used to store the string-based integer structure.
  • stringint_append_digits: add a digit to a string-based integer.
  • stringint_count_digits: count the number of digits in a string-based integer (leading zeros are not included in the count). Example: 0005 contains one digit.
  • stringint_determine_absolute_value_larger_of_two_integers (num1, num2): determine the larger of the absolute value of num1 and num2. Return value: +1 (for num1 > num2); 0 (for num1 == num2); -1 (for num1 < num2).
  • stringint_determine_absolute_value_number_greater_than_one (num): determine if the absolute value of num is greater than one. Return value: +1 (for num1 > 1); 0 (for num == 1); -1 (for num1 < 1).

Stringint Boolean functions

  • stringint_less_than (num1, num2): TRUE if num1 < num2
  • stringint_equal (num1, num2): TRUE if num1 == num2.
  • stringint_not_equal (num1, num2): TRUE if num1 != num2.
  • stringint_greater_than (num1, num2): TRUE if num1 > num2
  • stringint_less_than or equal (num1, num2): TRUE if num1 <= num2
  • stringint_greater_than_or_equal (num1, num2): TRUE if num1 >= num2

Stringint math functions

  • stringint_increment_one (num): result = num + 1
  • stringint_decrement_one (num): result = num - 1
  • stringint_negate (num): result = (-1) * num. Note: stringint_negate flips the sign bit on the number. It does not perform a multiply operation. This is for performance reasons on very large string-based integers.
  • stringint_add (result, num1, num2): result = num1 + num2
  • stringint_subract (result, num1, num2): result = num1 - num2
  • stringint_multiply (result, num1, num2): result = num1 * num2
  • stringint_divide (result, num1, num2): result = num1 / num2. Note: Any remainder is truncated.
  • stringint_modulo (result, num1, num2): result = num1 % num2. Note: Returns the remainder from a division.
  • stringint_factorial (result, num): computes the factorial of num where num >= 0

Stringint miscellaneous functions

  • stringint_set_sign (num, sign): set the sign of a string-based integer. Possible value for sign are {positive, negative, zero}.
  • stringint_set_value (num, "string"): initialize a string-based integer to an initial, input value defined by a constant string. Example: stringint_set_value (num1, "-12345678901234567890")
  • stringint_initialize_to_zero (num): initialize the value of a string-based integer variable to zero.
  • stringint_copy_number (target, num): make a copy of a string-based integer variable into target. Note: target will have its own memory allocation.
  • stringint_to_stringfloat (num): convert a string-based integer to string-based floating point number.
  • stringint_to_stringcomplex (num): convert a string-based integer to string-based complex number. Note: the imaginary component of resulting complex number will be zero.
  • stringint_to_ascii (num): convert a string-based integer to a NULL-terminated ASCII string.

Stringfloat management functions

  • display_stringfloat_structure: a diagnostic subroutine meant for debugging purposes only. This subroutine displays the structure of a stringfloat.
  • stringfloat_release_memory: release the memory used to store the string-based floating-point structure.
  • stringfloat_determine_absolute_value_larger_of_two_floats (num1, num2): determine the larger of the absolute value of num1 and num2. Return value: +1 (for num1 > num2); 0 (for num1 == num2); -1 (for num1 < num2).
  • stringfloat_determine_absolute_value_number_greater_than_one (num): determine if the absolute value of num is greater than one. Return value: +1 (for num1 > 1); 0 (for num == 1); -1 (for num1 < 1).

Stringfloat Boolean functions

  • stringfloat_less_than (num1, num2): TRUE if num1 < num2
  • stringfloat_equal (num1, num2): TRUE if num1 == num2.
  • stringfloat_not_equal (num1, num2): TRUE if num1 != num2.
  • stringfloat_greater_than (num1, num2): TRUE if num1 > num2
  • stringfloat_less_than or equal (num1, num2): TRUE if num1 <= num2
  • stringfloat_greater_than_or_equal (num1, num2): TRUE if num1 >= num2

Stringfloat math functions

  • stringfloat_negate (num): result = (-1) * num. Note: stringfloat_negate flips the sign bit on the number. It does not perform a multiply operation. This is for performance reasons on very large string-based floating-point numbers.
  • stringfloat_add (result, num1, num2): result = num1 + num2
  • stringfloat_subract (result, num1, num2): result = num1 - num2
  • stringfloat_multiply (result, num1, num2): result = num1 * num2
  • stringfloat_divide (result, num1, num2): result = num1 / num2.
  • stringfloat_factorial (result, num): computes the factorial of num where num >= 0

Stringfloat miscellaneous functions

  • stringfloat_set_sign (num, sign): set the sign of a string-based floating-point number. Possible value for sign are {positive, negative, zero}.
  • stringfloat_set_value (num, "string"): initialize a string-based floating-point variable to an initial, input value defined by a constant string. Example: stringfloat_set_value (num1, "-12345678901234567890")
  • stringfloat_initialize_to_zero (num): initialize the value of a string-based floating-point variable to zero.
  • stringfloat_copy_number (target, num): make a copy of a string-based floating-point variable into target. Note: target will have its own memory allocation.
  • stringfloat_to_stringint (num): convert a string-based floating-point number to string-based integer. Note: Any fractional part will be truncated in the conversion process
  • stringfloat_to_stringcomplex (num): convert a string-based floating-point number to string-based complex number. Note: the imaginary component of resulting complex number will be zero.
  • stringfloat_to_ascii (num): convert a string-based floating-point number to a NULL-terminated ASCII string.

Chaga input/output library

About the Chaga input/output library

The Chaga input/output library manages input and output for the Chaga compiler. The functions below are internally called within the Chaga compiler. The end-user does not directly call these functions. I documented these functions for developers working on internal infrastructure for the Chaga compiler.

Chaga output library functions

  • stringint_display (num, display_unary_plus): display the contents of the integer variable, num. Setting display_unary_plus to TRUE means positive integers will be preceded by a plus sign. Example: +5.
  • bool_display (num): display the contents of the Boolean variable, num. The output will be either TRUE or FALSE, depending on the value of the Boolean variable.

Copyright © 2025, 2026 Robert James Bruce.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at https://www.gnu.org/licenses/fdl-1.3.html