Changeset 216


Ignore:
Timestamp:
11/09/02 18:18:10 (21 years ago)
Author:
piso
Message:

skipComment(), skipSingleLineComment()

Location:
trunk/j/src/org/armedbear/j
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/j/CTagger.java

    r202 r216  
    33 *
    44 * Copyright (C) 1998-2002 Peter Graves
    5  * $Id: CTagger.java,v 1.4 2002-11-05 02:24:53 piso Exp $
     5 * $Id: CTagger.java,v 1.5 2002-11-09 18:17:45 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    6060            }
    6161            if (pos.lookingAt("/*")) {
    62                 skipComment();
     62                skipComment(pos);
    6363                continue;
    6464            }
    6565            if (pos.lookingAt("//")) {
    66                 Line nextLine = pos.getNextLine();
    67                 if (nextLine == null)
    68                     break;
    69                 pos.moveTo(nextLine, 0);
     66                skipSingleLineComment(pos);
    7067                continue;
    7168            }
     
    165162        return sb.toString();
    166163    }
    167    
     164
    168165    private static boolean isDefunStart(String s)
    169166    {
  • trunk/j/src/org/armedbear/j/CppTagger.java

    r201 r216  
    6161            }
    6262            if (pos.lookingAt("/*")) {
    63                 skipComment();
     63                skipComment(pos);
    6464                continue;
    6565            }
    6666            if (pos.lookingAt("//")) {
    67                 Line nextLine = pos.getNextLine();
    68                 if (nextLine == null)
    69                     break;
    70                 pos.moveTo(nextLine, 0);
     67                skipSingleLineComment(pos);
    7168                continue;
    7269            }
  • trunk/j/src/org/armedbear/j/JavaTagger.java

    r2 r216  
    33 *
    44 * Copyright (C) 1998-2002 Peter Graves
    5  * $Id: JavaTagger.java,v 1.1.1.1 2002-09-24 16:08:08 piso Exp $
     5 * $Id: JavaTagger.java,v 1.2 2002-11-09 18:17:21 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    7676            }
    7777            if (pos.lookingAt("/*")) {
    78                 skipComment();
     78                skipComment(pos);
    7979                continue;
    8080            }
    8181            if (pos.lookingAt("//")) {
    82                 Line next = pos.getNextLine();
    83                 if (next == null)
    84                     break;
    85                 pos.moveTo(next, 0);
     82                skipSingleLineComment(pos);
    8683                continue;
    8784            }
     
    302299    }
    303300
    304     protected void skipComment()
     301    protected static final void skipComment(Position pos)
    305302    {
    306303        while (!pos.lookingAt("*/") && pos.next())
     
    308305        if (pos.lookingAt("*/"))
    309306            pos.skip(2);
     307    }
     308
     309    protected static final void skipSingleLineComment(Position pos)
     310    {
     311        Line next = pos.getNextLine();
     312        if (next != null)
     313            pos.moveTo(next, 0);
     314        else
     315            pos.setOffset(pos.getLineLength());
    310316    }
    311317
     
    339345            while (true) {
    340346                if (pos.lookingAt("/*")) {
    341                     skipComment();
     347                    skipComment(pos);
    342348                    continue;
    343349                }
    344350                if (pos.lookingAt("//")) {
    345                     Line nextLine = pos.getNextLine();
    346                     if (nextLine == null)
    347                         break;
    348                     pos.moveTo(nextLine, 0);
     351                    skipSingleLineComment(pos);
    349352                    continue;
    350353                }
     
    372375            while (true) {
    373376                if (pos.lookingAt("/*")) {
    374                     skipComment();
     377                    skipComment(pos);
    375378                    continue;
    376379                }
    377380                if (pos.lookingAt("//")) {
    378                     Line nextLine = pos.getNextLine();
    379                     if (nextLine != null) {
    380                         pos.moveTo(nextLine, 0);
    381                         continue;
    382                     }
    383                     // Next line is null.  Reached end of buffer.
    384                     pos.setOffset(pos.getLineLength());
    385                     break;
     381                    skipSingleLineComment(pos);
     382                    continue;
    386383                }
    387384                char c = pos.getChar();
     
    414411        while (!pos.atEnd()) {
    415412            if (pos.lookingAt("/*")) {
    416                 skipComment();
     413                skipComment(pos);
    417414                continue;
    418415            }
    419416            if (pos.lookingAt("//")) {
    420                 Line nextLine = pos.getNextLine();
    421                 if (nextLine == null) {
    422                     // Next line is null.  Reached end of buffer.
    423                     pos.setOffset(pos.getLineLength());
    424                     break;
    425                 } else {
    426                     pos.moveTo(nextLine, 0);
    427                     continue;
    428                 }
     417                skipSingleLineComment(pos);
     418                continue;
    429419            }
    430420            char c = pos.getChar();
Note: See TracChangeset for help on using the changeset viewer.