Changeset 190


Ignore:
Timestamp:
10/31/02 13:45:21 (21 years ago)
Author:
piso
Message:

Skip preprocessor continuation lines.

File:
1 edited

Legend:

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

    r2 r190  
    33 *
    44 * Copyright (C) 1998-2002 Peter Graves
    5  * $Id: CTagger.java,v 1.1.1.1 2002-09-24 16:09:14 piso Exp $
     5 * $Id: CTagger.java,v 1.2 2002-10-31 13:45:21 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2424import gnu.regexp.RE;
    2525import gnu.regexp.UncheckedRE;
    26 import java.util.Vector;
     26import java.util.ArrayList;
    2727
    2828public final class CTagger extends JavaTagger
     
    4444    public void run()
    4545    {
    46         Vector tags = new Vector();
     46        ArrayList tags = new ArrayList();
    4747        pos = new Position(buffer.getFirstLine(), 0);
    4848        token = null;
     
    6363                continue;
    6464            }
    65             if (pos.lookingAt("//") || (c == '#' && pos.getOffset() == 0)) {
     65            if (pos.lookingAt("//")) {
    6666                Line nextLine = pos.getNextLine();
    6767                if (nextLine == null)
    6868                    break;
    6969                pos.moveTo(nextLine, 0);
     70                continue;
     71            }
     72            if (c == '#' && pos.getOffset() == 0) {
     73                skipPreprocessor(pos);
    7074                continue;
    7175            }
     
    169173        token = sb.toString();
    170174    }
     175   
     176    private static void skipPreprocessor(Position pos)
     177    {
     178        while (true) {
     179            Line line = pos.getLine();
     180            Line nextLine = line.next();
     181            if (nextLine == null) {
     182                pos.setOffset(line.length());
     183                return;
     184            }
     185            pos.moveTo(nextLine, 0);
     186            if (line.length() == 0 || line.charAt(line.length()-1) != '\\')
     187                return;
     188        }
     189    }
    171190
    172191    private static final boolean isIdentifierStart(char c)
Note: See TracChangeset for help on using the changeset viewer.