text: #imports
  import Error
  from Interpreter import Interpreter
  from Parser import Parser
  from Scanner import Scanner
  import sys, time
  
  #begin Timid class
  class Timid:
      INTERPRETER = Interpreter()
      #define checkArgs function
      @staticmethod
      def checkArgs(args): #Check the system arguments
          #TODO: Add debug mode
          #begin if
          if len(args) > 1: #Show usage if wrong arguments passed
              print("Usage: Timid <sourceFile>")
              exit(65)
  
          elif len(args) == 1: #Run file if arguments has one file name
              #Get file name
              fileName = args[0]
  
              #Get start time
              t_start = time.time_ns()
  
              #begin runFile
              exitCode = Timid.runFile(fileName)
              #end runFile
  
              #Get end time
              t_end = time.time_ns()
  
              #Calculate time taken to run program, in seconds
              t_elapsed = t_end - t_start #Elapsed times
              t_elapsed = t_elapsed / 10**9 #Elpased in seconds
  
              print(f"File '{fileName}' executed with exit code {exitCode} in {t_elapsed} seconds")
  
              #Exit
              exit(exitCode)
  
          else: #Run interpreter on command line if no arguments
              print("Timid interpreter booting...")
              #Get start time
              t_start = time.time_ns()
  
              #begin runInterpreter
              exitCode = Timid.runInterpreter()
              #end runInterpreter
  
              #Get end time
              t_end = time.time_ns()
  
              print(f"Timid interpreter ran for {(t_end - t_start) / 10**9} seconds, and exited with exit code {exitCode}")
  
              #Exit
              exit(exitCode)
          #end if
      #end checkArgs function
  
      #define run function
      @staticmethod
      def run(source, fileName): #Running source
          #Set exit code
          exitCode = 0
  
          #Create new scanner
          scanner = Scanner(source, fileName)
  
          #Scan tokens, returns a list of tokens
          tokens = scanner.scan()
  
          #TODO: Enable when debug mode is on
          '''#begin for
          for token in tokens: #Loop through the tokens
              print(token)
          #end for'''
  
          #Create new parser
          parser = Parser(tokens)
          ast = parser.parse()
          
          #begin if
          if Error.hadError: #If error set exit code to 65
              exitCode = 65  
              return exitCode
          #end if      
  
          #TODO: Enable if debug mode on
          '''try:
              print(ast)
          except RecursionError:
              print("R")'''
  
          Timid.INTERPRETER.interpret(ast) #Interpret tree
  
          if Error.hadRTError: #If runtime error set exit code to 70
              exitCode = 70
              return exitCode
  
          return exitCode
      #end funFunction
  
      #define runFile function
      @staticmethod
      def runFile(fileName): #Running files, returns exit code
          #begin try
          try:
              #Open file
              file = open(fileName)
  
              #Read file
              source = file.read()
  
          except FileNotFoundError: #If file not found
              print(f"File '{fileName}' either does not exist, or is not in the current directory")
              return 65
  
          #end try
  
          #begin run
          exitCode = Timid.run(source, fileName)
          #end run
  
          return exitCode
      #end runFile function
  
      #begin runInterpreter function
      @staticmethod
      def runInterpreter(): #Running interpreter on command line, returns exit code
          #begin while
          while True:
              #begin try
              try:
                  source = input("Timid> ")
              except (KeyboardInterrupt, EOFError): #If exited abnormally
                  return 64
              #end try
  
              #begin if
              if not source: #If no text
                  return 0
              #end if
  
              #begin run
              Timid.run(source, "<stdin>")
              #end run
  
              Error.hadError = False
              Error.hadRuntimeError = False
  
          #end while
      #end runInterpreter function
      
      #define start function
      @staticmethod
      def start(): #Main entry point
          args = sys.argv[1:] #First argument is this file's name, so discard first argument
  
          #begin checkArgs
          Timid.checkArgs(args)     
          #end checkArgs
      #end start function
  #end Timid class
  
  #begin
  #begin if     
  if __name__ == "__main__":
      Timid.start()
  #end if
  #end