Chaga Programming Language: Developers

The Chaga programming language developer documentation is licensed under GNU Free Documentation License Logo for GNU Free Documentation License

Project status

  • IN-PROGRESS: string-based floating-point nth root of a string-based floating-point number.
  • Partially completed: implementing selection statements in Chaga compiler.
  • COMPLETED: string-based floating-point function to convert packed string floating point numbers to_scientific notation
  • COMPLETED: string-based floating-point power function for the the Chaga string arithmetic library.
  • COMPLETED: string-based floating-point division for the the Chaga string arithmetic library.
  • COMPLETED: string-based floating-point multiplication for the the Chaga string arithmetic library.
  • COMPLETED: string-based floating-point subtraction for the the Chaga string arithmetic library.
  • COMPLETED: string-based floating-point addition for the the Chaga string arithmetic library.
  • 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.

Developer notes:

Flag status bits must be added to the Chaga numerical string library. Specifically:

  • DIVZ: this flag bit indicates a divide-by-zero occurred.
  • RNT: this flag bit indicates a Repeating, Non-Terminating result occurrred (e.g. 1/3 = 0.3333333.... If the denominator (of a fraction to be computed) is an integer, I will likely have to check if it can be expressed as 2^M * 5^N where M and N are whole numbers. I'd also check that the numerator is non-zero.
  • IMGY: this flag bit would be set if a resultant IMaGinarY number is being stored in an integer or floating-point datatype instead of an imaginary or complex datatype.
  • IIS: this flag bit indicates an Internal InfraStructure error occurred which likely corrupted the resultant number being stored.

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 packed string integer
  • Structure of packed string float
  • Structure of packed string complex
  • Structure of packed string imaginary

Packed string integer management functions

  • display_packed_string_integer_structure: a diagnostic subroutine meant for debugging purposes only. This subroutine displays the structure of a packed string integer.
  • packed_string_integer_release_memory: release the memory used to store the string-based integer structure.
  • packed_string_integer_append_digits: add a digit to a string-based integer.
  • packed_string_integer_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.
  • packed_string_integer_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).
  • packed_string_integer_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).

Packed string integer Boolean functions

  • packed_string_integer_less_than (num1, num2): TRUE if num1 < num2
  • packed_string_integer_equal (num1, num2): TRUE if num1 == num2.
  • packed_string_integer_not_equal (num1, num2): TRUE if num1 != num2.
  • packed_string_integer_greater_than (num1, num2): TRUE if num1 > num2
  • packed_string_integer_less_than or equal (num1, num2): TRUE if num1 <= num2
  • packed_string_integer_greater_than_or_equal (num1, num2): TRUE if num1 >= num2

Packed string integer math functions

  • packed_string_integer_increment_one (num): result = num + 1
  • packed_string_integer_decrement_one (num): result = num - 1
  • packed_string_integer_negate (num): result = (-1) * num. Note: packed_string_integer_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.
  • packed_string_integer_add (result, num1, num2): result = num1 + num2
  • packed_string_integer_subract (result, num1, num2): result = num1 - num2
  • packed_string_integer_multiply (result, num1, num2): result = num1 * num2
  • packed_string_integer_divide (result, num1, num2): result = num1 / num2. Note: Any remainder is truncated.
  • packed_string_integer_modulo (result, num1, num2): result = num1 % num2. Note: Returns the remainder from a division.
  • packed_string_integer_factorial (result, num): computes the factorial of num where num >= 0

Packed string integer miscellaneous functions

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

Stringfloat management functions

  • display_packed_string_float_structure: a diagnostic subroutine meant for debugging purposes only. This subroutine displays the structure of a stringfloat.
  • packed_string_float_release_memory: release the memory used to store the string-based floating-point structure.
  • packed_string_float_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).
  • packed_string_float_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).

Packed string float Boolean functions

  • packed_string_float_less_than (num1, num2): TRUE if num1 < num2
  • packed_string_float_equal (num1, num2): TRUE if num1 == num2.
  • packed_string_float_not_equal (num1, num2): TRUE if num1 != num2.
  • packed_string_float_greater_than (num1, num2): TRUE if num1 > num2
  • packed_string_float_less_than or equal (num1, num2): TRUE if num1 <= num2
  • packed_string_float_greater_than_or_equal (num1, num2): TRUE if num1 >= num2

Packed string float math functions

  • packed_string_float_add (result, num1, num2): result = num1 + num2
  • packed_string_float_divide (result, num1, num2): result = num1 / num2.
  • packed_string_float_factorial (result, num): computes the factorial of num where num >= 0
  • packed_string_float_power (num, unsigned long long int exponent): computes num^exponent
  • packed_string_float_multiply (result, num1, num2): result = num1 * num2
  • packed_string_float_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.
  • packed_string_float_nth_root (result, num, unsigned long long int n): computes the nth root of num given num and and n.
  • packed_string_float_subract (result, num1, num2): result = num1 - num2

Packed string float miscellaneous functions

  • packed_string_float_set_sign (num, sign): set the sign of a string-based floating-point number. Possible value for sign are {positive, negative, zero}.
  • packed_string_float_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")
  • packed_string_float_initialize_to_zero (num): initialize the value of a string-based floating-point variable to zero.
  • packed_string_float_copy_number (target, num): make a copy of a string-based floating-point variable into target. Note: target will have its own memory allocation.
  • packed_string_float_to_packed_string_integer (num): convert a string-based floating-point number to string-based integer. Note: Any fractional part will be truncated in the conversion process
  • packed_string_float_to_packed_string_complex (num): convert a string-based floating-point number to string-based complex number. Note: the imaginary component of resulting complex number will be zero.
  • packed_string_float_to_ascii (num): convert a string-based floating-point number to a NULL-terminated ASCII string.
  • convert_packed_string_float_to_scientific_notation (num): convert a string-based floating-point number into scientific notation.

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

  • packed_string_integer_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