BELScript.g:44:1: document : ( NEWLINE | DOCUMENT_COMMENT | record )+ EOF ;
340414
public final BELScriptParser.document_return document() throws RecognitionException {
        BELScriptParser.document_return retval = new BELScriptParser.document_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token NEWLINE1=null;
        Token DOCUMENT_COMMENT2=null;
        Token EOF4=null;
        BELScriptParser.record_return record3 = null;


        Object NEWLINE1_tree=null;
        Object DOCUMENT_COMMENT2_tree=null;
        Object EOF4_tree=null;

        try {
            // BELScript.g:44:9: ( ( NEWLINE | DOCUMENT_COMMENT | record )+ EOF )
            // BELScript.g:45:5: ( NEWLINE | DOCUMENT_COMMENT | record )+ EOF
            {
            root_0 = (Object)adaptor.nil();

            // BELScript.g:45:5: ( NEWLINE | DOCUMENT_COMMENT | record )+
            int cnt1=0;
            loop1:
            do {
                int alt1=4;
                switch ( input.LA(1) ) {
                case NEWLINE:
                    {
                    alt1=1;
                    }
                    break;
                case DOCUMENT_COMMENT:
                    {
                    alt1=2;
                    }
                    break;
                case 24:
                case 26:
                case 27:
                case 44:
                case 45:
                case 46:
                case 47:
                case 48:
                case 49:
                case 50:
                case 51:
                case 52:
                case 53:
                case 54:
                case 55:
                case 56:
                case 57:
                case 58:
                case 59:
                case 60:
                case 61:
                case 62:
                case 63:
                case 64:
                case 65:
                case 66:
                case 67:
                case 68:
                case 69:
                case 70:
                case 71:
                case 72:
                case 73:
                case 74:
                case 75:
                case 76:
                case 77:
                case 78:
                case 79:
                case 80:
                case 81:
                case 82:
                case 83:
                case 84:
                case 85:
                case 86:
                case 87:
                case 88:
                case 89:
                case 90:
                case 91:
                case 92:
                case 93:
                case 94:
                case 95:
                case 96:
                case 97:
                case 98:
                case 99:
                case 100:
                case 101:
                case 102:
                    {
                    alt1=3;
                    }
                    break;

                }

                switch (alt1) {
            	case 1 :
            	    // BELScript.g:45:6: NEWLINE
            	    {
            	    NEWLINE1=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_document62); 
            	    NEWLINE1_tree = (Object)adaptor.create(NEWLINE1);
            	    adaptor.addChild(root_0, NEWLINE1_tree);


            	    }
            	    break;
            	case 2 :
            	    // BELScript.g:45:16: DOCUMENT_COMMENT
            	    {
            	    DOCUMENT_COMMENT2=(Token)match(input,DOCUMENT_COMMENT,FOLLOW_DOCUMENT_COMMENT_in_document66); 
            	    DOCUMENT_COMMENT2_tree = (Object)adaptor.create(DOCUMENT_COMMENT2);
            	    adaptor.addChild(root_0, DOCUMENT_COMMENT2_tree);


            	    }
            	    break;
            	case 3 :
            	    // BELScript.g:45:35: record
            	    {
            	    pushFollow(FOLLOW_record_in_document70);
            	    record3=record();

            	    state._fsp--;

            	    adaptor.addChild(root_0, record3.getTree());

            	    }
            	    break;

            	default :
            	    if ( cnt1 >= 1 ) break loop1;
                        EarlyExitException eee =
                            new EarlyExitException(1, input);
                        throw eee;
                }
                cnt1++;
            } while (true);

            EOF4=(Token)match(input,EOF,FOLLOW_EOF_in_document74); 
            EOF4_tree = (Object)adaptor.create(EOF4);
            adaptor.addChild(root_0, EOF4_tree);


            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
329353
function scriptLog(script, msg, isError) {
	write(msg, 
		isError ? clc.red : null, 
		clc.yellow('[' + script + ']'));
}
265935
def ensure_description_newlines(buffer)
      return if description.empty?

      if description[-1, 1] != '\n'
        buffer << '\n\n'
      elsif description.length > 1 && description[-2, 1] != '\n'
        buffer << '\n'
      end
    end
836552
public final void mDOCUMENT_KEYWORD() throws RecognitionException {
        try {
            int _type = DOCUMENT_KEYWORD;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // BELScript.g:261:17: ( 'DOCUMENT' )
            // BELScript.g:262:5: 'DOCUMENT'
            {
            match("DOCUMENT"); 


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
462336
private String readDocumentation() {
    String result = null;
    while (true) {
      skipWhitespace(false);
      if (pos == data.length || data[pos] != '/') {
        return result != null ? result : "";
      }
      String comment = readComment();
      result = (result == null) ? comment : (result + "\n" + comment);
    }
  }
612117
def check_all(self):
        
        self.file_errors = 0
        self.line_number = 0
        self.indent_char = None
        self.indent_level = 0
        self.previous_logical = ''
        self.blank_lines = 0
        self.tokens = []
        parens = 0
        for token in tokenize.generate_tokens(self.readline_check_physical):
            # print tokenize.tok_name[token[0]], repr(token)
            self.tokens.append(token)
            token_type, text = token[0:2]
            if token_type == tokenize.OP and text in '([{':
                parens += 1
            if token_type == tokenize.OP and text in '}])':
                parens -= 1
            if token_type == tokenize.NEWLINE and not parens:
                self.check_logical()
                self.blank_lines = 0
                self.tokens = []
            if token_type == tokenize.NL and not parens:
                if len(self.tokens) <= 1:
                    # The physical line contains only this token.
                    self.blank_lines += 1
                self.tokens = []
            if token_type == tokenize.COMMENT:
                source_line = token[4]
                token_start = token[2][1]
                if source_line[:token_start].strip() == '':
                    self.blank_lines = 0
                if text.endswith('\n') and not parens:
                    # The comment also ends a physical line.  This works around
                    # Python < 2.6 behaviour, which does not generate NL after
                    # a comment which is on a line by itself.
                    self.tokens = []
        return self.file_errors
972105
public final void mNEWLINE() throws RecognitionException {
        try {
            int _type = NEWLINE;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // BELScript.g:297:8: ( ( '\\u000d' )? '\\u000a' | '\\u000d' )
            int alt11=2;
            int LA11_0 = input.LA(1);

            if ( (LA11_0=='\r') ) {
                int LA11_1 = input.LA(2);

                if ( (LA11_1=='\n') ) {
                    alt11=1;
                }
                else {
                    alt11=2;}
            }
            else if ( (LA11_0=='\n') ) {
                alt11=1;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 11, 0, input);

                throw nvae;
            }
            switch (alt11) {
                case 1 :
                    // BELScript.g:298:5: ( '\\u000d' )? '\\u000a'
                    {
                    // BELScript.g:298:5: ( '\\u000d' )?
                    int alt10=2;
                    int LA10_0 = input.LA(1);

                    if ( (LA10_0=='\r') ) {
                        alt10=1;
                    }
                    switch (alt10) {
                        case 1 :
                            // BELScript.g:298:5: '\\u000d'
                            {
                            match('\r'); 

                            }
                            break;

                    }

                    match('\n'); 

                    }
                    break;
                case 2 :
                    // BELScript.g:298:26: '\\u000d'
                    {
                    match('\r'); 

                    }
                    break;

            }
            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
629167
def document_is_multiline_python(document):
    
    def ends_in_multiline_string():
        """
        ``True`` if we're inside a multiline string at the end of the text.
        """
        delims = _multiline_string_delims.findall(document.text)
        opening = None
        for delim in delims:
            if opening is None:
                opening = delim
            elif delim == opening:
                opening = None
        return bool(opening)

    if '\n' in document.text or ends_in_multiline_string():
        return True

    def line_ends_with_colon():
        return document.current_line.rstrip()[-1:] == ':'

    # If we just typed a colon, or still have open brackets, always insert a real newline.
    if line_ends_with_colon() or \
            (document.is_cursor_at_the_end and
             has_unclosed_brackets(document.text_before_cursor)) or \
            document.text.startswith('@'):
        return True

    # If the character before the cursor is a backslash (line continuation
    # char), insert a new line.
    elif document.text_before_cursor[-1:] == '\\':
        return True

    return False
1246439
def parse_comment(self, comment, filename, lineno, endlineno,
                      include_paths=None, stripped=False):
        
        if not stripped and not self.__validate_c_comment(comment.strip()):
            return None

        title_offset = 0

        column_offset = 0

        raw_comment = comment
        if not stripped:
            try:
                while comment[column_offset * -1 - 1] != '\n':
                    column_offset += 1
            except IndexError:
                column_offset = 0
            comment, title_offset = self.__strip_comment(comment)

        title_and_params, description = self.__extract_titles_params_and_description(comment)
        try:
            block_name, parameters, annotations, is_section = \
                self.__parse_title_and_parameters(filename, title_and_params)
        except HotdocSourceException as _:
            warn('gtk-doc-bad-syntax',
                 message=_.message,
                 filename=filename,
                 lineno=lineno + title_offset)
            return None

        params_offset = 0
        for param in parameters:
            param.filename = filename
            param.lineno = lineno
            param_offset = param.line_offset
            param.line_offset = title_offset + params_offset + 1
            params_offset += param_offset
            param.col_offset = column_offset

        if not block_name:
            return None

        description_offset = 0
        meta = {}
        tags = []
        if description is not None:
            n_lines = len(comment.split('\n'))
            description_offset = (title_offset + n_lines -
                                  len(description.split('\n')))
            meta['description'], tags = self.__parse_description_and_tags(description)

        actual_parameters = OrderedDict({})
        for param in parameters:
            if is_section:
                cleaned_up_name = param.name.lower().replace('_', '-')
                if cleaned_up_name in ['symbols', 'private-symbols', 'auto-sort', 'sources']:
                    meta.update(self.__parse_yaml_comment(param, filename))
                    if cleaned_up_name == 'sources':
                        sources_paths = [os.path.abspath(os.path.join(os.path.dirname(filename), path)) for path in meta[cleaned_up_name]]
                        meta[cleaned_up_name] = sources_paths
                else:
                    meta[param.name] = param.description
            else:
                actual_parameters[param.name] = param

        annotations = {annotation.name: annotation for annotation in
                       annotations}
        tags = {tag.name.lower(): tag for tag in tags}

        block = Comment(name=block_name, filename=filename, lineno=lineno,
                        endlineno=endlineno,
                        annotations=annotations, params=actual_parameters,
                        tags=tags, raw_comment=raw_comment,
                        meta=meta, toplevel=is_section)
        block.line_offset = description_offset
        block.col_offset = column_offset

        return block
280385
def read_record(fp, first_line=None):
    

    if first_line is None:
        first_line = fp.readline()

    if not first_line:
        raise EOFError()

    match = _START.match(first_line)
    if not match:
        raise Exception('Bad start of message', first_line)

    type = match.group(1)
    message = Message(type)

    while True:
        row = fp.readline()

        match = _MULTILINE_FIELD.match(row)
        if match:
            key = match.group(1)
            val = ""
            while row:
                pos = fp.tell()
                row = fp.readline()
                if row[0] in '.':
                    break
                elif row[0] in '{}':
                    fp.seek(pos)  # put the line back
                    break
                val += row
            message.contents.append((key, val, True))
            continue

        match = _FIELD.match(row)
        if match:
            key, val = match.group(1), match.group(2)
            message.contents.append((key, val, False))
            continue

        match = _START.match(row)
        if match:
            message.append(read_record(fp, row))
            continue

        if row[0] == '}':
            break

        raise Exception('Bad line', row)

    return message
1169142
def validate(self, document):
        
        # When the input starts with Ctrl-Z, always accept. This means EOF in a
        # Python REPL.
        if document.text.startswith('\x1a'):
            return

        try:
            if self.get_compiler_flags:
                flags = self.get_compiler_flags()
            else:
                flags = 0

            compile(document.text, '<input>', 'exec', flags=flags, dont_inherit=True)
        except SyntaxError as e:
            # Note, the 'or 1' for offset is required because Python 2.7
            # gives `None` as offset in case of '4=4' as input. (Looks like
            # fixed in Python 3.)
            index = document.translate_row_col_to_index(e.lineno - 1,  (e.offset or 1) - 1)
            raise ValidationError(index, 'Syntax Error')
        except TypeError as e:
            # e.g. "compile() expected string without null bytes"
            raise ValidationError(0, str(e))
        except ValueError as e:
            # In Python 2, compiling "\x9" (an invalid escape sequence) raises
            # ValueError instead of SyntaxError.
            raise ValidationError(0, 'Syntax Error: %s' % e)
480374
public void write( Document document ) {
        assert document != null;
        ++count;
        ++totalCount;
        if (count > maxDocumentsPerFile) {
            // Close the stream (we'll open a new one later in the method) ...
            close();
            count = 1;
        }
        try {
            if (stream == null) {
                // Open the stream to the next file ...
                ++fileCount;
                String suffix = StringUtil.justifyRight(Long.toString(fileCount), BackupService.NUM_CHARS_IN_FILENAME_SUFFIX, '0');
                String filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION;
                if (compress) filename = filename + GZIP_EXTENSION;
                currentFile = new File(parentDirectory, filename);
                OutputStream fileStream = new FileOutputStream(currentFile);
                if (compress) fileStream = new GZIPOutputStream(fileStream);
                stream = new BufferedOutputStream(fileStream);
            }
            Json.write(document, stream);
            // Need to append a non-consumable character so that we can read multiple JSON documents per file
            stream.write((byte)'\n');
        } catch (IOException e) {
            problems.addError(JcrI18n.problemsWritingDocumentToBackup, currentFile.getAbsolutePath(), e.getMessage());
        }
    }
516102
public final BELScriptParser.statement_return statement() throws RecognitionException {
        BELScriptParser.statement_return retval = new BELScriptParser.statement_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token OPEN_PAREN50=null;
        Token CLOSE_PAREN54=null;
        Token STATEMENT_COMMENT56=null;
        BELScriptParser.outer_term_return outer_term48 = null;

        BELScriptParser.relationship_return relationship49 = null;

        BELScriptParser.outer_term_return outer_term51 = null;

        BELScriptParser.relationship_return relationship52 = null;

        BELScriptParser.outer_term_return outer_term53 = null;

        BELScriptParser.outer_term_return outer_term55 = null;


        Object OPEN_PAREN50_tree=null;
        Object CLOSE_PAREN54_tree=null;
        Object STATEMENT_COMMENT56_tree=null;

         paraphrases.push("in statement."); 
        try {
            // BELScript.g:135:5: ( outer_term ( relationship ( ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN ) | outer_term ) )? ( STATEMENT_COMMENT )? )
            // BELScript.g:136:5: outer_term ( relationship ( ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN ) | outer_term ) )? ( STATEMENT_COMMENT )?
            {
            root_0 = (Object)adaptor.nil();

            pushFollow(FOLLOW_outer_term_in_statement677);
            outer_term48=outer_term();

            state._fsp--;

            adaptor.addChild(root_0, outer_term48.getTree());
            // BELScript.g:136:16: ( relationship ( ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN ) | outer_term ) )?
            int alt9=2;
            int LA9_0 = input.LA(1);

            if ( ((LA9_0>=103 && LA9_0<=130)) ) {
                alt9=1;
            }
            switch (alt9) {
                case 1 :
                    // BELScript.g:136:17: relationship ( ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN ) | outer_term )
                    {
                    pushFollow(FOLLOW_relationship_in_statement680);
                    relationship49=relationship();

                    state._fsp--;

                    adaptor.addChild(root_0, relationship49.getTree());
                    // BELScript.g:136:30: ( ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN ) | outer_term )
                    int alt8=2;
                    int LA8_0 = input.LA(1);

                    if ( (LA8_0==OPEN_PAREN) ) {
                        alt8=1;
                    }
                    else if ( ((LA8_0>=44 && LA8_0<=102)) ) {
                        alt8=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 8, 0, input);

                        throw nvae;
                    }
                    switch (alt8) {
                        case 1 :
                            // BELScript.g:136:31: ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN )
                            {
                            // BELScript.g:136:31: ( OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN )
                            // BELScript.g:136:32: OPEN_PAREN outer_term relationship outer_term CLOSE_PAREN
                            {
                            OPEN_PAREN50=(Token)match(input,OPEN_PAREN,FOLLOW_OPEN_PAREN_in_statement684); 
                            OPEN_PAREN50_tree = (Object)adaptor.create(OPEN_PAREN50);
                            adaptor.addChild(root_0, OPEN_PAREN50_tree);

                            pushFollow(FOLLOW_outer_term_in_statement686);
                            outer_term51=outer_term();

                            state._fsp--;

                            adaptor.addChild(root_0, outer_term51.getTree());
                            pushFollow(FOLLOW_relationship_in_statement688);
                            relationship52=relationship();

                            state._fsp--;

                            adaptor.addChild(root_0, relationship52.getTree());
                            pushFollow(FOLLOW_outer_term_in_statement690);
                            outer_term53=outer_term();

                            state._fsp--;

                            adaptor.addChild(root_0, outer_term53.getTree());
                            CLOSE_PAREN54=(Token)match(input,CLOSE_PAREN,FOLLOW_CLOSE_PAREN_in_statement692); 
                            CLOSE_PAREN54_tree = (Object)adaptor.create(CLOSE_PAREN54);
                            adaptor.addChild(root_0, CLOSE_PAREN54_tree);


                            }


                            }
                            break;
                        case 2 :
                            // BELScript.g:136:93: outer_term
                            {
                            pushFollow(FOLLOW_outer_term_in_statement697);
                            outer_term55=outer_term();

                            state._fsp--;

                            adaptor.addChild(root_0, outer_term55.getTree());

                            }
                            break;

                    }


                    }
                    break;

            }

            // BELScript.g:136:107: ( STATEMENT_COMMENT )?
            int alt10=2;
            int LA10_0 = input.LA(1);

            if ( (LA10_0==STATEMENT_COMMENT) ) {
                alt10=1;
            }
            switch (alt10) {
                case 1 :
                    // BELScript.g:136:107: STATEMENT_COMMENT
                    {
                    STATEMENT_COMMENT56=(Token)match(input,STATEMENT_COMMENT,FOLLOW_STATEMENT_COMMENT_in_statement702); 
                    STATEMENT_COMMENT56_tree = (Object)adaptor.create(STATEMENT_COMMENT56);
                    adaptor.addChild(root_0, STATEMENT_COMMENT56_tree);


                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

             paraphrases.pop(); 
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
663962
function(doc){
	var vs=doc.split("\r\n");
	if(vs.length==1){
		vs=doc.split("\n");
	}
	if(vs[vs.length-1]==''){
		vs.pop();
	}
	return vs;
}
1083092
private void commentLinesAfter( String content, int line ) {
        int offset = rootElement.getElement(line).getEndOffset();
        // End of comment not found, nothing to do
        int endDelimiter = indexOf(content, getEndDelimiter(), offset);
        if (endDelimiter < 0)
            return;
        // Matching start/end of comment found, comment the lines
        int startDelimiter = lastIndexOf(content, getStartDelimiter(), endDelimiter);
        if (startDelimiter < 0 || startDelimiter <= offset) {
            doc.setCharacterAttributes(offset, endDelimiter - offset + 1, comment, false);
        }
    }
1362342
@Override
  public boolean tokenizeLine(String line, BufferedReader reader, Record record) throws IOException {
    int numChars = line.length();
    final char DELIMITER = separatorChar;
    final char QUOTE = quoteChar;
    final StringBuilder sb = new StringBuilder(30);
    boolean isQuoted = false;
    int i = 0;
    int j = 0;
    
    while (true) {
      
      if (!isQuoted) {
        if (i == line.length()) {
          break; // we're done
        }
        final char c = line.charAt(i);
        if (c == DELIMITER) {
          put(sb, j, record);
          j++;
          sb.setLength(0);
        } else if (c == QUOTE) {
          if (sb.length() == 0) {
            isQuoted = true;
          } else if (i + 1 < line.length() && line.charAt(i + 1) == QUOTE) {
            sb.append(c);
            i++;
          } else {
            isQuoted = true;
          }
        } else {
          sb.append(c);
        }
          
      } else {
        assert isQuoted;
        if (i == line.length()) {
          sb.append('\n');
          i = -1;
          line = reader.readLine();
          if (line == null) {
            throw new IllegalStateException("unexpected end of file, unclosed quotation");
          }
          numChars += line.length();
          if (!verifyRecordLength(
              numChars, maxCharactersPerRecord, sb, line, ignoreTooLongRecords, LOG)) {
            return false; // attempt to ignore it
          }
        } else {
          final char c = line.charAt(i);
          if (c == QUOTE) {
            if (i + 1 < line.length() && line.charAt(i + 1) == QUOTE) {
              sb.append(c); // found two quotes -> insert single quote
              i++;
            } else {
              isQuoted = false;
            }
          } else {
            sb.append(c);
          }
        }
      }

      i++;
    }
    
    if (!(j == 0 && sb.length() == 0)) {
      put(sb, j, record);
    }
    
    return true;
  }
1067405
private boolean checkOutputFileEncoding(String docencoding,
            DocErrorReporter reporter) {
        OutputStream ost= new ByteArrayOutputStream();
        OutputStreamWriter osw = null;
        try {
            osw = new OutputStreamWriter(ost, docencoding);
        } catch (UnsupportedEncodingException exc) {
            reporter.printError(getText("doclet.Encoding_not_supported",
                docencoding));
            return false;
        } finally {
            try {
                if (osw != null) {
                    osw.close();
                }
            } catch (IOException exc) {
            }
        }
        return true;
    }