# Autogenerated from a Treetop grammar. Edits may be lost.


module Mail
  module RFC2822
    include Treetop::Runtime

    def root
      @root ||= :ALPHA
    end

    include RFC2822Obsolete

    def _nt_ALPHA
      start_index = index
      if node_cache[:ALPHA].has_key?(index)
        cached = node_cache[:ALPHA][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      if has_terminal?('\G[a-zA-Z]', true, index)
        r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        r0 = nil
      end

      node_cache[:ALPHA][start_index] = r0

      r0
    end

    def _nt_DIGIT
      start_index = index
      if node_cache[:DIGIT].has_key?(index)
        cached = node_cache[:DIGIT][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      if has_terminal?('\G[0-9]', true, index)
        r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        r0 = nil
      end

      node_cache[:DIGIT][start_index] = r0

      r0
    end

    def _nt_DQUOTE
      start_index = index
      if node_cache[:DQUOTE].has_key?(index)
        cached = node_cache[:DQUOTE][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      if has_terminal?('"', false, index)
        r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure('"')
        r0 = nil
      end

      node_cache[:DQUOTE][start_index] = r0

      r0
    end

    def _nt_LF
      start_index = index
      if node_cache[:LF].has_key?(index)
        cached = node_cache[:LF][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      if has_terminal?("\n", false, index)
        r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure("\n")
        r0 = nil
      end

      node_cache[:LF][start_index] = r0

      r0
    end

    def _nt_CR
      start_index = index
      if node_cache[:CR].has_key?(index)
        cached = node_cache[:CR][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      if has_terminal?("\r", false, index)
        r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure("\r")
        r0 = nil
      end

      node_cache[:CR][start_index] = r0

      r0
    end

    def _nt_CRLF
      start_index = index
      if node_cache[:CRLF].has_key?(index)
        cached = node_cache[:CRLF][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      if has_terminal?("\r\n", false, index)
        r0 = instantiate_node(SyntaxNode,input, index...(index + 2))
        @index += 2
      else
        terminal_parse_failure("\r\n")
        r0 = nil
      end

      node_cache[:CRLF][start_index] = r0

      r0
    end

    def _nt_WSP
      start_index = index
      if node_cache[:WSP].has_key?(index)
        cached = node_cache[:WSP][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      if has_terminal?('\G[\\x09\\x20]', true, index)
        r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        r0 = nil
      end

      node_cache[:WSP][start_index] = r0

      r0
    end

    module FWS0
      def CRLF
        elements[1]
      end

    end

    module FWS1
      def CRLF
        elements[0]
      end

    end

    def _nt_FWS
      start_index = index
      if node_cache[:FWS].has_key?(index)
        cached = node_cache[:FWS][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      s2, i2 = [], index
      loop do
        r3 = _nt_WSP
        if r3
          s2 << r3
        else
          break
        end
      end
      r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
      s1 << r2
      if r2
        r4 = _nt_CRLF
        s1 << r4
        if r4
          s5, i5 = [], index
          loop do
            r6 = _nt_WSP
            if r6
              s5 << r6
            else
              break
            end
          end
          if s5.empty?
            @index = i5
            r5 = nil
          else
            r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
          end
          s1 << r5
        end
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(FWS0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        i7, s7 = index, []
        r8 = _nt_CRLF
        s7 << r8
        if r8
          s9, i9 = [], index
          loop do
            r10 = _nt_WSP
            if r10
              s9 << r10
            else
              break
            end
          end
          if s9.empty?
            @index = i9
            r9 = nil
          else
            r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
          end
          s7 << r9
        end
        if s7.last
          r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
          r7.extend(FWS1)
        else
          @index = i7
          r7 = nil
        end
        if r7
          r0 = r7
        else
          r11 = _nt_obs_FWS
          if r11
            r0 = r11
          else
            @index = i0
            r0 = nil
          end
        end
      end

      node_cache[:FWS][start_index] = r0

      r0
    end

    module CFWS0
      def comment
        elements[1]
      end
    end

    module CFWS1
    end

    def _nt_CFWS
      start_index = index
      if node_cache[:CFWS].has_key?(index)
        cached = node_cache[:CFWS][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      s1, i1 = [], index
      loop do
        i2, s2 = index, []
        s3, i3 = [], index
        loop do
          r4 = _nt_FWS
          if r4
            s3 << r4
          else
            break
          end
        end
        r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        s2 << r3
        if r3
          r5 = _nt_comment
          s2 << r5
        end
        if s2.last
          r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
          r2.extend(CFWS0)
        else
          @index = i2
          r2 = nil
        end
        if r2
          s1 << r2
        else
          break
        end
      end
      r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
      s0 << r1
      if r1
        r7 = _nt_FWS
        if r7
          r6 = r7
        else
          r6 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r6
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(CFWS1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:CFWS][start_index] = r0

      r0
    end

    def _nt_NO_WS_CTL
      start_index = index
      if node_cache[:NO_WS_CTL].has_key?(index)
        cached = node_cache[:NO_WS_CTL][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      if has_terminal?('\G[\\x01-\\x08]', true, index)
        r1 = true
        @index += 1
      else
        r1 = nil
      end
      if r1
        r0 = r1
      else
        if has_terminal?('\G[\\x0B-\\x0C]', true, index)
          r2 = true
          @index += 1
        else
          r2 = nil
        end
        if r2
          r0 = r2
        else
          if has_terminal?('\G[\\x0E-\\x1F]', true, index)
            r3 = true
            @index += 1
          else
            r3 = nil
          end
          if r3
            r0 = r3
          else
            if has_terminal?('\G[\\x7f]', true, index)
              r4 = true
              @index += 1
            else
              r4 = nil
            end
            if r4
              r0 = r4
            else
              @index = i0
              r0 = nil
            end
          end
        end
      end

      node_cache[:NO_WS_CTL][start_index] = r0

      r0
    end

    def _nt_specials
      start_index = index
      if node_cache[:specials].has_key?(index)
        cached = node_cache[:specials][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      if has_terminal?("(", false, index)
        r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure("(")
        r1 = nil
      end
      if r1
        r0 = r1
      else
        if has_terminal?(")", false, index)
          r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure(")")
          r2 = nil
        end
        if r2
          r0 = r2
        else
          if has_terminal?("<", false, index)
            r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure("<")
            r3 = nil
          end
          if r3
            r0 = r3
          else
            if has_terminal?(">", false, index)
              r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure(">")
              r4 = nil
            end
            if r4
              r0 = r4
            else
              if has_terminal?("[", false, index)
                r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
                @index += 1
              else
                terminal_parse_failure("[")
                r5 = nil
              end
              if r5
                r0 = r5
              else
                if has_terminal?("]", false, index)
                  r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
                  @index += 1
                else
                  terminal_parse_failure("]")
                  r6 = nil
                end
                if r6
                  r0 = r6
                else
                  if has_terminal?(":", false, index)
                    r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
                    @index += 1
                  else
                    terminal_parse_failure(":")
                    r7 = nil
                  end
                  if r7
                    r0 = r7
                  else
                    if has_terminal?(";", false, index)
                      r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
                      @index += 1
                    else
                      terminal_parse_failure(";")
                      r8 = nil
                    end
                    if r8
                      r0 = r8
                    else
                      if has_terminal?("@", false, index)
                        r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
                        @index += 1
                      else
                        terminal_parse_failure("@")
                        r9 = nil
                      end
                      if r9
                        r0 = r9
                      else
                        if has_terminal?('\\', false, index)
                          r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
                          @index += 1
                        else
                          terminal_parse_failure('\\')
                          r10 = nil
                        end
                        if r10
                          r0 = r10
                        else
                          if has_terminal?(",", false, index)
                            r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
                            @index += 1
                          else
                            terminal_parse_failure(",")
                            r11 = nil
                          end
                          if r11
                            r0 = r11
                          else
                            if has_terminal?(".", false, index)
                              r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
                              @index += 1
                            else
                              terminal_parse_failure(".")
                              r12 = nil
                            end
                            if r12
                              r0 = r12
                            else
                              r13 = _nt_DQUOTE
                              if r13
                                r0 = r13
                              else
                                @index = i0
                                r0 = nil
                              end
                            end
                          end
                        end
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end

      node_cache[:specials][start_index] = r0

      r0
    end

    def _nt_ctext
      start_index = index
      if node_cache[:ctext].has_key?(index)
        cached = node_cache[:ctext][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_NO_WS_CTL
      if r1
        r0 = r1
      else
        if has_terminal?('\G[\\x21-\\x27]', true, index)
          r2 = true
          @index += 1
        else
          r2 = nil
        end
        if r2
          r0 = r2
        else
          if has_terminal?('\G[\\x2a-\\x5b]', true, index)
            r3 = true
            @index += 1
          else
            r3 = nil
          end
          if r3
            r0 = r3
          else
            if has_terminal?('\G[\\x5d-\\x7e]', true, index)
              r4 = true
              @index += 1
            else
              r4 = nil
            end
            if r4
              r0 = r4
            else
              @index = i0
              r0 = nil
            end
          end
        end
      end

      node_cache[:ctext][start_index] = r0

      r0
    end

    def _nt_ccontent
      start_index = index
      if node_cache[:ccontent].has_key?(index)
        cached = node_cache[:ccontent][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_ctext
      if r1
        r0 = r1
      else
        r2 = _nt_quoted_pair
        if r2
          r0 = r2
        else
          r3 = _nt_comment
          if r3
            r0 = r3
          else
            @index = i0
            r0 = nil
          end
        end
      end

      node_cache[:ccontent][start_index] = r0

      r0
    end

    module Comment0
      def ccontent
        elements[1]
      end
    end

    module Comment1
    end

    def _nt_comment
      start_index = index
      if node_cache[:comment].has_key?(index)
        cached = node_cache[:comment][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      if has_terminal?("(", false, index)
        r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure("(")
        r1 = nil
      end
      s0 << r1
      if r1
        s2, i2 = [], index
        loop do
          i3, s3 = index, []
          r5 = _nt_FWS
          if r5
            r4 = r5
          else
            r4 = instantiate_node(SyntaxNode,input, index...index)
          end
          s3 << r4
          if r4
            r6 = _nt_ccontent
            s3 << r6
          end
          if s3.last
            r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
            r3.extend(Comment0)
          else
            @index = i3
            r3 = nil
          end
          if r3
            s2 << r3
          else
            break
          end
        end
        r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        s0 << r2
        if r2
          r8 = _nt_FWS
          if r8
            r7 = r8
          else
            r7 = instantiate_node(SyntaxNode,input, index...index)
          end
          s0 << r7
          if r7
            if has_terminal?(")", false, index)
              r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure(")")
              r9 = nil
            end
            s0 << r9
          end
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(Comment1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:comment][start_index] = r0

      r0
    end

    def _nt_atext
      start_index = index
      if node_cache[:atext].has_key?(index)
        cached = node_cache[:atext][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_ALPHA
      if r1
        r0 = r1
      else
        r2 = _nt_DIGIT
        if r2
          r0 = r2
        else
          if has_terminal?("!", false, index)
            r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure("!")
            r3 = nil
          end
          if r3
            r0 = r3
          else
            if has_terminal?("#", false, index)
              r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure("#")
              r4 = nil
            end
            if r4
              r0 = r4
            else
              if has_terminal?("$", false, index)
                r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
                @index += 1
              else
                terminal_parse_failure("$")
                r5 = nil
              end
              if r5
                r0 = r5
              else
                if has_terminal?("%", false, index)
                  r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
                  @index += 1
                else
                  terminal_parse_failure("%")
                  r6 = nil
                end
                if r6
                  r0 = r6
                else
                  if has_terminal?("&", false, index)
                    r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
                    @index += 1
                  else
                    terminal_parse_failure("&")
                    r7 = nil
                  end
                  if r7
                    r0 = r7
                  else
                    if has_terminal?("'", false, index)
                      r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
                      @index += 1
                    else
                      terminal_parse_failure("'")
                      r8 = nil
                    end
                    if r8
                      r0 = r8
                    else
                      if has_terminal?("*", false, index)
                        r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
                        @index += 1
                      else
                        terminal_parse_failure("*")
                        r9 = nil
                      end
                      if r9
                        r0 = r9
                      else
                        if has_terminal?("+", false, index)
                          r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
                          @index += 1
                        else
                          terminal_parse_failure("+")
                          r10 = nil
                        end
                        if r10
                          r0 = r10
                        else
                          if has_terminal?("-", false, index)
                            r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
                            @index += 1
                          else
                            terminal_parse_failure("-")
                            r11 = nil
                          end
                          if r11
                            r0 = r11
                          else
                            if has_terminal?("/", false, index)
                              r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
                              @index += 1
                            else
                              terminal_parse_failure("/")
                              r12 = nil
                            end
                            if r12
                              r0 = r12
                            else
                              if has_terminal?("=", false, index)
                                r13 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                @index += 1
                              else
                                terminal_parse_failure("=")
                                r13 = nil
                              end
                              if r13
                                r0 = r13
                              else
                                if has_terminal?("?", false, index)
                                  r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                  @index += 1
                                else
                                  terminal_parse_failure("?")
                                  r14 = nil
                                end
                                if r14
                                  r0 = r14
                                else
                                  if has_terminal?("^", false, index)
                                    r15 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                    @index += 1
                                  else
                                    terminal_parse_failure("^")
                                    r15 = nil
                                  end
                                  if r15
                                    r0 = r15
                                  else
                                    if has_terminal?("_", false, index)
                                      r16 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                      @index += 1
                                    else
                                      terminal_parse_failure("_")
                                      r16 = nil
                                    end
                                    if r16
                                      r0 = r16
                                    else
                                      if has_terminal?("`", false, index)
                                        r17 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                        @index += 1
                                      else
                                        terminal_parse_failure("`")
                                        r17 = nil
                                      end
                                      if r17
                                        r0 = r17
                                      else
                                        if has_terminal?("{", false, index)
                                          r18 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                          @index += 1
                                        else
                                          terminal_parse_failure("{")
                                          r18 = nil
                                        end
                                        if r18
                                          r0 = r18
                                        else
                                          if has_terminal?("|", false, index)
                                            r19 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                            @index += 1
                                          else
                                            terminal_parse_failure("|")
                                            r19 = nil
                                          end
                                          if r19
                                            r0 = r19
                                          else
                                            if has_terminal?("}", false, index)
                                              r20 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                              @index += 1
                                            else
                                              terminal_parse_failure("}")
                                              r20 = nil
                                            end
                                            if r20
                                              r0 = r20
                                            else
                                              if has_terminal?("~", false, index)
                                                r21 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                                @index += 1
                                              else
                                                terminal_parse_failure("~")
                                                r21 = nil
                                              end
                                              if r21
                                                r0 = r21
                                              else
                                                @index = i0
                                                r0 = nil
                                              end
                                            end
                                          end
                                        end
                                      end
                                    end
                                  end
                                end
                              end
                            end
                          end
                        end
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end

      node_cache[:atext][start_index] = r0

      r0
    end

    def _nt_mtext
      start_index = index
      if node_cache[:mtext].has_key?(index)
        cached = node_cache[:mtext][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      s0, i0 = [], index
      loop do
        i1 = index
        r2 = _nt_atext
        if r2
          r1 = r2
        else
          if has_terminal?(".", false, index)
            r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure(".")
            r3 = nil
          end
          if r3
            r1 = r3
          else
            @index = i1
            r1 = nil
          end
        end
        if r1
          s0 << r1
        else
          break
        end
      end
      if s0.empty?
        @index = i0
        r0 = nil
      else
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      end

      node_cache[:mtext][start_index] = r0

      r0
    end

    module Atom0
    end

    def _nt_atom
      start_index = index
      if node_cache[:atom].has_key?(index)
        cached = node_cache[:atom][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r2 = _nt_CFWS
      if r2
        r1 = r2
      else
        r1 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r1
      if r1
        s3, i3 = [], index
        loop do
          r4 = _nt_atext
          if r4
            s3 << r4
          else
            break
          end
        end
        if s3.empty?
          @index = i3
          r3 = nil
        else
          r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        end
        s0 << r3
        if r3
          r6 = _nt_CFWS
          if r6
            r5 = r6
          else
            r5 = instantiate_node(SyntaxNode,input, index...index)
          end
          s0 << r5
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(Atom0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:atom][start_index] = r0

      r0
    end

    module DotAtom0
      def dot_atom_text
        elements[1]
      end

    end

    def _nt_dot_atom
      start_index = index
      if node_cache[:dot_atom].has_key?(index)
        cached = node_cache[:dot_atom][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r2 = _nt_CFWS
      if r2
        r1 = r2
      else
        r1 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r1
      if r1
        r3 = _nt_dot_atom_text
        s0 << r3
        if r3
          r5 = _nt_CFWS
          if r5
            r4 = r5
          else
            r4 = instantiate_node(SyntaxNode,input, index...index)
          end
          s0 << r4
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(DotAtom0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:dot_atom][start_index] = r0

      r0
    end

    module LocalDotAtom0
      def local_dot_atom_text
        elements[1]
      end

    end

    def _nt_local_dot_atom
      start_index = index
      if node_cache[:local_dot_atom].has_key?(index)
        cached = node_cache[:local_dot_atom][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r2 = _nt_CFWS
      if r2
        r1 = r2
      else
        r1 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r1
      if r1
        r3 = _nt_local_dot_atom_text
        s0 << r3
        if r3
          r5 = _nt_CFWS
          if r5
            r4 = r5
          else
            r4 = instantiate_node(SyntaxNode,input, index...index)
          end
          s0 << r4
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(LocalDotAtom0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:local_dot_atom][start_index] = r0

      r0
    end

    def _nt_message_id_text
      start_index = index
      if node_cache[:message_id_text].has_key?(index)
        cached = node_cache[:message_id_text][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      s0, i0 = [], index
      loop do
        r1 = _nt_mtext
        if r1
          s0 << r1
        else
          break
        end
      end
      if s0.empty?
        @index = i0
        r0 = nil
      else
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      end

      node_cache[:message_id_text][start_index] = r0

      r0
    end

    module DotAtomText0
      def domain_text
        elements[0]
      end

    end

    def _nt_dot_atom_text
      start_index = index
      if node_cache[:dot_atom_text].has_key?(index)
        cached = node_cache[:dot_atom_text][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      s0, i0 = [], index
      loop do
        i1, s1 = index, []
        r2 = _nt_domain_text
        s1 << r2
        if r2
          if has_terminal?(".", false, index)
            r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure(".")
            r4 = nil
          end
          if r4
            r3 = r4
          else
            r3 = instantiate_node(SyntaxNode,input, index...index)
          end
          s1 << r3
        end
        if s1.last
          r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
          r1.extend(DotAtomText0)
        else
          @index = i1
          r1 = nil
        end
        if r1
          s0 << r1
        else
          break
        end
      end
      if s0.empty?
        @index = i0
        r0 = nil
      else
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      end

      node_cache[:dot_atom_text][start_index] = r0

      r0
    end

    module LocalDotAtomText0
      def domain_text
        elements[1]
      end

    end

    def _nt_local_dot_atom_text
      start_index = index
      if node_cache[:local_dot_atom_text].has_key?(index)
        cached = node_cache[:local_dot_atom_text][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      s0, i0 = [], index
      loop do
        i1, s1 = index, []
        s2, i2 = [], index
        loop do
          if has_terminal?(".", false, index)
            r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure(".")
            r3 = nil
          end
          if r3
            s2 << r3
          else
            break
          end
        end
        r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        s1 << r2
        if r2
          r4 = _nt_domain_text
          s1 << r4
          if r4
            s5, i5 = [], index
            loop do
              if has_terminal?(".", false, index)
                r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
                @index += 1
              else
                terminal_parse_failure(".")
                r6 = nil
              end
              if r6
                s5 << r6
              else
                break
              end
            end
            r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
            s1 << r5
          end
        end
        if s1.last
          r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
          r1.extend(LocalDotAtomText0)
        else
          @index = i1
          r1 = nil
        end
        if r1
          s0 << r1
        else
          break
        end
      end
      if s0.empty?
        @index = i0
        r0 = nil
      else
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      end

      node_cache[:local_dot_atom_text][start_index] = r0

      r0
    end

    module DomainText0
      def quoted_domain
        elements[1]
      end
    end

    module DomainText1
      def DQUOTE1
        elements[0]
      end

      def DQUOTE2
        elements[3]
      end
    end

    def _nt_domain_text
      start_index = index
      if node_cache[:domain_text].has_key?(index)
        cached = node_cache[:domain_text][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r2 = _nt_DQUOTE
      s1 << r2
      if r2
        s3, i3 = [], index
        loop do
          i4, s4 = index, []
          r6 = _nt_FWS
          if r6
            r5 = r6
          else
            r5 = instantiate_node(SyntaxNode,input, index...index)
          end
          s4 << r5
          if r5
            r7 = _nt_quoted_domain
            s4 << r7
          end
          if s4.last
            r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
            r4.extend(DomainText0)
          else
            @index = i4
            r4 = nil
          end
          if r4
            s3 << r4
          else
            break
          end
        end
        if s3.empty?
          @index = i3
          r3 = nil
        else
          r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        end
        s1 << r3
        if r3
          r9 = _nt_FWS
          if r9
            r8 = r9
          else
            r8 = instantiate_node(SyntaxNode,input, index...index)
          end
          s1 << r8
          if r8
            r10 = _nt_DQUOTE
            s1 << r10
          end
        end
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(DomainText1)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        s11, i11 = [], index
        loop do
          r12 = _nt_atext
          if r12
            s11 << r12
          else
            break
          end
        end
        if s11.empty?
          @index = i11
          r11 = nil
        else
          r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
        end
        if r11
          r0 = r11
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:domain_text][start_index] = r0

      r0
    end

    module QuotedDomain0
      def text
        elements[1]
      end
    end

    def _nt_quoted_domain
      start_index = index
      if node_cache[:quoted_domain].has_key?(index)
        cached = node_cache[:quoted_domain][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_qdcontent
      if r1
        r0 = r1
      else
        i2, s2 = index, []
        if has_terminal?("\\", false, index)
          r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("\\")
          r3 = nil
        end
        s2 << r3
        if r3
          r4 = _nt_text
          s2 << r4
        end
        if s2.last
          r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
          r2.extend(QuotedDomain0)
        else
          @index = i2
          r2 = nil
        end
        if r2
          r0 = r2
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:quoted_domain][start_index] = r0

      r0
    end

    def _nt_qdcontent
      start_index = index
      if node_cache[:qdcontent].has_key?(index)
        cached = node_cache[:qdcontent][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_NO_WS_CTL
      if r1
        r0 = r1
      else
        if has_terminal?('\G[\\x21]', true, index)
          r2 = true
          @index += 1
        else
          r2 = nil
        end
        if r2
          r0 = r2
        else
          if has_terminal?('\G[\\x23-\\x45]', true, index)
            r3 = true
            @index += 1
          else
            r3 = nil
          end
          if r3
            r0 = r3
          else
            if has_terminal?('\G[\\x47-\\x5b]', true, index)
              r4 = true
              @index += 1
            else
              r4 = nil
            end
            if r4
              r0 = r4
            else
              if has_terminal?('\G[\\x5d-\\x7e]', true, index)
                r5 = true
                @index += 1
              else
                r5 = nil
              end
              if r5
                r0 = r5
              else
                @index = i0
                r0 = nil
              end
            end
          end
        end
      end

      node_cache[:qdcontent][start_index] = r0

      r0
    end

    def _nt_phrase
      start_index = index
      if node_cache[:phrase].has_key?(index)
        cached = node_cache[:phrase][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_obs_phrase
      if r1
        r0 = r1
      else
        s2, i2 = [], index
        loop do
          r3 = _nt_word
          if r3
            s2 << r3
          else
            break
          end
        end
        if s2.empty?
          @index = i2
          r2 = nil
        else
          r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        end
        if r2
          r0 = r2
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:phrase][start_index] = r0

      r0
    end

    def _nt_word
      start_index = index
      if node_cache[:word].has_key?(index)
        cached = node_cache[:word][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_atom
      if r1
        r0 = r1
      else
        r2 = _nt_quoted_string
        if r2
          r0 = r2
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:word][start_index] = r0

      r0
    end

    module PhraseList0
      def phrase_value
        elements[2]
      end
    end

    module PhraseList1
      def first_phrase
        elements[0]
      end

      def other_phrases
        elements[1]
      end
    end

    def _nt_phrase_list
      start_index = index
      if node_cache[:phrase_list].has_key?(index)
        cached = node_cache[:phrase_list][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r1 = _nt_phrase
      s0 << r1
      if r1
        s2, i2 = [], index
        loop do
          i3, s3 = index, []
          if has_terminal?(",", false, index)
            r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure(",")
            r4 = nil
          end
          s3 << r4
          if r4
            s5, i5 = [], index
            loop do
              r6 = _nt_FWS
              if r6
                s5 << r6
              else
                break
              end
            end
            r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
            s3 << r5
            if r5
              r7 = _nt_phrase
              s3 << r7
            end
          end
          if s3.last
            r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
            r3.extend(PhraseList0)
          else
            @index = i3
            r3 = nil
          end
          if r3
            s2 << r3
          else
            break
          end
        end
        r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        s0 << r2
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(PhraseList1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:phrase_list][start_index] = r0

      r0
    end

    module DomainLiteral0
      def dcontent
        elements[1]
      end
    end

    module DomainLiteral1
    end

    def _nt_domain_literal
      start_index = index
      if node_cache[:domain_literal].has_key?(index)
        cached = node_cache[:domain_literal][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r2 = _nt_CFWS
      if r2
        r1 = r2
      else
        r1 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r1
      if r1
        if has_terminal?("[", false, index)
          r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("[")
          r3 = nil
        end
        s0 << r3
        if r3
          s4, i4 = [], index
          loop do
            i5, s5 = index, []
            r7 = _nt_FWS
            if r7
              r6 = r7
            else
              r6 = instantiate_node(SyntaxNode,input, index...index)
            end
            s5 << r6
            if r6
              r8 = _nt_dcontent
              s5 << r8
            end
            if s5.last
              r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
              r5.extend(DomainLiteral0)
            else
              @index = i5
              r5 = nil
            end
            if r5
              s4 << r5
            else
              break
            end
          end
          r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
          s0 << r4
          if r4
            r10 = _nt_FWS
            if r10
              r9 = r10
            else
              r9 = instantiate_node(SyntaxNode,input, index...index)
            end
            s0 << r9
            if r9
              if has_terminal?("]", false, index)
                r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
                @index += 1
              else
                terminal_parse_failure("]")
                r11 = nil
              end
              s0 << r11
              if r11
                r13 = _nt_CFWS
                if r13
                  r12 = r13
                else
                  r12 = instantiate_node(SyntaxNode,input, index...index)
                end
                s0 << r12
              end
            end
          end
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(DomainLiteral1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:domain_literal][start_index] = r0

      r0
    end

    def _nt_dcontent
      start_index = index
      if node_cache[:dcontent].has_key?(index)
        cached = node_cache[:dcontent][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_dtext
      if r1
        r0 = r1
      else
        r2 = _nt_quoted_pair
        if r2
          r0 = r2
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:dcontent][start_index] = r0

      r0
    end

    def _nt_dtext
      start_index = index
      if node_cache[:dtext].has_key?(index)
        cached = node_cache[:dtext][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_NO_WS_CTL
      if r1
        r0 = r1
      else
        if has_terminal?('\G[\\x21-\\x5a]', true, index)
          r2 = true
          @index += 1
        else
          r2 = nil
        end
        if r2
          r0 = r2
        else
          if has_terminal?('\G[\\x5e-\\x7e]', true, index)
            r3 = true
            @index += 1
          else
            r3 = nil
          end
          if r3
            r0 = r3
          else
            @index = i0
            r0 = nil
          end
        end
      end

      node_cache[:dtext][start_index] = r0

      r0
    end

    module AngleAddr0
      def addr_spec
        elements[2]
      end

    end

    def _nt_angle_addr
      start_index = index
      if node_cache[:angle_addr].has_key?(index)
        cached = node_cache[:angle_addr][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r3 = _nt_CFWS
      if r3
        r2 = r3
      else
        r2 = instantiate_node(SyntaxNode,input, index...index)
      end
      s1 << r2
      if r2
        if has_terminal?("<", false, index)
          r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("<")
          r4 = nil
        end
        s1 << r4
        if r4
          r5 = _nt_addr_spec
          s1 << r5
          if r5
            if has_terminal?(">", false, index)
              r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure(">")
              r6 = nil
            end
            s1 << r6
            if r6
              r8 = _nt_CFWS
              if r8
                r7 = r8
              else
                r7 = instantiate_node(SyntaxNode,input, index...index)
              end
              s1 << r7
            end
          end
        end
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(AngleAddr0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r9 = _nt_obs_angle_addr
        if r9
          r0 = r9
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:angle_addr][start_index] = r0

      r0
    end

    module AddrSpec0
      def local_part
        elements[0]
      end

      def domain
        elements[2]
      end
    end

    def _nt_addr_spec
      start_index = index
      if node_cache[:addr_spec].has_key?(index)
        cached = node_cache[:addr_spec][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r2 = _nt_local_part
      s1 << r2
      if r2
        if has_terminal?("@", false, index)
          r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("@")
          r3 = nil
        end
        s1 << r3
        if r3
          r4 = _nt_domain
          s1 << r4
        end
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(AddrSpec0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r5 = _nt_local_part
        if r5
          r0 = r5
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:addr_spec][start_index] = r0

      r0
    end

    def _nt_local_part
      start_index = index
      if node_cache[:local_part].has_key?(index)
        cached = node_cache[:local_part][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_local_dot_atom
      if r1
        r0 = r1
      else
        r2 = _nt_quoted_string
        if r2
          r0 = r2
        else
          r3 = _nt_obs_local_part
          if r3
            r0 = r3
          else
            @index = i0
            r0 = nil
          end
        end
      end

      node_cache[:local_part][start_index] = r0

      r0
    end

    def _nt_domain
      start_index = index
      if node_cache[:domain].has_key?(index)
        cached = node_cache[:domain][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_dot_atom
      if r1
        r0 = r1
      else
        r2 = _nt_domain_literal
        if r2
          r0 = r2
        else
          r3 = _nt_obs_domain
          if r3
            r0 = r3
          else
            @index = i0
            r0 = nil
          end
        end
      end

      node_cache[:domain][start_index] = r0

      r0
    end

    module Group0
      def group_name
        elements[0]
      end

      def group_list
        elements[2]
      end

    end

    def _nt_group
      start_index = index
      if node_cache[:group].has_key?(index)
        cached = node_cache[:group][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r1 = _nt_display_name
      s0 << r1
      if r1
        if has_terminal?(":", false, index)
          r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure(":")
          r2 = nil
        end
        s0 << r2
        if r2
          i4 = index
          r5 = _nt_mailbox_list_group
          if r5
            r4 = r5
          else
            r6 = _nt_CFWS
            if r6
              r4 = r6
            else
              @index = i4
              r4 = nil
            end
          end
          if r4
            r3 = r4
          else
            r3 = instantiate_node(SyntaxNode,input, index...index)
          end
          s0 << r3
          if r3
            if has_terminal?(";", false, index)
              r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure(";")
              r7 = nil
            end
            s0 << r7
            if r7
              r9 = _nt_CFWS
              if r9
                r8 = r9
              else
                r8 = instantiate_node(SyntaxNode,input, index...index)
              end
              s0 << r8
            end
          end
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(Group0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:group][start_index] = r0

      r0
    end

    module MailboxListGroup0
      def addresses
        [first_addr] + other_addr.elements.map { |o| o.addr_value }
      end
    end

    def _nt_mailbox_list_group
      start_index = index
      if node_cache[:mailbox_list_group].has_key?(index)
        cached = node_cache[:mailbox_list_group][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      r0 = _nt_mailbox_list
      r0.extend(MailboxListGroup0)

      node_cache[:mailbox_list_group][start_index] = r0

      r0
    end

    module QuotedString0
      def qcontent
        elements[1]
      end
    end

    module QuotedString1
      def DQUOTE1
        elements[1]
      end

      def quoted_content
        elements[2]
      end

      def DQUOTE2
        elements[4]
      end

    end

    def _nt_quoted_string
      start_index = index
      if node_cache[:quoted_string].has_key?(index)
        cached = node_cache[:quoted_string][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r2 = _nt_CFWS
      if r2
        r1 = r2
      else
        r1 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r1
      if r1
        r3 = _nt_DQUOTE
        s0 << r3
        if r3
          s4, i4 = [], index
          loop do
            i5, s5 = index, []
            r7 = _nt_FWS
            if r7
              r6 = r7
            else
              r6 = instantiate_node(SyntaxNode,input, index...index)
            end
            s5 << r6
            if r6
              r8 = _nt_qcontent
              s5 << r8
            end
            if s5.last
              r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
              r5.extend(QuotedString0)
            else
              @index = i5
              r5 = nil
            end
            if r5
              s4 << r5
            else
              break
            end
          end
          r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
          s0 << r4
          if r4
            r10 = _nt_FWS
            if r10
              r9 = r10
            else
              r9 = instantiate_node(SyntaxNode,input, index...index)
            end
            s0 << r9
            if r9
              r11 = _nt_DQUOTE
              s0 << r11
              if r11
                r13 = _nt_CFWS
                if r13
                  r12 = r13
                else
                  r12 = instantiate_node(SyntaxNode,input, index...index)
                end
                s0 << r12
              end
            end
          end
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(QuotedString1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:quoted_string][start_index] = r0

      r0
    end

    def _nt_qcontent
      start_index = index
      if node_cache[:qcontent].has_key?(index)
        cached = node_cache[:qcontent][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_qtext
      if r1
        r0 = r1
      else
        r2 = _nt_quoted_pair
        if r2
          r0 = r2
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:qcontent][start_index] = r0

      r0
    end

    module QuotedPair0
      def text
        elements[1]
      end
    end

    def _nt_quoted_pair
      start_index = index
      if node_cache[:quoted_pair].has_key?(index)
        cached = node_cache[:quoted_pair][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      if has_terminal?("\\", false, index)
        r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure("\\")
        r2 = nil
      end
      s1 << r2
      if r2
        r3 = _nt_text
        s1 << r3
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(QuotedPair0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r4 = _nt_obs_qp
        if r4
          r0 = r4
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:quoted_pair][start_index] = r0

      r0
    end

    def _nt_qtext
      start_index = index
      if node_cache[:qtext].has_key?(index)
        cached = node_cache[:qtext][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_NO_WS_CTL
      if r1
        r0 = r1
      else
        if has_terminal?('\G[\\x21]', true, index)
          r2 = true
          @index += 1
        else
          r2 = nil
        end
        if r2
          r0 = r2
        else
          if has_terminal?('\G[\\x23-\\x5b]', true, index)
            r3 = true
            @index += 1
          else
            r3 = nil
          end
          if r3
            r0 = r3
          else
            if has_terminal?('\G[\\x5d-\\x7e]', true, index)
              r4 = true
              @index += 1
            else
              r4 = nil
            end
            if r4
              r0 = r4
            else
              @index = i0
              r0 = nil
            end
          end
        end
      end

      node_cache[:qtext][start_index] = r0

      r0
    end

    def _nt_text
      start_index = index
      if node_cache[:text].has_key?(index)
        cached = node_cache[:text][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      if has_terminal?('\G[\\x01-\\x09]', true, index)
        r1 = true
        @index += 1
      else
        r1 = nil
      end
      if r1
        r0 = r1
      else
        if has_terminal?('\G[\\x0b-\\x0c]', true, index)
          r2 = true
          @index += 1
        else
          r2 = nil
        end
        if r2
          r0 = r2
        else
          if has_terminal?('\G[\\x0e-\\x7e]', true, index)
            r3 = true
            @index += 1
          else
            r3 = nil
          end
          if r3
            r0 = r3
          else
            r4 = _nt_obs_text
            if r4
              r0 = r4
            else
              @index = i0
              r0 = nil
            end
          end
        end
      end

      node_cache[:text][start_index] = r0

      r0
    end

    def _nt_display_name
      start_index = index
      if node_cache[:display_name].has_key?(index)
        cached = node_cache[:display_name][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      r0 = _nt_phrase

      node_cache[:display_name][start_index] = r0

      r0
    end

    module NameAddr0
      def display_name
        elements[0]
      end

      def angle_addr
        elements[1]
      end
    end

    def _nt_name_addr
      start_index = index
      if node_cache[:name_addr].has_key?(index)
        cached = node_cache[:name_addr][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r2 = _nt_display_name
      s1 << r2
      if r2
        r3 = _nt_angle_addr
        s1 << r3
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(NameAddr0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r4 = _nt_angle_addr
        if r4
          r0 = r4
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:name_addr][start_index] = r0

      r0
    end

    module MailboxList0
      def addr_value
        elements[1]
      end
    end

    module MailboxList1
      def first_addr
        elements[0]
      end

      def other_addr
        elements[1]
      end
    end

    def _nt_mailbox_list
      start_index = index
      if node_cache[:mailbox_list].has_key?(index)
        cached = node_cache[:mailbox_list][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r2 = _nt_mailbox
      s1 << r2
      if r2
        s3, i3 = [], index
        loop do
          i4, s4 = index, []
          i5 = index
          if has_terminal?(",", false, index)
            r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure(",")
            r6 = nil
          end
          if r6
            r5 = r6
          else
            if has_terminal?(";", false, index)
              r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure(";")
              r7 = nil
            end
            if r7
              r5 = r7
            else
              @index = i5
              r5 = nil
            end
          end
          s4 << r5
          if r5
            r8 = _nt_mailbox
            s4 << r8
          end
          if s4.last
            r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
            r4.extend(MailboxList0)
          else
            @index = i4
            r4 = nil
          end
          if r4
            s3 << r4
          else
            break
          end
        end
        r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        s1 << r3
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(MailboxList1)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r9 = _nt_obs_mbox_list
        if r9
          r0 = r9
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:mailbox_list][start_index] = r0

      r0
    end

    module Mailbox0
      def dig_comments(comments, elements)
        elements.each { |elem|
          if elem.respond_to?(:comment)
            comments << elem.comment
          end
          dig_comments(comments, elem.elements) if elem.elements
         }
      end

      def comments
        comments = []
        dig_comments(comments, elements)
        comments
      end
    end

    def _nt_mailbox
      start_index = index
      if node_cache[:mailbox].has_key?(index)
        cached = node_cache[:mailbox][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_name_addr
      if r1
        r0 = r1
        r0.extend(Mailbox0)
      else
        r2 = _nt_addr_spec
        if r2
          r0 = r2
          r0.extend(Mailbox0)
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:mailbox][start_index] = r0

      r0
    end

    module Address0
  
      def dig_comments(comments, elements)
        elements.each { |elem|
          if elem.respond_to?(:comment)
            comments << elem.comment
          end
          dig_comments(comments, elem.elements) if elem.elements
         }
      end
  
      def comments
        comments = []
        dig_comments(comments, elements)
        comments
      end
    end

    def _nt_address
      start_index = index
      if node_cache[:address].has_key?(index)
        cached = node_cache[:address][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_group
      r1.extend(Address0)
      if r1
        r0 = r1
      else
        r2 = _nt_mailbox
        if r2
          r0 = r2
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:address][start_index] = r0

      r0
    end

    module AddressList0
      def addr_value
        elements[3]
      end
    end

    module AddressList1
      def first_addr
        elements[0]
      end

      def other_addr
        elements[1]
      end
    end

    def _nt_address_list
      start_index = index
      if node_cache[:address_list].has_key?(index)
        cached = node_cache[:address_list][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r2 = _nt_address
      if r2
        r1 = r2
      else
        r1 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r1
      if r1
        s3, i3 = [], index
        loop do
          i4, s4 = index, []
          s5, i5 = [], index
          loop do
            r6 = _nt_FWS
            if r6
              s5 << r6
            else
              break
            end
          end
          r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
          s4 << r5
          if r5
            i7 = index
            if has_terminal?(",", false, index)
              r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure(",")
              r8 = nil
            end
            if r8
              r7 = r8
            else
              if has_terminal?(";", false, index)
                r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
                @index += 1
              else
                terminal_parse_failure(";")
                r9 = nil
              end
              if r9
                r7 = r9
              else
                @index = i7
                r7 = nil
              end
            end
            s4 << r7
            if r7
              s10, i10 = [], index
              loop do
                r11 = _nt_FWS
                if r11
                  s10 << r11
                else
                  break
                end
              end
              r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
              s4 << r10
              if r10
                r13 = _nt_address
                if r13
                  r12 = r13
                else
                  r12 = instantiate_node(SyntaxNode,input, index...index)
                end
                s4 << r12
              end
            end
          end
          if s4.last
            r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
            r4.extend(AddressList0)
          else
            @index = i4
            r4 = nil
          end
          if r4
            s3 << r4
          else
            break
          end
        end
        r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        s0 << r3
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(AddressList1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:address_list][start_index] = r0

      r0
    end

    module DateTime0
      def day_of_week
        elements[0]
      end

    end

    module DateTime1
      def date
        elements[1]
      end

      def FWS
        elements[2]
      end

      def time
        elements[3]
      end

    end

    def _nt_date_time
      start_index = index
      if node_cache[:date_time].has_key?(index)
        cached = node_cache[:date_time][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      i2, s2 = index, []
      r3 = _nt_day_of_week
      s2 << r3
      if r3
        if has_terminal?(",", false, index)
          r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure(",")
          r4 = nil
        end
        s2 << r4
      end
      if s2.last
        r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        r2.extend(DateTime0)
      else
        @index = i2
        r2 = nil
      end
      if r2
        r1 = r2
      else
        r1 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r1
      if r1
        r5 = _nt_date
        s0 << r5
        if r5
          r6 = _nt_FWS
          s0 << r6
          if r6
            r7 = _nt_time
            s0 << r7
            if r7
              r9 = _nt_CFWS
              if r9
                r8 = r9
              else
                r8 = instantiate_node(SyntaxNode,input, index...index)
              end
              s0 << r8
            end
          end
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(DateTime1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:date_time][start_index] = r0

      r0
    end

    module DayOfWeek0
      def day_name
        elements[1]
      end
    end

    def _nt_day_of_week
      start_index = index
      if node_cache[:day_of_week].has_key?(index)
        cached = node_cache[:day_of_week][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r3 = _nt_FWS
      if r3
        r2 = r3
      else
        r2 = instantiate_node(SyntaxNode,input, index...index)
      end
      s1 << r2
      if r2
        r4 = _nt_day_name
        s1 << r4
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(DayOfWeek0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r5 = _nt_obs_day_of_week
        if r5
          r0 = r5
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:day_of_week][start_index] = r0

      r0
    end

    def _nt_day_name
      start_index = index
      if node_cache[:day_name].has_key?(index)
        cached = node_cache[:day_name][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      if has_terminal?("Mon", false, index)
        r1 = instantiate_node(SyntaxNode,input, index...(index + 3))
        @index += 3
      else
        terminal_parse_failure("Mon")
        r1 = nil
      end
      if r1
        r0 = r1
      else
        if has_terminal?("Tue", false, index)
          r2 = instantiate_node(SyntaxNode,input, index...(index + 3))
          @index += 3
        else
          terminal_parse_failure("Tue")
          r2 = nil
        end
        if r2
          r0 = r2
        else
          if has_terminal?("Wed", false, index)
            r3 = instantiate_node(SyntaxNode,input, index...(index + 3))
            @index += 3
          else
            terminal_parse_failure("Wed")
            r3 = nil
          end
          if r3
            r0 = r3
          else
            if has_terminal?("Thu", false, index)
              r4 = instantiate_node(SyntaxNode,input, index...(index + 3))
              @index += 3
            else
              terminal_parse_failure("Thu")
              r4 = nil
            end
            if r4
              r0 = r4
            else
              if has_terminal?("Fri", false, index)
                r5 = instantiate_node(SyntaxNode,input, index...(index + 3))
                @index += 3
              else
                terminal_parse_failure("Fri")
                r5 = nil
              end
              if r5
                r0 = r5
              else
                if has_terminal?("Sat", false, index)
                  r6 = instantiate_node(SyntaxNode,input, index...(index + 3))
                  @index += 3
                else
                  terminal_parse_failure("Sat")
                  r6 = nil
                end
                if r6
                  r0 = r6
                else
                  if has_terminal?("Sun", false, index)
                    r7 = instantiate_node(SyntaxNode,input, index...(index + 3))
                    @index += 3
                  else
                    terminal_parse_failure("Sun")
                    r7 = nil
                  end
                  if r7
                    r0 = r7
                  else
                    @index = i0
                    r0 = nil
                  end
                end
              end
            end
          end
        end
      end

      node_cache[:day_name][start_index] = r0

      r0
    end

    module Date0
      def day
        elements[0]
      end

      def month
        elements[1]
      end

      def year
        elements[2]
      end
    end

    def _nt_date
      start_index = index
      if node_cache[:date].has_key?(index)
        cached = node_cache[:date][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r1 = _nt_day
      s0 << r1
      if r1
        r2 = _nt_month
        s0 << r2
        if r2
          r3 = _nt_year
          s0 << r3
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(Date0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:date][start_index] = r0

      r0
    end

    module Year0
      def DIGIT1
        elements[0]
      end

      def DIGIT2
        elements[1]
      end

      def DIGIT3
        elements[2]
      end

      def DIGIT4
        elements[3]
      end
    end

    def _nt_year
      start_index = index
      if node_cache[:year].has_key?(index)
        cached = node_cache[:year][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r2 = _nt_DIGIT
      s1 << r2
      if r2
        r3 = _nt_DIGIT
        s1 << r3
        if r3
          r4 = _nt_DIGIT
          s1 << r4
          if r4
            r5 = _nt_DIGIT
            s1 << r5
          end
        end
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(Year0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r6 = _nt_obs_year
        if r6
          r0 = r6
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:year][start_index] = r0

      r0
    end

    module Month0
      def FWS1
        elements[0]
      end

      def month_name
        elements[1]
      end

      def FWS2
        elements[2]
      end
    end

    def _nt_month
      start_index = index
      if node_cache[:month].has_key?(index)
        cached = node_cache[:month][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r2 = _nt_FWS
      s1 << r2
      if r2
        r3 = _nt_month_name
        s1 << r3
        if r3
          r4 = _nt_FWS
          s1 << r4
        end
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(Month0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r5 = _nt_obs_month
        if r5
          r0 = r5
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:month][start_index] = r0

      r0
    end

    def _nt_month_name
      start_index = index
      if node_cache[:month_name].has_key?(index)
        cached = node_cache[:month_name][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      if has_terminal?("Jan", false, index)
        r1 = instantiate_node(SyntaxNode,input, index...(index + 3))
        @index += 3
      else
        terminal_parse_failure("Jan")
        r1 = nil
      end
      if r1
        r0 = r1
      else
        if has_terminal?("Feb", false, index)
          r2 = instantiate_node(SyntaxNode,input, index...(index + 3))
          @index += 3
        else
          terminal_parse_failure("Feb")
          r2 = nil
        end
        if r2
          r0 = r2
        else
          if has_terminal?("Mar", false, index)
            r3 = instantiate_node(SyntaxNode,input, index...(index + 3))
            @index += 3
          else
            terminal_parse_failure("Mar")
            r3 = nil
          end
          if r3
            r0 = r3
          else
            if has_terminal?("Apr", false, index)
              r4 = instantiate_node(SyntaxNode,input, index...(index + 3))
              @index += 3
            else
              terminal_parse_failure("Apr")
              r4 = nil
            end
            if r4
              r0 = r4
            else
              if has_terminal?("May", false, index)
                r5 = instantiate_node(SyntaxNode,input, index...(index + 3))
                @index += 3
              else
                terminal_parse_failure("May")
                r5 = nil
              end
              if r5
                r0 = r5
              else
                if has_terminal?("Jun", false, index)
                  r6 = instantiate_node(SyntaxNode,input, index...(index + 3))
                  @index += 3
                else
                  terminal_parse_failure("Jun")
                  r6 = nil
                end
                if r6
                  r0 = r6
                else
                  if has_terminal?("Jul", false, index)
                    r7 = instantiate_node(SyntaxNode,input, index...(index + 3))
                    @index += 3
                  else
                    terminal_parse_failure("Jul")
                    r7 = nil
                  end
                  if r7
                    r0 = r7
                  else
                    if has_terminal?("Aug", false, index)
                      r8 = instantiate_node(SyntaxNode,input, index...(index + 3))
                      @index += 3
                    else
                      terminal_parse_failure("Aug")
                      r8 = nil
                    end
                    if r8
                      r0 = r8
                    else
                      if has_terminal?("Sep", false, index)
                        r9 = instantiate_node(SyntaxNode,input, index...(index + 3))
                        @index += 3
                      else
                        terminal_parse_failure("Sep")
                        r9 = nil
                      end
                      if r9
                        r0 = r9
                      else
                        if has_terminal?("Oct", false, index)
                          r10 = instantiate_node(SyntaxNode,input, index...(index + 3))
                          @index += 3
                        else
                          terminal_parse_failure("Oct")
                          r10 = nil
                        end
                        if r10
                          r0 = r10
                        else
                          if has_terminal?("Nov", false, index)
                            r11 = instantiate_node(SyntaxNode,input, index...(index + 3))
                            @index += 3
                          else
                            terminal_parse_failure("Nov")
                            r11 = nil
                          end
                          if r11
                            r0 = r11
                          else
                            if has_terminal?("Dec", false, index)
                              r12 = instantiate_node(SyntaxNode,input, index...(index + 3))
                              @index += 3
                            else
                              terminal_parse_failure("Dec")
                              r12 = nil
                            end
                            if r12
                              r0 = r12
                            else
                              @index = i0
                              r0 = nil
                            end
                          end
                        end
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end

      node_cache[:month_name][start_index] = r0

      r0
    end

    module Day0
      def DIGIT
        elements[1]
      end

    end

    def _nt_day
      start_index = index
      if node_cache[:day].has_key?(index)
        cached = node_cache[:day][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r3 = _nt_FWS
      if r3
        r2 = r3
      else
        r2 = instantiate_node(SyntaxNode,input, index...index)
      end
      s1 << r2
      if r2
        r4 = _nt_DIGIT
        s1 << r4
        if r4
          r6 = _nt_DIGIT
          if r6
            r5 = r6
          else
            r5 = instantiate_node(SyntaxNode,input, index...index)
          end
          s1 << r5
        end
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(Day0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r7 = _nt_obs_day
        if r7
          r0 = r7
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:day][start_index] = r0

      r0
    end

    module Time0
      def time_of_day
        elements[0]
      end

      def FWS
        elements[1]
      end

      def zone
        elements[2]
      end
    end

    def _nt_time
      start_index = index
      if node_cache[:time].has_key?(index)
        cached = node_cache[:time][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r1 = _nt_time_of_day
      s0 << r1
      if r1
        r2 = _nt_FWS
        s0 << r2
        if r2
          r3 = _nt_zone
          s0 << r3
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(Time0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:time][start_index] = r0

      r0
    end

    module TimeOfDay0
      def second
        elements[1]
      end
    end

    module TimeOfDay1
      def hour
        elements[0]
      end

      def minute
        elements[2]
      end

    end

    def _nt_time_of_day
      start_index = index
      if node_cache[:time_of_day].has_key?(index)
        cached = node_cache[:time_of_day][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r1 = _nt_hour
      s0 << r1
      if r1
        if has_terminal?(":", false, index)
          r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure(":")
          r2 = nil
        end
        s0 << r2
        if r2
          r3 = _nt_minute
          s0 << r3
          if r3
            i5, s5 = index, []
            if has_terminal?(":", false, index)
              r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure(":")
              r6 = nil
            end
            s5 << r6
            if r6
              r7 = _nt_second
              s5 << r7
            end
            if s5.last
              r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
              r5.extend(TimeOfDay0)
            else
              @index = i5
              r5 = nil
            end
            if r5
              r4 = r5
            else
              r4 = instantiate_node(SyntaxNode,input, index...index)
            end
            s0 << r4
          end
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(TimeOfDay1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:time_of_day][start_index] = r0

      r0
    end

    module Hour0
      def DIGIT1
        elements[0]
      end

      def DIGIT2
        elements[1]
      end
    end

    def _nt_hour
      start_index = index
      if node_cache[:hour].has_key?(index)
        cached = node_cache[:hour][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r2 = _nt_DIGIT
      s1 << r2
      if r2
        r3 = _nt_DIGIT
        s1 << r3
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(Hour0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r4 = _nt_obs_hour
        if r4
          r0 = r4
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:hour][start_index] = r0

      r0
    end

    module Minute0
      def DIGIT1
        elements[0]
      end

      def DIGIT2
        elements[1]
      end
    end

    def _nt_minute
      start_index = index
      if node_cache[:minute].has_key?(index)
        cached = node_cache[:minute][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r2 = _nt_DIGIT
      s1 << r2
      if r2
        r3 = _nt_DIGIT
        s1 << r3
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(Minute0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r4 = _nt_obs_minute
        if r4
          r0 = r4
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:minute][start_index] = r0

      r0
    end

    module Second0
      def DIGIT1
        elements[0]
      end

      def DIGIT2
        elements[1]
      end
    end

    def _nt_second
      start_index = index
      if node_cache[:second].has_key?(index)
        cached = node_cache[:second][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r2 = _nt_DIGIT
      s1 << r2
      if r2
        r3 = _nt_DIGIT
        s1 << r3
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(Second0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r4 = _nt_obs_second
        if r4
          r0 = r4
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:second][start_index] = r0

      r0
    end

    module Zone0
      def DIGIT1
        elements[1]
      end

      def DIGIT2
        elements[2]
      end

      def DIGIT3
        elements[3]
      end

      def DIGIT4
        elements[4]
      end
    end

    def _nt_zone
      start_index = index
      if node_cache[:zone].has_key?(index)
        cached = node_cache[:zone][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      i2 = index
      if has_terminal?("+", false, index)
        r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure("+")
        r3 = nil
      end
      if r3
        r2 = r3
      else
        if has_terminal?("-", false, index)
          r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("-")
          r4 = nil
        end
        if r4
          r2 = r4
        else
          @index = i2
          r2 = nil
        end
      end
      s1 << r2
      if r2
        r5 = _nt_DIGIT
        s1 << r5
        if r5
          r6 = _nt_DIGIT
          s1 << r6
          if r6
            r7 = _nt_DIGIT
            s1 << r7
            if r7
              r8 = _nt_DIGIT
              s1 << r8
            end
          end
        end
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(Zone0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r9 = _nt_obs_zone
        if r9
          r0 = r9
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:zone][start_index] = r0

      r0
    end

    module Return0
      def path
        elements[0]
      end

      def CRLF
        elements[1]
      end
    end

    def _nt_return
      start_index = index
      if node_cache[:return].has_key?(index)
        cached = node_cache[:return][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r1 = _nt_path
      s0 << r1
      if r1
        r2 = _nt_CRLF
        s0 << r2
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(Return0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:return][start_index] = r0

      r0
    end

    module Path0
    end

    def _nt_path
      start_index = index
      if node_cache[:path].has_key?(index)
        cached = node_cache[:path][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r3 = _nt_CFWS
      if r3
        r2 = r3
      else
        r2 = instantiate_node(SyntaxNode,input, index...index)
      end
      s1 << r2
      if r2
        if has_terminal?("<", false, index)
          r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("<")
          r4 = nil
        end
        s1 << r4
        if r4
          i5 = index
          r7 = _nt_CFWS
          if r7
            r6 = r7
          else
            r6 = instantiate_node(SyntaxNode,input, index...index)
          end
          if r6
            r5 = r6
          else
            r8 = _nt_addr_spec
            if r8
              r5 = r8
            else
              @index = i5
              r5 = nil
            end
          end
          s1 << r5
          if r5
            if has_terminal?(">", false, index)
              r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure(">")
              r9 = nil
            end
            s1 << r9
            if r9
              r11 = _nt_CFWS
              if r11
                r10 = r11
              else
                r10 = instantiate_node(SyntaxNode,input, index...index)
              end
              s1 << r10
            end
          end
        end
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(Path0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        r12 = _nt_obs_path
        if r12
          r0 = r12
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:path][start_index] = r0

      r0
    end

    module Received0
      def name_val_list
        elements[0]
      end

      def date_time
        elements[2]
      end

      def CRLF
        elements[3]
      end
    end

    def _nt_received
      start_index = index
      if node_cache[:received].has_key?(index)
        cached = node_cache[:received][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r1 = _nt_name_val_list
      s0 << r1
      if r1
        if has_terminal?(";", false, index)
          r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure(";")
          r2 = nil
        end
        s0 << r2
        if r2
          r3 = _nt_date_time
          s0 << r3
          if r3
            r4 = _nt_CRLF
            s0 << r4
          end
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(Received0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:received][start_index] = r0

      r0
    end

    module NameValList0
      def CFWS
        elements[0]
      end

      def name_val_pair
        elements[1]
      end
    end

    module NameValList1
      def name_val_pair
        elements[0]
      end

    end

    module NameValList2
    end

    def _nt_name_val_list
      start_index = index
      if node_cache[:name_val_list].has_key?(index)
        cached = node_cache[:name_val_list][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r2 = _nt_CFWS
      if r2
        r1 = r2
      else
        r1 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r1
      if r1
        i4, s4 = index, []
        r5 = _nt_name_val_pair
        s4 << r5
        if r5
          s6, i6 = [], index
          loop do
            i7, s7 = index, []
            r8 = _nt_CFWS
            s7 << r8
            if r8
              r9 = _nt_name_val_pair
              s7 << r9
            end
            if s7.last
              r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
              r7.extend(NameValList0)
            else
              @index = i7
              r7 = nil
            end
            if r7
              s6 << r7
            else
              break
            end
          end
          r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
          s4 << r6
        end
        if s4.last
          r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
          r4.extend(NameValList1)
        else
          @index = i4
          r4 = nil
        end
        if r4
          r3 = r4
        else
          r3 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r3
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(NameValList2)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:name_val_list][start_index] = r0

      r0
    end

    module NameValPair0
      def item_name
        elements[0]
      end

      def CFWS
        elements[1]
      end

      def item_value
        elements[2]
      end
    end

    def _nt_name_val_pair
      start_index = index
      if node_cache[:name_val_pair].has_key?(index)
        cached = node_cache[:name_val_pair][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r1 = _nt_item_name
      s0 << r1
      if r1
        r2 = _nt_CFWS
        s0 << r2
        if r2
          r3 = _nt_item_value
          s0 << r3
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(NameValPair0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:name_val_pair][start_index] = r0

      r0
    end

    module ItemName0
    end

    module ItemName1
      def ALPHA
        elements[0]
      end

    end

    def _nt_item_name
      start_index = index
      if node_cache[:item_name].has_key?(index)
        cached = node_cache[:item_name][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r1 = _nt_ALPHA
      s0 << r1
      if r1
        s2, i2 = [], index
        loop do
          i3, s3 = index, []
          if has_terminal?("-", false, index)
            r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure("-")
            r5 = nil
          end
          if r5
            r4 = r5
          else
            r4 = instantiate_node(SyntaxNode,input, index...index)
          end
          s3 << r4
          if r4
            i6 = index
            r7 = _nt_ALPHA
            if r7
              r6 = r7
            else
              r8 = _nt_DIGIT
              if r8
                r6 = r8
              else
                @index = i6
                r6 = nil
              end
            end
            s3 << r6
          end
          if s3.last
            r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
            r3.extend(ItemName0)
          else
            @index = i3
            r3 = nil
          end
          if r3
            s2 << r3
          else
            break
          end
        end
        r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        s0 << r2
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(ItemName1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:item_name][start_index] = r0

      r0
    end

    def _nt_item_value
      start_index = index
      if node_cache[:item_value].has_key?(index)
        cached = node_cache[:item_value][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      s1, i1 = [], index
      loop do
        r2 = _nt_angle_addr
        if r2
          s1 << r2
        else
          break
        end
      end
      if s1.empty?
        @index = i1
        r1 = nil
      else
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
      end
      if r1
        r0 = r1
      else
        r3 = _nt_addr_spec
        if r3
          r0 = r3
        else
          r4 = _nt_atom
          if r4
            r0 = r4
          else
            r5 = _nt_domain
            if r5
              r0 = r5
            else
              r6 = _nt_msg_id
              if r6
                r0 = r6
              else
                @index = i0
                r0 = nil
              end
            end
          end
        end
      end

      node_cache[:item_value][start_index] = r0

      r0
    end

    module MessageIds0
      def CFWS
        elements[0]
      end

      def msg_id_value
        elements[1]
      end
    end

    module MessageIds1
      def first_msg_id
        elements[0]
      end

      def other_msg_ids
        elements[1]
      end
    end

    def _nt_message_ids
      start_index = index
      if node_cache[:message_ids].has_key?(index)
        cached = node_cache[:message_ids][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r1 = _nt_msg_id
      s0 << r1
      if r1
        s2, i2 = [], index
        loop do
          i3, s3 = index, []
          r4 = _nt_CFWS
          s3 << r4
          if r4
            r5 = _nt_msg_id
            s3 << r5
          end
          if s3.last
            r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
            r3.extend(MessageIds0)
          else
            @index = i3
            r3 = nil
          end
          if r3
            s2 << r3
          else
            break
          end
        end
        r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        s0 << r2
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(MessageIds1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:message_ids][start_index] = r0

      r0
    end

    module MsgId0
      def msg_id_value
        elements[2]
      end

    end

    def _nt_msg_id
      start_index = index
      if node_cache[:msg_id].has_key?(index)
        cached = node_cache[:msg_id][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r2 = _nt_CFWS
      if r2
        r1 = r2
      else
        r1 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r1
      if r1
        if has_terminal?("<", false, index)
          r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("<")
          r3 = nil
        end
        s0 << r3
        if r3
          r4 = _nt_msg_id_value
          s0 << r4
          if r4
            if has_terminal?(">", false, index)
              r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure(">")
              r5 = nil
            end
            s0 << r5
            if r5
              r7 = _nt_CFWS
              if r7
                r6 = r7
              else
                r6 = instantiate_node(SyntaxNode,input, index...index)
              end
              s0 << r6
            end
          end
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(MsgId0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:msg_id][start_index] = r0

      r0
    end

    module MsgIdValue0
      def id_left
        elements[0]
      end

      def id_right
        elements[2]
      end
    end

    def _nt_msg_id_value
      start_index = index
      if node_cache[:msg_id_value].has_key?(index)
        cached = node_cache[:msg_id_value][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r1 = _nt_id_left
      s0 << r1
      if r1
        if has_terminal?("@", false, index)
          r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
          @index += 1
        else
          terminal_parse_failure("@")
          r2 = nil
        end
        s0 << r2
        if r2
          r3 = _nt_id_right
          s0 << r3
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(MsgIdValue0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:msg_id_value][start_index] = r0

      r0
    end

    def _nt_id_left
      start_index = index
      if node_cache[:id_left].has_key?(index)
        cached = node_cache[:id_left][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_message_id_text
      if r1
        r0 = r1
      else
        r2 = _nt_no_fold_quote
        if r2
          r0 = r2
        else
          r3 = _nt_obs_id_left
          if r3
            r0 = r3
          else
            @index = i0
            r0 = nil
          end
        end
      end

      node_cache[:id_left][start_index] = r0

      r0
    end

    def _nt_id_right
      start_index = index
      if node_cache[:id_right].has_key?(index)
        cached = node_cache[:id_right][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_msg_id_dot_atom_text
      if r1
        r0 = r1
      else
        r2 = _nt_no_fold_literal
        if r2
          r0 = r2
        else
          r3 = _nt_obs_id_right
          if r3
            r0 = r3
          else
            @index = i0
            r0 = nil
          end
        end
      end

      node_cache[:id_right][start_index] = r0

      r0
    end

    module MsgIdDotAtomText0
      def msg_id_domain_text
        elements[0]
      end

    end

    def _nt_msg_id_dot_atom_text
      start_index = index
      if node_cache[:msg_id_dot_atom_text].has_key?(index)
        cached = node_cache[:msg_id_dot_atom_text][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      s0, i0 = [], index
      loop do
        i1, s1 = index, []
        r2 = _nt_msg_id_domain_text
        s1 << r2
        if r2
          if has_terminal?(".", false, index)
            r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure(".")
            r4 = nil
          end
          if r4
            r3 = r4
          else
            r3 = instantiate_node(SyntaxNode,input, index...index)
          end
          s1 << r3
        end
        if s1.last
          r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
          r1.extend(MsgIdDotAtomText0)
        else
          @index = i1
          r1 = nil
        end
        if r1
          s0 << r1
        else
          break
        end
      end
      if s0.empty?
        @index = i0
        r0 = nil
      else
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      end

      node_cache[:msg_id_dot_atom_text][start_index] = r0

      r0
    end

    module MsgIdDomainText0
      def quoted_domain
        elements[1]
      end
    end

    module MsgIdDomainText1
      def DQUOTE1
        elements[0]
      end

      def DQUOTE2
        elements[3]
      end
    end

    def _nt_msg_id_domain_text
      start_index = index
      if node_cache[:msg_id_domain_text].has_key?(index)
        cached = node_cache[:msg_id_domain_text][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      i1, s1 = index, []
      r2 = _nt_DQUOTE
      s1 << r2
      if r2
        s3, i3 = [], index
        loop do
          i4, s4 = index, []
          r6 = _nt_FWS
          if r6
            r5 = r6
          else
            r5 = instantiate_node(SyntaxNode,input, index...index)
          end
          s4 << r5
          if r5
            r7 = _nt_quoted_domain
            s4 << r7
          end
          if s4.last
            r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
            r4.extend(MsgIdDomainText0)
          else
            @index = i4
            r4 = nil
          end
          if r4
            s3 << r4
          else
            break
          end
        end
        if s3.empty?
          @index = i3
          r3 = nil
        else
          r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        end
        s1 << r3
        if r3
          r9 = _nt_FWS
          if r9
            r8 = r9
          else
            r8 = instantiate_node(SyntaxNode,input, index...index)
          end
          s1 << r8
          if r8
            r10 = _nt_DQUOTE
            s1 << r10
          end
        end
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(MsgIdDomainText1)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r0 = r1
      else
        s11, i11 = [], index
        loop do
          r12 = _nt_msg_id_atext
          if r12
            s11 << r12
          else
            break
          end
        end
        if s11.empty?
          @index = i11
          r11 = nil
        else
          r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
        end
        if r11
          r0 = r11
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:msg_id_domain_text][start_index] = r0

      r0
    end

    def _nt_msg_id_atext
      start_index = index
      if node_cache[:msg_id_atext].has_key?(index)
        cached = node_cache[:msg_id_atext][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0 = index
      r1 = _nt_ALPHA
      if r1
        r0 = r1
      else
        r2 = _nt_DIGIT
        if r2
          r0 = r2
        else
          if has_terminal?("!", false, index)
            r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure("!")
            r3 = nil
          end
          if r3
            r0 = r3
          else
            if has_terminal?("#", false, index)
              r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
              @index += 1
            else
              terminal_parse_failure("#")
              r4 = nil
            end
            if r4
              r0 = r4
            else
              if has_terminal?("$", false, index)
                r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
                @index += 1
              else
                terminal_parse_failure("$")
                r5 = nil
              end
              if r5
                r0 = r5
              else
                if has_terminal?("%", false, index)
                  r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
                  @index += 1
                else
                  terminal_parse_failure("%")
                  r6 = nil
                end
                if r6
                  r0 = r6
                else
                  if has_terminal?("&", false, index)
                    r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
                    @index += 1
                  else
                    terminal_parse_failure("&")
                    r7 = nil
                  end
                  if r7
                    r0 = r7
                  else
                    if has_terminal?("'", false, index)
                      r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
                      @index += 1
                    else
                      terminal_parse_failure("'")
                      r8 = nil
                    end
                    if r8
                      r0 = r8
                    else
                      if has_terminal?("*", false, index)
                        r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
                        @index += 1
                      else
                        terminal_parse_failure("*")
                        r9 = nil
                      end
                      if r9
                        r0 = r9
                      else
                        if has_terminal?("+", false, index)
                          r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
                          @index += 1
                        else
                          terminal_parse_failure("+")
                          r10 = nil
                        end
                        if r10
                          r0 = r10
                        else
                          if has_terminal?("-", false, index)
                            r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
                            @index += 1
                          else
                            terminal_parse_failure("-")
                            r11 = nil
                          end
                          if r11
                            r0 = r11
                          else
                            if has_terminal?("/", false, index)
                              r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
                              @index += 1
                            else
                              terminal_parse_failure("/")
                              r12 = nil
                            end
                            if r12
                              r0 = r12
                            else
                              if has_terminal?("=", false, index)
                                r13 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                @index += 1
                              else
                                terminal_parse_failure("=")
                                r13 = nil
                              end
                              if r13
                                r0 = r13
                              else
                                if has_terminal?("?", false, index)
                                  r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                  @index += 1
                                else
                                  terminal_parse_failure("?")
                                  r14 = nil
                                end
                                if r14
                                  r0 = r14
                                else
                                  if has_terminal?("^", false, index)
                                    r15 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                    @index += 1
                                  else
                                    terminal_parse_failure("^")
                                    r15 = nil
                                  end
                                  if r15
                                    r0 = r15
                                  else
                                    if has_terminal?("_", false, index)
                                      r16 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                      @index += 1
                                    else
                                      terminal_parse_failure("_")
                                      r16 = nil
                                    end
                                    if r16
                                      r0 = r16
                                    else
                                      if has_terminal?("`", false, index)
                                        r17 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                        @index += 1
                                      else
                                        terminal_parse_failure("`")
                                        r17 = nil
                                      end
                                      if r17
                                        r0 = r17
                                      else
                                        if has_terminal?("{", false, index)
                                          r18 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                          @index += 1
                                        else
                                          terminal_parse_failure("{")
                                          r18 = nil
                                        end
                                        if r18
                                          r0 = r18
                                        else
                                          if has_terminal?("|", false, index)
                                            r19 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                            @index += 1
                                          else
                                            terminal_parse_failure("|")
                                            r19 = nil
                                          end
                                          if r19
                                            r0 = r19
                                          else
                                            if has_terminal?("}", false, index)
                                              r20 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                              @index += 1
                                            else
                                              terminal_parse_failure("}")
                                              r20 = nil
                                            end
                                            if r20
                                              r0 = r20
                                            else
                                              if has_terminal?("~", false, index)
                                                r21 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                                @index += 1
                                              else
                                                terminal_parse_failure("~")
                                                r21 = nil
                                              end
                                              if r21
                                                r0 = r21
                                              else
                                                if has_terminal?("@", false, index)
                                                  r22 = instantiate_node(SyntaxNode,input, index...(index + 1))
                                                  @index += 1
                                                else
                                                  terminal_parse_failure("@")
                                                  r22 = nil
                                                end
                                                if r22
                                                  r0 = r22
                                                else
                                                  @index = i0
                                                  r0 = nil
                                                end
                                              end
                                            end
                                          end
                                        end
                                      end
                                    end
                                  end
                                end
                              end
                            end
                          end
                        end
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end

      node_cache[:msg_id_atext][start_index] = r0

      r0
    end

    module NoFoldQuote0
      def DQUOTE1
        elements[0]
      end

      def DQUOTE2
        elements[2]
      end
    end

    def _nt_no_fold_quote
      start_index = index
      if node_cache[:no_fold_quote].has_key?(index)
        cached = node_cache[:no_fold_quote][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      r1 = _nt_DQUOTE
      s0 << r1
      if r1
        s2, i2 = [], index
        loop do
          i3 = index
          r4 = _nt_qtext
          if r4
            r3 = r4
          else
            r5 = _nt_quoted_pair
            if r5
              r3 = r5
            else
              @index = i3
              r3 = nil
            end
          end
          if r3
            s2 << r3
          else
            break
          end
        end
        if s2.empty?
          @index = i2
          r2 = nil
        else
          r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        end
        s0 << r2
        if r2
          r6 = _nt_DQUOTE
          s0 << r6
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(NoFoldQuote0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:no_fold_quote][start_index] = r0

      r0
    end

    module NoFoldLiteral0
    end

    def _nt_no_fold_literal
      start_index = index
      if node_cache[:no_fold_literal].has_key?(index)
        cached = node_cache[:no_fold_literal][index]
        if cached
          cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
          @index = cached.interval.end
        end
        return cached
      end

      i0, s0 = index, []
      if has_terminal?("[", false, index)
        r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
        @index += 1
      else
        terminal_parse_failure("[")
        r1 = nil
      end
      s0 << r1
      if r1
        s2, i2 = [], index
        loop do
          i3 = index
          r4 = _nt_dtext
          if r4
            r3 = r4
          else
            r5 = _nt_quoted_pair
            if r5
              r3 = r5
            else
              @index = i3
              r3 = nil
            end
          end
          if r3
            s2 << r3
          else
            break
          end
        end
        if s2.empty?
          @index = i2
          r2 = nil
        else
          r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        end
        s0 << r2
        if r2
          if has_terminal?("]", false, index)
            r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
            @index += 1
          else
            terminal_parse_failure("]")
            r6 = nil
          end
          s0 << r6
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(NoFoldLiteral0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:no_fold_literal][start_index] = r0

      r0
    end

  end

  class RFC2822Parser < Treetop::Runtime::CompiledParser
    include RFC2822
  end

end
