code: def p_optional_value(t):
      
      # return value or None.
      t[0] = t[1]
      # Note this must be unsigned
      value = t[0]
      if value is None or value[0].isdigit():
          return
      msg = ''
      if value[0] == '-':
          msg = "Can't use negative index %s" % value
      elif value not in name_dict:
          msg = "Can't derefence index %s" % value
      else:
          data = name_dict[value]
          if data.type != 'const':
              msg = "Can't use non-constant %s %s as index" % (data.type, value)
          elif not data.positive:
              msg = "Can't use negative index %s" % value
      if msg:
          global error_occurred
          error_occurred = True
          print(u"ERROR - {0:s} near line {1:d}".format(msg, t.lineno(1)))
docs: optional_value : value
                        | empty