/**************************************************************************************
 * Chaga compiler                                                                     *
 * Copyright (C) 2026 Robert James Bruce                                              *
 *                                                                                    *
 * This file is part of the Chaga compiler.                                           *
 *                                                                                    *
 * The Chaga compiler is free software: you can redistribute it and/or modify it      *
 * under the terms of the GNU General Public License as published by the              *
 * Free Software Foundation, either version 3 of the License, or (at your option) any *
 * later version.                                                                     *
 *                                                                                    *
 * The Chaga compiler is distributed in the hope that it will be useful, but WITHOUT  *
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or              *
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License               *
 * for more details.                                                                  *
 *                                                                                    *
 * You should have received a copy of the GNU General Public License                  *
 * along with the Chaga compiler. If not, see <https://www.gnu.org/licenses/>.        *
 **************************************************************************************/
#include <stddef.h>
#include <string.h>
#include "./include/chaga_compiler-constants.h"
#include "./include/chaga_compiler-data_structures.h"
#include "./include/chaga_compiler-data_structure_management.h"

// *************************************
// * CREATE CONCRETE SYNTAX TREE (CST) *
// *************************************
cst_node * create_concrete_syntax_tree (token_node *token_list)
{
  cst_node *new_cst_element, *new_cst_element2, *last_cst_element, *concrete_syntax_tree, *cst_element, *set_statement_cst_element;
  token_node *current_token, *previous_token;
  statement_stack_node *statement_stack;
  size_t token_string_length;
  char *user_defined_datatype_name, cst_optimization_flags;
  int state, temp_state, num_left_brackets, num_right_brackets;
  long long int set_statement_num_integer_constants_in_expression;
  unsigned long long int num_left_curly_braces, num_right_curly_braces, num_left_parenthesis, num_right_parenthesis;

  set_statement_cst_element = NULL;
  concrete_syntax_tree      = NULL;
  statement_stack           = NULL;
  last_cst_element          = NULL;
  previous_token            = NULL;
  num_left_parenthesis      = 0;
  num_right_parenthesis     = 0;
  num_left_curly_braces     = 0;
  num_right_curly_braces    = 0;
  current_token = token_list;
  state = 0;
  while ((current_token != NULL) && (state < 99999))
  {
    if (current_token->token != NULL)
    {
      //printf ("IN CREATE CONCRETE SYNTAX TREE. state = %d, token = %s, num_left_curly_braces = %d, num_right_curly_braces = %d\n", state, current_token->token, num_left_curly_braces, num_right_curly_braces);
      //printf ("IN CREATE CONCRETE SYNTAX TREE. state = %d, token = %s\n", state, current_token->token);
      switch (state)
      {
        case 0:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            token_string_length = strlen (current_token->token);
            switch (token_string_length)
            {
              case 6:
                if (strncmp(current_token->token, "define", 6) == 0)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    state = 50;        
                    if (last_cst_element != NULL)
                    {
                      last_cst_element->child = new_cst_element;
                      last_cst_element = last_cst_element->child;
                    }
                    else
                    {
                      concrete_syntax_tree = new_cst_element;
                      last_cst_element = concrete_syntax_tree;
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  state = 99999;
                }
              break;               
              case 7:
                if (strncmp(current_token->token, "declare", 7) == 0)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    state = 25;
                    if (last_cst_element != NULL)
                    {
                      last_cst_element->child = new_cst_element;
                      last_cst_element = last_cst_element->child;
                    }
                    else
                    {
                      concrete_syntax_tree = new_cst_element;
                      last_cst_element = concrete_syntax_tree;
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  state = 99999;
                }
              break;
              default:
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              break;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// ***************
// * declare ... *
// ***************
        case 25:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            token_string_length = strlen (current_token->token);
            switch (token_string_length)
            {
              case 3:
                if (strncmp(current_token->token, "int", 3) == 0)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    state = 100;
                    if (last_cst_element != NULL)
                    {
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  printf ("Syntax error on line %llu near \"%s\". Unknown datatype.\n", current_token->line_number, current_token->token);
                  state = 99999;
                }
              break;
              case 4:
                if (strncmp(current_token->token, "bool", 4) == 0)
                {
                  printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                  state = 99999;
                }
                else
                {
                  if (strncmp(current_token->token, "char", 4) == 0)
                  {
                    printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                    state = 99999; 
                  }
                  else
                  {
                    if (strncmp(current_token->token, "date", 4) == 0)
                    {
                      printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                      state = 99999; 
                    }
                    else
                    {
                      if (strncmp(current_token->token, "time", 4) == 0)
                      {
                        printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                        state = 99999; 
                      }
                      else
                      {
                        if (strncmp(current_token->token, "file", 4) == 0)
                        {
                          printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                          state = 99999; 
                        }
                        else
                        {
                          if (strncmp(current_token->token, "void", 4) == 0)
                          {
                            printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                            state = 99999; 
                          }
                          else
                          {
                            if (strncmp(current_token->token, "enum", 4) == 0)
                            {
                              printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                              state = 99999;
                            }
                            else
                            {
                              printf ("Syntax error on line %llu near \"%s\". Unknown datatype.\n", current_token->line_number, current_token->token);
                              state = 99999;
                            }
                          }
                        }
                      }
                    }
                  }
                }
              break;
              case 5:
                if (strncmp(current_token->token, "float", 5) == 0)
                {
                  printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                  state = 99999; 
                }
                else
                {
                  printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                  state = 99999;
                }
              break;
              case 6:
                if (strncmp(current_token->token, "string", 6) == 0)
                {
                  printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                  state = 99999;
                }
                else
                {
                  if (strncmp(current_token->token, "define", 6) == 0)
                  {
                    new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                    if (new_cst_element != NULL)
                    {
                      state = 50;        
                      if (last_cst_element != NULL)
                      {
                        last_cst_element->sibling = new_cst_element;
                        last_cst_element = last_cst_element->sibling;
                      }
                      else
                      {
                        state = 99999; 
                      }
                    }
                    else
                    {
                      state = 99999;
                    }
                  }
                  else
                  {
                    printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                    state = 99999;
                  }
                }
              break;               
              case 7:
                if (strncmp(current_token->token, "pointer", 7) == 0)
                {
                  printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                  state = 99999; 
                }
                else
                {
                  if (strncmp(current_token->token, "complex", 7) == 0)
                  {
                    printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                    state = 99999;
                  }
                  else
                  {
                    printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                    state = 99999;
                  }
                }
              break;
              case 8:
                if (strncmp(current_token->token, "datetime", 8) == 0)
                {
                  printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                  state = 99999; 
                }
                else
                {
                  printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                  state = 99999;
                }
              break;
              case 9:
                if (strncmp(current_token->token, "imaginary", 9) == 0)
                {
                  printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                  state = 99999; 
		}
                else
                {
                  if (strncmp(current_token->token, "attribute", 9) == 0)
                  {
                    printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                    state = 99999; 
	          }
                  else
                  {
                    printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                    state = 99999;
                  }
                }
              break;
              default:
                printf ("Syntax error on line %llu near \"%s\". Unknown datatype.\n", current_token->line_number, current_token->token);
                state = 99999;
              break;
            }
          }
        break;
// **************
// * define ... *
// **************
        case 50:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            token_string_length = strlen (current_token->token);
            switch (token_string_length)
            {
              case 4:
                if (strncmp(current_token->token, "type", 4) == 0)
                {
                  printf ("The type command on line %llu is not yet implemented in the Chaga compiler.\n", current_token->line_number);
                  state = 99999; 
                }
                else
                {
                  printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                  state = 99999;
                }
              break;
              case 8:
                if (strncmp(current_token->token, "function", 8) == 0)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    num_left_parenthesis = 0;
                    num_right_parenthesis = 0;
                    num_left_curly_braces = 0;
                    num_right_curly_braces = 0;
                    state = 2000;
                    if (last_cst_element != NULL)
                    {
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                  state = 99999;
                }
              break;   
              case 9:
                if (strncmp(current_token->token, "procedure", 9) == 0)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    num_left_parenthesis = 0;
                    num_right_parenthesis = 0;
                    num_left_curly_braces = 0;
                    num_right_curly_braces = 0;
                    state = 3000;
                    if (last_cst_element != NULL)
                    {
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                  state = 99999;
                }
              default:
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              break;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// ******************
// * <DATATYPE> ... *
// ******************
        case 100:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            num_left_brackets = 0;
            num_right_brackets = 0;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 150;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          } 
        break;
// *******************************
// * <DATATYPE> <IDENTIFIER> ... *
// *******************************
        case 150:
          if (current_token->token_type == TOKEN_LEFT_BRACKET)
          {
            num_left_brackets++;
            num_left_parenthesis = 0;
            num_right_parenthesis = 0;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 200;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_COMMA)
            {
              if ((num_left_brackets == num_right_brackets) && (num_left_parenthesis == num_right_parenthesis))
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  state = 100;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_SEMICOLON)
              {
                if ((num_left_brackets == num_right_brackets) && (num_left_parenthesis == num_right_parenthesis))
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    state = 0;
                    if (last_cst_element != NULL)
                    {
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
        break;
// **********************************************
// * <DATATYPE> <IDENTIFIER> <LEFT_BRACKET> ... *
// **********************************************
        case 200:
          if (current_token->token_type == TOKEN_IDENTIFIER_INTEGER_CONSTANT)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 250;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
            {
              num_left_parenthesis++;
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                state = 200;
                if (last_cst_element != NULL)
                {
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// ********************************************************
// * <DATATYPE> <IDENTIFIER> <LEFT_BRACKET> <INTEGER> ... *
// ********************************************************
        case 250:
          if ((current_token->token_type == TOKEN_PLUS)     || 
              (current_token->token_type == TOKEN_MINUS)    ||
              (current_token->token_type == TOKEN_ASTERISK) ||
              (current_token->token_type == TOKEN_DIVIDE)   ||
              (current_token->token_type == TOKEN_CARET)    ||
              (current_token->token_type == TOKEN_MODULO))
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 300;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }   
          else
          {
            if (current_token->token_type == TOKEN_RIGHT_BRACKET)
            {
              num_right_brackets++;
              if ((num_left_brackets == num_right_brackets) && (num_left_parenthesis == num_right_parenthesis))
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  state = 350;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
              {
                if (num_left_parenthesis >= num_right_parenthesis)
                {  
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    state = 250;
                    if (last_cst_element != NULL)
                    {
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else 
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
        break;
// ************************************************************************
// * <DATATYPE> <IDENTIFIER> <LEFT_BRACKET> <INTEGER> <MATH_OPERATOR> ... *
// ************************************************************************
        case 300:
          if (current_token->token_type == TOKEN_IDENTIFIER_INTEGER_CONSTANT)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 250;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
            {
              num_left_parenthesis++;
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                state = 300;
                if (last_cst_element != NULL)
                {
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// ************************************************************************
// * <DATATYPE> <IDENTIFIER> <LEFT_BRACKET> <INTEGER> <RIGHT_BRACKET> ... *
// ************************************************************************
        case 350:
          if (current_token->token_type == TOKEN_LEFT_BRACKET)
          {
            num_left_brackets++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 200;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_SEMICOLON)
            {
              if ((num_left_brackets == num_right_brackets) && (num_left_parenthesis == num_right_parenthesis))
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  state = 0;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_COMMA)
              {
                if ((num_left_brackets == num_right_brackets) && (num_left_parenthesis == num_right_parenthesis))
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    state = 0;
                    if (last_cst_element != NULL)
                    {
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
        break;
// *******************
// * define type ... *
// *******************
        case 1000:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 1050;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// ********************************
// * define type <IDENTIFIER> ... *
// ********************************
        case 1050:
          if (current_token->token_type == TOKEN_LEFT_CURLY_BRACE)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 1100;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// **********************************
// * define type <IDENTIFIER> { ... *
// **********************************
        case 1100:
          if (current_token->token_type == TOKEN_RIGHT_CURLY_BRACE)
          {
            num_right_curly_braces++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (num_left_curly_braces == num_right_curly_braces)
              {
                state = 0;           
                if (last_cst_element != NULL)
                {
                  last_cst_element->child = new_cst_element;
                  last_cst_element = last_cst_element->child;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                if (num_left_curly_braces > num_right_curly_braces)
                {
                  state = 1100;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->child = new_cst_element;
                    last_cst_element = last_cst_element->child;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }  
              }
            }
            else
            {
              state = 99999;
            }
          }         
          else
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 1100;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
        break;
// ***********************
// * define function ... *
// ***********************
        case 2000:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 2050;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// ************************************
// * define function <IDENTIFIER> ... *
// ************************************
        case 2050:
          if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
          {
            num_left_parenthesis++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 2100;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// **************************************
// * define function <IDENTIFIER> ( ... *
// **************************************
        case 2100:
          if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
          {
            num_left_parenthesis++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 2100;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
            {
              num_right_parenthesis++;
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (num_left_parenthesis == num_right_parenthesis)
                {
                  state = 2150;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  if (num_left_parenthesis > num_right_parenthesis)
                  {
                    state = 2100;
                    if (last_cst_element != NULL)
                    {
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
//FIXME
              if (current_token->token_type == TOKEN_IDENTIFIER)
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  state = 2110;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
        break;
// ***************************************************
// * define function <IDENTIFIER> ( <IDENTIFIER> ... *
// ***************************************************
        case 2110:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 2120;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// ****************************************************************
// * define function <IDENTIFIER> ( <IDENTIFIER> <IDENTIFIER> ... *
// ****************************************************************
        case 2120:
          if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
          {
            num_right_parenthesis++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (num_left_parenthesis == num_right_parenthesis)
              {
                state = 2150;
                if (last_cst_element != NULL)
                {
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                if (num_left_parenthesis > num_right_parenthesis)
                {
                  state = 2120;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_COMMA)
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                state = 2130;
                if (last_cst_element != NULL)
                {
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// ******************************************************************
// * define function <IDENTIFIER> ( <IDENTIFIER> <IDENTIFIER> , ... *
// ******************************************************************
        case 2130:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 2110;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// *****************************************************
// * define function <IDENTIFIER> ( <EXPRESSION> ) ... *
// *****************************************************
        case 2150:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            token_string_length = strlen (current_token->token);
            if (token_string_length == 6)
            {
              if (strncmp(current_token->token, "return", 6) == 0)
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  num_left_parenthesis = 0;
                  num_right_parenthesis = 0;
                  state = 2200;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                } 
                else
                {
                  state = 99999;
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// ************************************************************
// * define function <IDENTIFIER> ( <EXPRESSION> ) return ... *
// ************************************************************
        case 2200:
          if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
          {
            num_left_parenthesis++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 2250;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// **************************************************************
// * define function <IDENTIFIER> ( <EXPRESSION> ) return ( ... *
// **************************************************************
        case 2250:
          if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
          {
            num_left_parenthesis++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 2250;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
            {
              num_right_parenthesis++;
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (num_left_parenthesis == num_right_parenthesis)
                {
                  state = 2300;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  if (num_left_parenthesis > num_right_parenthesis)
                  {
                    state = 2250;
                    if (last_cst_element != NULL)
                    {
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_IDENTIFIER)
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  state = 2260;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
        break;
// ***************************************************************************
// * define function <IDENTIFIER> ( <EXPRESSION> ) return ( <IDENTIFIER> ... *
// ***************************************************************************
        case 2260:
          if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
          {
            num_left_parenthesis++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 2260;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
            {
              num_right_parenthesis++;
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (num_left_parenthesis == num_right_parenthesis)
                {
                  state = 2300;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  if (num_left_parenthesis > num_right_parenthesis)
                  {
                    state = 2260;
                    if (last_cst_element != NULL)
                    {
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_COMMA)
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  state = 2250;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
        break;
// *****************************************************************************
// * define function <IDENTIFIER> ( <EXPRESSION> ) return ( <EXPRESSION> ) ... *
// *****************************************************************************
        case 2300:
          if (current_token->token_type == TOKEN_LEFT_CURLY_BRACE)
          {
            statement_stack = push_statement_stack (statement_stack, _define, num_left_curly_braces - num_right_curly_braces);
            num_left_curly_braces++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 4000;
              if (last_cst_element != NULL)
              {
                last_cst_element->child = new_cst_element;
                last_cst_element = last_cst_element->child;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// ************************
// * define procedure ... *
// ************************
        case 3000:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 3050;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// *************************************
// * define procedure <IDENTIFIER> ... *
// *************************************
        case 3050:
          if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
          {
            num_left_parenthesis++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 3100;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// ***************************************
// * define procedure <IDENTIFIER> ( ... *
// ***************************************
        case 3100:
          if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
          {
            num_left_parenthesis++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 3100;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
            {
              num_right_parenthesis++;
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (num_left_parenthesis == num_right_parenthesis)
                {
                  state = 3150;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  if (num_left_parenthesis > num_right_parenthesis)
                  {
                    state = 3100;
                    if (last_cst_element != NULL)
                    {
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                state = 3100;
                if (last_cst_element != NULL)
                {
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
          }
        break;
// ******************************************************
// * define procedure <IDENTIFIER> ( <EXPRESSION> ) ... *
// ******************************************************
        case 3150:
          if (current_token->token_type == TOKEN_LEFT_CURLY_BRACE)
          {
            statement_stack = push_statement_stack (statement_stack, _define, num_left_curly_braces);
            num_left_curly_braces++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 4000;
              if (last_cst_element != NULL)
              {
                last_cst_element->child = new_cst_element;
                last_cst_element = last_cst_element->child;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// *******************************************************************************
// * We are now inside a statement block for a function or procedure definition. *
// *******************************************************************************
        case 4000:
          cst_optimization_flags = 0; // initialize all optimization flags to FALSE for the current statement.
          if (current_token->token_type == TOKEN_RIGHT_CURLY_BRACE)
          {
            num_right_curly_braces++;
            if (statement_stack != NULL)
            {
              if (statement_stack->left_curly_brace_count_before_this_statement == (num_left_curly_braces - num_right_curly_braces))
              {
                statement_stack = pop_statement_stack (statement_stack);
              }
            }
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (num_left_curly_braces == num_right_curly_braces)
              {
                state = 0;
                if (last_cst_element != NULL)
                {
                  last_cst_element->child = new_cst_element;
                  last_cst_element = last_cst_element->child;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                if (num_left_curly_braces > num_right_curly_braces)
                {
                  state = 4000;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->child = new_cst_element;
                    last_cst_element = last_cst_element->child;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_IDENTIFIER)
            {
              token_string_length = strlen (current_token->token);
              switch (token_string_length)
              {
                case 2:
                  if (strncmp(current_token->token, "do", 2) == 0)
                  {
                    printf ("The \"do\" statement on line %llu is not yet implemented in the Chaga compiler.\n", current_token->line_number);
                    state = 99999;
                  }
                  else
                  {
                    if (strncmp(current_token->token, "if", 2) == 0)
                    {
                      new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                      if (new_cst_element != NULL)
                      {
                        state = 7000;
                        if (last_cst_element != NULL)
                        {
                          last_cst_element->child = new_cst_element;
                          last_cst_element = last_cst_element->child;
                        }
                        else
                        {
                          state = 99999; 
                        }
                      }
                      else
                      {
                        state = 99999;
                      }
                    }
                    else
                    {
                      printf ("Syntax error on line %llu near \"%s\".\n", current_token->line_number, current_token->token);
                      state = 99999;
                    }
                  }
                break;
                case 3:
                  if (strncmp(current_token->token, "for", 3) == 0)
                  {
                    printf ("The \"for\" statement on line %llu is not yet implemented in the Chaga compiler.\n", current_token->line_number);
                    state = 99999;
                  }
                  else
                  {
                    if (strncmp(current_token->token, "set", 3) == 0)
                    {
                      new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                      if (new_cst_element != NULL)
                      {
                        set_statement_cst_element = new_cst_element; // save a copy of this point in the CST tree since I will need to insert compilation flags in this element when the statement reaches the semicolon token.
                        state = 6000;
                        if (last_cst_element != NULL)
                        {
                          last_cst_element->child = new_cst_element;
                          last_cst_element = last_cst_element->child;
                        }
                        else
                        {
                          state = 99999; 
                        }
                      }
                      else
                      {
                        state = 99999;
                      }
                    }
                    else
                    {
                      printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                      state = 99999;
                    }
                  }
                break;
                case 4:
                  if (strncmp(current_token->token, "call", 4) == 0)
                  {
                    printf ("The \"call\" statement on line %llu is not yet implemented in the Chaga compiler.\n", current_token->line_number);
                    state = 99999; 
                  }
                  else
                  {
                    if (strncmp(current_token->token, "case", 4) == 0)
                    {
                      printf ("The \"case\" statement on line %llu is not yet implemented in the Chaga compiler.\n", current_token->line_number);
                      state = 99999; 
                    }
                    else
                    {
                      if (strncmp(current_token->token, "else", 4) == 0)
                      {
                        new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                        if (new_cst_element != NULL)
                        {
                          state = 8000;
                          if (last_cst_element != NULL)
                          {
                            last_cst_element->child = new_cst_element;
                            last_cst_element = last_cst_element->child;
                          }
                          else
                          {
                            state = 99999; 
                          }
                        }
                        else
                        {
                          state = 99999;
                        }
                      }
                      else
                      {
                        if (strncmp(current_token->token, "read", 4) == 0)
                        {
                          printf ("The \"read\" statement on line %llu is not yet implemented in the Chaga compiler.\n", current_token->line_number);
                          state = 99999; 
                        }
                        else
                        {
                          printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                          state = 99999;
                        }
                      }
                    }
                  }
                break;
                case 5:
                  if (strncmp(current_token->token, "break", 5) == 0)
                  {
                    printf ("The \"break\" statement on line %llu is not yet implemented in the Chaga compiler.\n", current_token->line_number);
                    state = 99999; 
                  }
                  else
                  {
                    if (strncmp(current_token->token, "print", 5) == 0)
                    {
                      new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                      if (new_cst_element != NULL)
                      {
                        state = 5000;
                        if (last_cst_element != NULL)
                        {
                          last_cst_element->child = new_cst_element;
                          last_cst_element = last_cst_element->child;
                        }
                        else
                        {
                          state = 99999; 
                        }
                      }
                    }
                    else
                    {
                      if (strncmp(current_token->token, "until", 5) == 0)
                      {
                        printf ("The \"until\" statement on line %llu is not yet implemented in the Chaga compiler.\n", current_token->line_number);
                        state = 99999; 
                      }
                      else
                      {
                        if (strncmp(current_token->token, "while", 5) == 0)
                        {
                          printf ("The \"while\" statement on line %llu is not yet implemented in the Chaga compiler.\n", current_token->line_number);
                          state = 99999; 
                        }
                        else
                        {
                          printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                          state = 99999;
                        }
                      }
                    }
                  }
                break;
                case 6:
                  if (strncmp(current_token->token, "print", 6) == 0)
                  {
                    new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                    if (new_cst_element != NULL)
                    {
                      state = 5000;
                      if (last_cst_element != NULL)
                      {
                        last_cst_element->child = new_cst_element;
                        last_cst_element = last_cst_element->child;
                      }
                      else
                      {
                        state = 99999; 
                      }
                    }
                    else
                    {
                      state = 99999;
                    }
                  }
                  else
                  {
                    if (strncmp(current_token->token, "return", 6) == 0)
                    {
                      printf ("The \"return\" statement on line %llu is not yet implemented in the Chaga compiler.\n", current_token->line_number);
                      state = 99999; 
                    }
                    else
                    {
                      if (strncmp(current_token->token, "switch", 6) == 0)
                      {
                        printf ("The \"switch\" statement on line %llu is not yet implemented in the Chaga compiler.\n", current_token->line_number);
                        state = 99999; 
                      }
                      else
                      {
                        printf ("Syntax error on line %llu near \"%s\". Unknown statement.\n", current_token->line_number, current_token->token);
                        state = 99999;
                      }
                    }
                  }
                break;
                case 7:
                  if (strncmp(current_token->token, "declare", 7) == 0)
                  {
                    new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                    if (new_cst_element != NULL)
                    {
                      state = 20000;
                      if (last_cst_element != NULL)
                      {
                        last_cst_element->child = new_cst_element;
                        last_cst_element = last_cst_element->child;
                      }
                      else
                      {
                        state = 99999; 
                      }
                    }
                  }
                  else
                  {
                    if (strncmp(current_token->token, "getchar", 7) == 0)
                    {
                      printf ("The \"getchar\" statement on line %llu is not yet implemented in the Chaga compiler.\n", current_token->line_number);
                      state = 99999; 
                    }
                    else
                    {
                      if (strncmp(current_token->token, "putchar", 7) == 0)
                      {
                        printf ("The \"putchar\" statement on line %llu is not yet implemented in the Chaga compiler.\n", current_token->line_number);
                        state = 99999; 
                      }
                      else
                      {
                        printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                        state = 99999;
                      }
                    }
                  }
                break;
                default:
                  printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                  state = 99999;
                break;
              }
            }
            else
            {
              printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// *************
// * print ... *
// *************
        case 5000:
          if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 5050;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (previous_token != NULL)
            {  
              if (previous_token->token != NULL)
              {  
                printf ("Syntax error on line %llu near \"%s\". Expected a left parenthesis after \"%s\". \n", current_token->line_number, current_token->token, previous_token->token);
              }
            }
            state = 99999;
          }
        break;
// ***************
// * print ( ... *
// ***************
        case 5050:
          if (current_token->token_type == TOKEN_DOUBLE_QUOTE)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 5100;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_SINGLE_QUOTE)
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                state = 5300;
                if (last_cst_element != NULL)
                {
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_IDENTIFIER)
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  state = 5060;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
        break;
// ****************************
// * print ( <IDENTIFIER> ... *
// ****************************
        case 5060:
          if (current_token->token_type == TOKEN_COMMA)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 5050;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// *****************
// * print ( " ... *
// *****************
        case 5100:
          if (current_token->token_type == TOKEN_STRING)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 5150;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// **************************
// * print ( " <STRING> ... *
// **************************
        case 5150:
          if (current_token->token_type == TOKEN_DOUBLE_QUOTE)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 5200;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// ****************************
// * print ( " <STRING> " ... *
// ****************************
        case 5200:
          if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 5250;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_COMMA)
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                state = 5460;
                if (last_cst_element != NULL)
                {
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
            }
            else
            {
              printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// ******************************
// * print ( " <STRING> " ) ... *
// ******************************
        case 5250:
          if (current_token->token_type == TOKEN_SEMICOLON)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 4000;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (previous_token != NULL)
            {
              if (previous_token->token != NULL)
              {
                printf ("Syntax error on line %llu near \"%s\". Expected a left semicolon after \"%s\".\n", previous_token->line_number, previous_token->token, previous_token->token);
              }
            }
            state = 99999;
          }
        break;
// *****************
// * print ( ' ... *
// *****************
        case 5300:
          if (current_token->token_type == TOKEN_STRING)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 5350;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_SINGLE_QUOTE)
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                state = 5400;
                if (last_cst_element != NULL)
                {
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// **************************
// * print ( ' <STRING> ... *
// **************************
        case 5350:
          if (current_token->token_type == TOKEN_SINGLE_QUOTE)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 5400;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// ****************************
// * print ( ' <STRING> ' ... *
// ****************************
        case 5400:
          if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 5450;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_COMMA)
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                state = 5460;
                if (last_cst_element != NULL)
                {
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// ******************************
// * print ( ' <STRING> ' ) ... *
// ******************************
        case 5450:
          if (current_token->token_type == TOKEN_SEMICOLON)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 4000;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// ******************************
// * print ( " <STRING> " , ... *
// ******************************
        case 5460:
          if (current_token->token_type == TOKEN_SINGLE_QUOTE)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 5300;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_DOUBLE_QUOTE)
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                state = 5100;
                if (last_cst_element != NULL)
                {
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_IDENTIFIER)
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  state = 5470;
                  if (last_cst_element != NULL)
                  {
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
        break;
// *******************************************
// * print ( " <STRING> " , <IDENTIFIER> ... *
// *******************************************
        case 5470:
          if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 5250;
              if (last_cst_element != NULL)
              {
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_COMMA)
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                state = 5460;
                if (last_cst_element != NULL)
                {
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
            }
            else
            {
              printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// ***********
// * set ... *
// ***********
        case 6000:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 6050;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// ************************
// * set <IDENTIFIER> ... *
// ************************
        case 6050:
          if (current_token->token_type == TOKEN_ASSIGNMENT)
          {
            cst_optimization_flags = 1; // Assume the numerical expression in the SET statement contains ONLY integer constants.
            set_statement_num_integer_constants_in_expression = 0; // count the number of integer constants in the SET statement
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 6100;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_PERIOD)
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
                  state = 6000;
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// *************************************
// * set <IDENTIFIER> <ASSIGNMENT> ... *
// *************************************
        case 6100:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
// *************************************************************************************************************
// * Set bit 0 of the Concrete Syntax Tree optimization flags to zero (FALSE) since the SET statement contains *
// * an IDENTIFIER. Recall that bit 0 flag determines if an entire expression is comprised of ONLY integer     *
// * constants. In such cases, I can evaluate the expression at compile time.                                  *
// *                                                                                                           *
// * Example:                                                                                                  *
// * set foo = 111 * 222 + 333;                                                                                *
// *                                                                                                           *
// * In the above example, the compiler will revise the above in the Abstract Syntax Tree to:                  *
// * set foo = 24975;                                                                                          *
// *************************************************************************************************************
            cst_optimization_flags = 0; 
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 6105;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
            {
              num_left_parenthesis++;
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
                  state = 6100;
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
              {
                num_right_parenthesis++;
                if (num_left_parenthesis >= num_right_parenthesis)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      state = 6100;
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  printf ("Syntax error on line %llu: unbalanced parenthesis\n", current_token->line_number);
                  state = 99999;
                }
              }
              else
              {
                if (current_token->token_type == TOKEN_IDENTIFIER_INTEGER_CONSTANT)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      set_statement_num_integer_constants_in_expression++;
                      state = 6105;
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  if (current_token->token_type == TOKEN_IDENTIFIER_FLOATING_POINT_CONSTANT)
                  {
                    new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                    if (new_cst_element != NULL)
                    {
                      if (last_cst_element != NULL)
                      {
                        state = 6600;
                        last_cst_element->sibling = new_cst_element;
                        last_cst_element = last_cst_element->sibling;
                      }
                      else
                      { 
                        state = 99999;
                      }
                    }
                    else
                    { 
                      state = 99999;
                    }
                  }
                  else
                  {
                    if ((current_token->token_type == TOKEN_TRUE) || (current_token->token_type == TOKEN_FALSE))
                    {
                      new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                      if (new_cst_element != NULL)
                      {
                        if (last_cst_element != NULL)
                        {
                          set_statement_num_integer_constants_in_expression++;
                          state = 6105;
                          last_cst_element->sibling = new_cst_element;
                          last_cst_element = last_cst_element->sibling;
                        }
                        else
                        {
                          state = 99999; 
                        }
                      }
                      else
                      {
                        state = 99999;
                      }
                    }
                    else
                    {
                      if (current_token->token_type == TOKEN_MINUS)
                      {
// *********************************************************************************************************************************************
// * NOTE: Since the current token is a minus, the minus sign is serving as a unary operator. To process this correctly, I inject a "0" (zero) *
// * token before the unary minus operator in the concrete syntax tree. This makes it much easier to convert from infix notation to postfix    *
// * notation later in the pipeline (when creating the abstract syntax tree. I need to have two operands and one operator. The zero is a       *
// * placeholder for one operand.                                                                                                              *
// *********************************************************************************************************************************************
                        new_cst_element = add_element_to_concrete_syntax_tree (current_token, "0", TOKEN_IDENTIFIER_INTEGER_CONSTANT);
                        if (new_cst_element != NULL)
                        {
                          new_cst_element2 = new_cst_element->sibling;
                          if (new_cst_element2 != NULL)
                          {
                            if (last_cst_element != NULL)
                            {
                              set_statement_num_integer_constants_in_expression++;
                              state = 6102;
                              last_cst_element->sibling = new_cst_element;
                              last_cst_element = last_cst_element->sibling;
                              if (last_cst_element != NULL)
                              {
                                last_cst_element = last_cst_element->sibling; // must advance two tokens because I inserted two tokens in Concrete Syntax Tree when calling last add_element_to_concrete_syntax_tree() above.
                              }
                              else
                              {
                                state = 99999; 
                              }
                            }
                            else
                            {
                              state = 99999; 
                            }
                          }
                          else
                          {
                            state = 99999;
                          }
                        }
                        else
                        {
                          state = 99999;
                        }
                      }
                      else
                      {
                        if (current_token->token_type == TOKEN_UNARY_NOT)
                        {
                          new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                          if (new_cst_element != NULL)
                          {
                            if (last_cst_element != NULL)
                            {
                              set_statement_num_integer_constants_in_expression++;
                              state = 6103;
                              last_cst_element->sibling = new_cst_element;
                              last_cst_element = last_cst_element->sibling;
                            }
                            else
                            {
                              state = 99999; 
                            }
                          }
                          else
                          {
                            state = 99999;
                          }
                        }
                        else
                        {
                          printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                          state = 99999;
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        break;
// *******************
// * <PLUS SIGN> ... *
// *******************
        case 6101:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
// *************************************************************************************************************
// * Set bit 0 of the Concrete Syntax Tree optimization flags to zero (FALSE) since the SET statement contains *
// * an IDENTIFIER.                                                                                            *
// *************************************************************************************************************
                cst_optimization_flags = 0;
                state = 6105;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }  
        break;
// ********************
// * <MINUS SIGN> ... *
// ********************
        case 6102:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
// *************************************************************************************************************
// * Set bit 0 of the Concrete Syntax Tree optimization flags to zero (FALSE) since the SET statement contains *
// * an IDENTIFIER.                                                                                            *
// *************************************************************************************************************
                cst_optimization_flags = 0;
                state = 6105;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_IDENTIFIER_INTEGER_CONSTANT)
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
                  set_statement_num_integer_constants_in_expression++;
                  state = 6105;
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// **************************
// * <EXCLAMATION MARK> ... *
// **************************
        case 6103:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
// *************************************************************************************************************
// * Set bit 0 of the Concrete Syntax Tree optimization flags to zero (FALSE) since the SET statement contains *
// * an IDENTIFIER.                                                                                            *
// *************************************************************************************************************
                cst_optimization_flags = 0;
                state = 6105;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if ((current_token->token_type == TOKEN_TRUE) || (current_token->token_type == TOKEN_FALSE))
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
                  set_statement_num_integer_constants_in_expression++;
                  state = 6105;
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
              {
                num_left_parenthesis++;
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  if (last_cst_element != NULL)
                  {
                    state = 6100;
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
        break;
// ****************
// * <IDENTIFIER> *
// ****************
        case 6105:
          if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
          {
            num_left_parenthesis++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 6110;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
            {
              num_right_parenthesis++;
              if (num_left_parenthesis >= num_right_parenthesis)
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  if (last_cst_element != NULL)
                  {
                    state = 6105;
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if ((current_token->token_type == TOKEN_PLUS)                  || 
                  (current_token->token_type == TOKEN_MINUS)                 ||
                  (current_token->token_type == TOKEN_ASTERISK)              ||
                  (current_token->token_type == TOKEN_DIVIDE)                ||
                  (current_token->token_type == TOKEN_CARET)                 ||
                  (current_token->token_type == TOKEN_MODULO)                ||
                  (current_token->token_type == TOKEN_AND)                   ||
                  (current_token->token_type == TOKEN_OR)                    ||
                  (current_token->token_type == TOKEN_LESS_THAN)             ||
                  (current_token->token_type == TOKEN_GREATER_THAN)          ||
                  (current_token->token_type == TOKEN_EQUAL)                 ||
                  (current_token->token_type == TOKEN_NOT_EQUAL)             ||
                  (current_token->token_type == TOKEN_LESS_THAN_OR_EQUAL)    ||
                  (current_token->token_type == TOKEN_GREATER_THAN_OR_EQUAL))
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  if (last_cst_element != NULL)
                  {
                    state = 6100; 
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                if (current_token->token_type == TOKEN_SEMICOLON)
                {
                  if (num_left_parenthesis == num_right_parenthesis)
                  {
                    if (num_left_brackets == num_right_brackets)
                    {
                      new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                      if (new_cst_element != NULL)
                      {
                        if (last_cst_element != NULL)
                        {

                          if (set_statement_num_integer_constants_in_expression >= 2)
                          {
                            if (set_statement_cst_element != NULL)
                            {
                              set_statement_cst_element->cst_optimization_flags = cst_optimization_flags;
                            }
                          }
                          state = 4000;
                          last_cst_element->sibling = new_cst_element;
                          last_cst_element = last_cst_element->sibling;
                        }
                        else
                        {
                          state = 99999; 
                        }
                      }
                      else
                      {
                        state = 99999;
                      }
                    }
                    else
                    {
                      state = 99999;
                    }
                  }
                  else
                  {
                    printf ("Syntax error on line %llu: unbalanced parenthesis\n", current_token->line_number);
                    state = 99999;
                  }
                }
                else
                {
                  if (current_token->token_type == TOKEN_LEFT_BRACKET)
                  {
                    num_left_brackets++;
                    new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                    if (new_cst_element != NULL)
                    {
                      if (last_cst_element != NULL)
                      {
                        state = 6130;
                        last_cst_element->sibling = new_cst_element;
                        last_cst_element = last_cst_element->sibling;
                      }
                      else
                      {
                        state = 99999; 
                      }
                    }
                    else
                    {
                      state = 99999;
                    }                 
                  }
                  else
                  {
                    if (current_token->token_type == TOKEN_RIGHT_BRACKET)
                    {
                      num_right_brackets++;
                      if (num_left_brackets >= num_right_brackets)
                      {
                        new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                        if (new_cst_element != NULL)
                        {
                          if (last_cst_element != NULL)
                          {
                            state = 6130;
                            last_cst_element->sibling = new_cst_element;
                            last_cst_element = last_cst_element->sibling;
                          }
                          else
                          {
                            state = 99999; 
                          }
                        }
                      }
                      else
                      {
                        state = 99999;
                      }
                    }
                    else
                    {
                      if (previous_token != NULL)
                      {
                        if (previous_token->token != NULL)
                        {
                          printf ("Syntax error on line %llu near \"%s\".\n", previous_token->line_number, previous_token->token);
                        }
                      }
                      state = 99999;
                    }
                  }
                }
              }
            }
          }
        break;
// ***********************************
// * <IDENTIFIER> <LEFT_PARENTHESIS> *
// ***********************************
        case 6110:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 6120;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_IDENTIFIER_INTEGER_CONSTANT)
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                state = 99999;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                if (last_cst_element != NULL)
                {
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// ************************************************
// * <IDENTIFIER> <LEFT_PARENTHESIS> <IDENTIFIER> *
// ************************************************
        case 6120:
          if (current_token->token_type == TOKEN_LEFT_BRACKET)
          {
            num_left_brackets++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 6130;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if ((current_token->token_type == TOKEN_PLUS)     || 
                (current_token->token_type == TOKEN_MINUS)    ||
                (current_token->token_type == TOKEN_ASTERISK) ||
                (current_token->token_type == TOKEN_DIVIDE)   ||
                (current_token->token_type == TOKEN_CARET)    ||
                (current_token->token_type == TOKEN_MODULO))
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
                  state = 6130;
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }            
            }
            else
            {
              if (current_token->token_type == TOKEN_COMMA)
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  if (last_cst_element != NULL)
                  {
                    state = 6110;
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }            
              }
              else
              {
                if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
                {
                  num_right_parenthesis++;
                  if (num_left_parenthesis >= num_right_parenthesis)
                  {
                    new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                    if (new_cst_element != NULL)
                    {
                      if (last_cst_element != NULL)
                      {
                        state = 6120;
                        last_cst_element->sibling = new_cst_element;
                        last_cst_element = last_cst_element->sibling;
                      }
                      else
                      {
                        state = 99999; 
                      }
                    }
                    else
                    {
                      state = 99999;
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  if (current_token->token_type == TOKEN_SEMICOLON)
                  {
                    if (num_left_parenthesis == num_right_parenthesis)
                    {
                      if (num_left_brackets == num_right_brackets)
                      {
                        new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                        if (new_cst_element != NULL)
                        {
                          if (last_cst_element != NULL)
                          {
                            state = 4000;
                            last_cst_element->sibling = new_cst_element;
                            last_cst_element = last_cst_element->sibling;
                          }
                          else
                          {
                            state = 99999; 
                          }
                        }
                        else
                        {
                          state = 99999;
                        }
                      }
                      else
                      {
                        state = 99999;
                      }
                    }
                    else
                    {
                      state = 99999;
                    }
                  }
                  else
                  {
                    if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
                    {
                      num_left_parenthesis++;
                      new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                      if (new_cst_element != NULL)
                      {
                        if (last_cst_element != NULL)
                        {
                          state = 6110;
                          last_cst_element->sibling = new_cst_element;
                          last_cst_element = last_cst_element->sibling;
                        }
                        else
                        {
                          state = 99999; 
                        }
                      }
                      else
                      {
                        state = 99999;
                      } 
                    }
                    else
                    {
                      if (current_token->token_type == TOKEN_RIGHT_BRACKET)
                      {
                        num_right_brackets++;
                        if (num_left_brackets >= num_right_brackets)
                        {
                          new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                          if (new_cst_element != NULL)
                          {
                            if (last_cst_element != NULL)
                            {
                              state = 6120;
                              last_cst_element->sibling = new_cst_element;
                              last_cst_element = last_cst_element->sibling;
                            }
                            else
                            {
                              state = 99999; 
                            }
                          }
                          else
                          {
                            state = 99999;
                          }
                        }
                        else
                        {
                          state = 99999;
                        }
                      }
                      else
                      {
                        printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                        state = 99999;
                      }
                    }
                  }
                }
              }
            }
          }
        break;
// ************************
// ************************
// ************************
        case 6130:
          if (current_token->token_type == TOKEN_IDENTIFIER_INTEGER_CONSTANT)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 6140;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_IDENTIFIER)
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
                  state = 6120;
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
              {
                num_left_parenthesis++;
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  if (last_cst_element != NULL)
                  {
                    state = 6130;
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                if (current_token->token_type == TOKEN_LEFT_BRACKET)
                {
                  num_left_brackets++;
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      state = 6130;
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                  state = 99999;
                }
              }
            }
          }
        break;
// ************************
// ************************
// ************************
        case 6140:
          if (current_token->token_type == TOKEN_RIGHT_BRACKET)
          {
            num_right_brackets++;
            if (num_left_brackets > num_right_brackets)
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
                  state = 6140;
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (num_left_brackets == num_right_brackets)
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  if (last_cst_element != NULL)
                  {
                    state = 6140;
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_LEFT_BRACKET)
            {
              num_left_brackets++;
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
                  state = 6150;
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
              {
                num_right_parenthesis++;
                if (num_left_parenthesis > num_right_parenthesis)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      state = 6140;
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  if (num_left_parenthesis == num_right_parenthesis)
                  {
                    new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                    if (new_cst_element != NULL)
                    {
                      if (last_cst_element != NULL)
                      {
                        state = 6500;
                        last_cst_element->sibling = new_cst_element;
                        last_cst_element = last_cst_element->sibling;
                      }
                      else
                      {
                        state = 99999; 
                      }
                    }
                    else
                    {
                      state = 99999;
                    }
                  }
                  else
                  {
                    printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                    state = 99999;
                  }
                }
              }
              else
              {             
                if ((current_token->token_type == TOKEN_PLUS)     || 
                    (current_token->token_type == TOKEN_MINUS)    ||
                    (current_token->token_type == TOKEN_ASTERISK) ||
                    (current_token->token_type == TOKEN_DIVIDE)   ||
                    (current_token->token_type == TOKEN_CARET)    ||
                    (current_token->token_type == TOKEN_MODULO))
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      state = 6150;
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  } 
                }
                else
                {
                  if (current_token->token_type == TOKEN_COMMA)
                  {
                    new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                    if (new_cst_element != NULL)
                    {
                      if (last_cst_element != NULL)
                      {
                        state = 6110;
                        last_cst_element->sibling = new_cst_element;
                        last_cst_element = last_cst_element->sibling;
                      }
                      else
                      {
                        state = 99999; 
                      }
                    }
                    else
                    {
                      state = 99999;
                    }
                  }
                  else
                  {
                    if (current_token->token_type == TOKEN_SEMICOLON)
                    {
                      if (num_left_parenthesis == num_right_parenthesis)
                      {
                        if (num_left_brackets == num_right_brackets)
                        {
                          new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                          if (new_cst_element != NULL)
                          {
                            if (last_cst_element != NULL)
                            {
                              state = 4000;
                              last_cst_element->sibling = new_cst_element;
                              last_cst_element = last_cst_element->sibling;
                            }
                            else
                            {
                              state = 99999; 
                            }
                          }
                          else
                          {
                            state = 99999;
                          }
                        }
                        else
                        {
                          state = 99999;
                        }
                      }
                      else
                      {
                        state = 99999;
                      }
                    }
                    else
                    {
                      printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                      state = 99999;
                    }
                  }
                }
              }
            }
          }
        break;
// ************************
// ************************
// ************************
        case 6150:
          if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
          {
            num_left_parenthesis++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 6150;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_IDENTIFIER)
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
		  state = 6120;
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_IDENTIFIER_INTEGER_CONSTANT)
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  if (last_cst_element != NULL)
                  {
                    state = 6140;
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              } 
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
        break;
        case 6500:
          if (current_token->token_type == TOKEN_SEMICOLON)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 4000;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if ((current_token->token_type == TOKEN_PLUS)     || 
                (current_token->token_type == TOKEN_MINUS)    ||
                (current_token->token_type == TOKEN_ASTERISK) ||
                (current_token->token_type == TOKEN_DIVIDE)   ||
                (current_token->token_type == TOKEN_CARET)    ||
                (current_token->token_type == TOKEN_MODULO))
            {
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
                  state = 6100;
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_RIGHT_BRACKET)
              {
                num_right_brackets++;
                if (num_left_brackets >= num_right_brackets)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      state = 6500;
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }   
            }           
          }
        break;
// ******************************************************
// * ... <TOKEN_IDENTIFIER_FLOATING_POINT_CONSTANT> ... *
// ******************************************************
        case 6600:
          if ((current_token->token_type == TOKEN_PLUS)                  || 
              (current_token->token_type == TOKEN_MINUS)                 ||
              (current_token->token_type == TOKEN_ASTERISK)              ||
              (current_token->token_type == TOKEN_DIVIDE)                ||
              (current_token->token_type == TOKEN_CARET)                 ||
              (current_token->token_type == TOKEN_MODULO)                ||
              (current_token->token_type == TOKEN_AND)                   ||
              (current_token->token_type == TOKEN_OR)                    ||
              (current_token->token_type == TOKEN_LESS_THAN)             ||
              (current_token->token_type == TOKEN_GREATER_THAN)          ||
              (current_token->token_type == TOKEN_EQUAL)                 ||
              (current_token->token_type == TOKEN_NOT_EQUAL)             ||
              (current_token->token_type == TOKEN_LESS_THAN_OR_EQUAL)    ||
              (current_token->token_type == TOKEN_GREATER_THAN_OR_EQUAL))
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 6100; 
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_SEMICOLON)
            {
              if (num_left_parenthesis == num_right_parenthesis)
              {
                if (num_left_brackets == num_right_brackets)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      if (set_statement_num_integer_constants_in_expression >= 2)
                      {
                        if (set_statement_cst_element != NULL)
                        {
                          set_statement_cst_element->cst_optimization_flags = cst_optimization_flags;
                        }
                      }
                      state = 4000;
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu: unbalanced parenthesis\n", current_token->line_number);
                state = 99999;
              }
            }
          }
        break;



// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!! Note: currently working adding SET command into the concrete syntax tree. Of course the SET command can include complex expressions if a variable contains an array element.         !!!
// !!! Everything under 6000 block of this section of the deterministic finite automaton needs to be verified. I probably need to create a graph to deal with numerical expressions within  !!!
// !!! an array element.                                                                                                                                                                    !!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!




// **********
// * IF ... *
// **********
        case 7000:
          if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
          {
            num_left_parenthesis = 1;
            num_right_parenthesis = 0;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 7010;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
        break;
// ************
// * IF ( ... *
// ************
        case 7010:
          if (current_token->token_type == TOKEN_IDENTIFIER_INTEGER_CONSTANT)
          {
            token_string_length = strlen (current_token->token);
            if (token_string_length == 1)
            {
              if (strncmp(current_token->token, "0", 1) == 0)
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  if (last_cst_element != NULL)
                  {
                    state = 7500;
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                if (strncmp(current_token->token, "1", 1) == 0)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      state = 7500;
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  printf ("Error on line %llu near \"%s\": expression within an IF statement is limited to \"0\" or \"1\" at the moment.\n", current_token->line_number, current_token->token);
                  state = 99999;
                }
              }             
            }
            else
            {
              printf ("Error on line %llu near \"%s\": expression within an IF statement is limited to \"0\" or \"1\" at the moment.\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
            {
              num_left_parenthesis++;
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
                  state = 7010;
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              printf ("Error on line %llu near \"%s\": expression within an IF statement is limited to \"0\" or \"1\" at the moment.\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// *************
// * IF (0 ... *
// *           *
// * IF (1 ... * 
// *************
        case 7500: 
          if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
          {
            num_right_parenthesis++;
            if (num_left_parenthesis >= num_right_parenthesis)
            {  
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                  if (num_left_parenthesis == num_right_parenthesis)
                  {
                    state = 7510;
                  }
                  else
                  {
                    state = 7500;
                  }
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else 
            {
              printf ("Unbalanced parenthesis on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// **************
// * IF (0) ... *
// * IF (1) ... *
// **************
        case 7510: 
          if (current_token->token_type == TOKEN_LEFT_CURLY_BRACE)
          {
            statement_stack = push_statement_stack (statement_stack, _if, num_left_curly_braces - num_right_curly_braces);
            num_left_curly_braces++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              state = 4000;
              if (last_cst_element != NULL)
              {
                last_cst_element->child = new_cst_element;
                last_cst_element = last_cst_element->child;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;
// ************
// * ELSE ... *
// ************
        case 8000:
          if (current_token->token_type == TOKEN_LEFT_CURLY_BRACE)
          {
            statement_stack = push_statement_stack (statement_stack, _else, num_left_curly_braces - num_right_curly_braces);
            num_left_curly_braces++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
   
              state = 4000;
              if (last_cst_element != NULL)
              {
                last_cst_element->child = new_cst_element;
                last_cst_element = last_cst_element->child;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          }
        break;




// ***************
// * DECLARE ... *
// ***************
        case 20000:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            token_string_length = strlen (current_token->token);
            switch (token_string_length)
            {
              case 3:
                if (strncmp(current_token->token, "int", 3) == 0)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      state = 20100;
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  printf ("Undeclared datatype \"%s\" on line %llu\n", current_token->token, current_token->line_number);
                  state = 99999;
                }
              break;
              case 4:
                if (strncmp(current_token->token, "bool", 4) == 0)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      state = 20100;
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  if (strncmp(current_token->token, "char", 4) == 0)
                  {
                    printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                    state = 99999;
                  }
                  else
                  {
                    if (strncmp(current_token->token, "date", 4) == 0)
                    {
                      printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                      state = 99999;
                    }
                    else
                    {
                      if (strncmp(current_token->token, "time", 4) == 0)
                      {
                        printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                        state = 99999;
                      }
                      else
                      {
                        if (strncmp(current_token->token, "file", 4) == 0)
                        {
                          printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                          state = 99999;
                        }
                        else
                        {
                          if (strncmp(current_token->token, "void", 4) == 0)
                          {
                            printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                            state = 99999;
                          }
                          else
                          {
                            if (strncmp(current_token->token, "enum", 4) == 0)
                            {
                              printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                              state = 99999;
                            }
                            else
                            {
                              printf ("Undeclared datatype \"%s\" on line %llu\n", current_token->token, current_token->line_number);
                              state = 99999;
                            }
                          }
                        }
                      }
                    }
                  }
                }
              break;
              case 5:
                if (strncmp(current_token->token, "float", 5) == 0)
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      state = 20100;
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999;
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  printf ("Undeclared datatype \"%s\" on line %llu\n", current_token->token, current_token->line_number);
                  state = 99999;
                }
              break;
              case 6:
                if (strncmp(current_token->token, "string", 6) == 0)
                {
                  printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                  state = 99999; 
                }
                else
                {
                  printf ("Undeclared datatype \"%s\" on line %llu\n", current_token->token, current_token->line_number);
                  state = 99999;
                }
              break;               
              case 7:
                if (strncmp(current_token->token, "pointer", 7) == 0)
                {
                  printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                  state = 99999;
                }
                else
                {
                  if (strncmp(current_token->token, "complex", 7) == 0)
                  {
                    printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                    state = 99999;
                  }
                  else
                  {
                    printf ("Undeclared datatype \"%s\" on line %llu\n", current_token->token, current_token->line_number);
                    state = 99999;
                  }
                }
              break;
              case 8:
                if (strncmp(current_token->token, "datetime", 8) == 0)
                {
                  printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                  state = 99999;
                }
                else
                {
                  printf ("Undeclared datatype \"%s\" on line %llu\n", current_token->token, current_token->line_number);
                  state = 99999;
                }
              break;
              case 9:
                if (strncmp(current_token->token, "imaginary", 9) == 0)
                {
                  printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                  state = 99999;
		}
                else
                {
                  if (strncmp(current_token->token, "attribute", 9) == 0)
                  {
                    printf ("The datatype \"%s\" on line %llu is not yet implemented in the Chaga compiler.\n", current_token->token, current_token->line_number);
                    state = 99999;
	          }
                  else
                  {
                    printf ("Undeclared datatype \"%s\" on line %llu\n", current_token->token, current_token->line_number);
                    state = 99999;
                  }
                }
              break;
              default:
                printf ("Undeclared datatype \"%s\" on line %llu\n", current_token->token, current_token->line_number);
                state = 99999;
              break;
            }
          }
        break;
// **************************
// * DECLARE <DATATYPE> ... *
// **************************
        case 20100:
          if (current_token->token_type == TOKEN_IDENTIFIER)
          {
            num_left_brackets = 0;
            num_right_brackets = 0;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 20150;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
            state = 99999;
          } 
        break;
// *******************************
// * <DATATYPE> <IDENTIFIER> ... *
// *******************************
        case 20150:
          if (current_token->token_type == TOKEN_LEFT_BRACKET)
          {
            num_left_brackets++;
            num_left_parenthesis = 0;
            num_right_parenthesis = 0;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 20200;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_COMMA)
            {
              if ((num_left_brackets == num_right_brackets) && (num_left_parenthesis == num_right_parenthesis))
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  if (last_cst_element != NULL)
                  {
                    state = 20100;
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_SEMICOLON)
              {
                if ((num_left_brackets == num_right_brackets) && (num_left_parenthesis == num_right_parenthesis))
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      state = 4000;
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
        break;
// **********************************************
// * <DATATYPE> <IDENTIFIER> <LEFT_BRACKET> ... *
// **********************************************
        case 20200:
          if (current_token->token_type == TOKEN_IDENTIFIER_INTEGER_CONSTANT)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 20250;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
            {
              num_left_parenthesis++;
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
                  state = 20200;
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// ********************************************************
// * <DATATYPE> <IDENTIFIER> <LEFT_BRACKET> <INTEGER> ... *
// ********************************************************
        case 20250:
          if ((current_token->token_type == TOKEN_PLUS)     || 
              (current_token->token_type == TOKEN_MINUS)    ||
              (current_token->token_type == TOKEN_ASTERISK) ||
              (current_token->token_type == TOKEN_DIVIDE)   ||
              (current_token->token_type == TOKEN_CARET)    ||
              (current_token->token_type == TOKEN_MODULO))
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 20300;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }   
          else
          {
            if (current_token->token_type == TOKEN_RIGHT_BRACKET)
            {
              num_right_brackets++;
              if ((num_left_brackets == num_right_brackets) && (num_left_parenthesis == num_right_parenthesis))
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  if (last_cst_element != NULL)
                  {
                    state = 20350;
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_RIGHT_PARENTHESIS)
              {
                if (num_left_parenthesis >= num_right_parenthesis)
                {  
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      state = 20250;
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else 
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
        break;
// ************************************************************************
// * <DATATYPE> <IDENTIFIER> <LEFT_BRACKET> <INTEGER> <MATH_OPERATOR> ... *
// ************************************************************************
        case 20300:
          if (current_token->token_type == TOKEN_IDENTIFIER_INTEGER_CONSTANT)
          {
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 20250;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_LEFT_PARENTHESIS)
            {
              num_left_parenthesis++;
              new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
              if (new_cst_element != NULL)
              {
                if (last_cst_element != NULL)
                {
                  state = 20300;
                  last_cst_element->sibling = new_cst_element;
                  last_cst_element = last_cst_element->sibling;
                }
                else
                {
                  state = 99999; 
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
              state = 99999;
            }
          }
        break;
// ************************************************************************
// * <DATATYPE> <IDENTIFIER> <LEFT_BRACKET> <INTEGER> <RIGHT_BRACKET> ... *
// ************************************************************************
        case 20350:
          if (current_token->token_type == TOKEN_LEFT_BRACKET)
          {
            num_left_brackets++;
            new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
            if (new_cst_element != NULL)
            {
              if (last_cst_element != NULL)
              {
                state = 20200;
                last_cst_element->sibling = new_cst_element;
                last_cst_element = last_cst_element->sibling;
              }
              else
              {
                state = 99999; 
              }
            }
            else
            {
              state = 99999;
            }
          }
          else
          {
            if (current_token->token_type == TOKEN_SEMICOLON)
            {
              if ((num_left_brackets == num_right_brackets) && (num_left_parenthesis == num_right_parenthesis))
              {
                new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                if (new_cst_element != NULL)
                {
                  if (last_cst_element != NULL)
                  {
                    state = 4000;
                    last_cst_element->sibling = new_cst_element;
                    last_cst_element = last_cst_element->sibling;
                  }
                  else
                  {
                    state = 99999; 
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                state = 99999;
              }
            }
            else
            {
              if (current_token->token_type == TOKEN_COMMA)
              {
                if ((num_left_brackets == num_right_brackets) && (num_left_parenthesis == num_right_parenthesis))
                {
                  new_cst_element = add_element_to_concrete_syntax_tree (current_token, NULL, TOKEN_UNKNOWN);
                  if (new_cst_element != NULL)
                  {
                    if (last_cst_element != NULL)
                    {
                      state = 20100; 
                      last_cst_element->sibling = new_cst_element;
                      last_cst_element = last_cst_element->sibling;
                    }
                    else
                    {
                      state = 99999; 
                    }
                  }
                  else
                  {
                    state = 99999;
                  }
                }
                else
                {
                  state = 99999;
                }
              }
              else
              {
                printf ("Syntax error on line %llu near \"%s\"\n", current_token->line_number, current_token->token);
                state = 99999;
              }
            }
          }
        break;
        default:
        break;
      }
    }
    else
    {
      state = 99999;
    }
    if (state != 99999)
    {
      previous_token = current_token;
      current_token = current_token->next;
    }
  }  // END: WHILE ((CURRENT_TOKEN != NULL) && (STATE < 99999))
  if ((state == 99999) || (current_token != NULL))
  {
// ********************************************************************************************
// * If an error occurred (i.e. state = 99999) OR the token_list was not completely exhausted *
// * then I must delete the Concrete Syntax Tree and return a NULL to calling program.        *
// ********************************************************************************************
    while (concrete_syntax_tree != NULL)
    {
      cst_element = concrete_syntax_tree;
      if (concrete_syntax_tree->sibling != NULL)
      {
        concrete_syntax_tree = concrete_syntax_tree->sibling;
      }
      else
      {
        concrete_syntax_tree = concrete_syntax_tree->child;
      }
      free (cst_element);
      cst_element = NULL;
    }
  }
// **********************************************************************************************************************************************************************************
// * Normally, the statement stack should be empty at this point IF no unbalanced curly braces occurred. However, IF the curly braces are unbalanced, clean-up the statement stack. *
// **********************************************************************************************************************************************************************************
  while (statement_stack != NULL)
  {
    statement_stack = pop_statement_stack (statement_stack);
  }
  return concrete_syntax_tree;
}
