1
/*******************************************************************************
2
* Copyright (c) 2004, 2008 IBM Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* IBM Corporation - initial implementation
10
* Anton Leherbauer - adding tokens for preprocessing directives
11
* Markus Schorn - classification of preprocessing directives.
12
*******************************************************************************/
13
package org.eclipse.cdt.internal.formatter.scanner;
15
import java.io.IOException;
16
import java.io.Reader;
17
import java.util.Stack;
19
public class ScannerContext {
20
private Reader fReader;
22
private Stack<Integer> fUndo = new Stack<Integer>();
24
public ScannerContext() {
27
public ScannerContext initialize(Reader r) {
33
public ScannerContext initialize(Reader r, int offset) {
36
} catch (IOException exc) {
37
throw new RuntimeException(exc);
44
public int read() throws IOException {
46
return fReader.read();
53
public final int getOffset() {
61
public final Reader getReader() {
65
public final int undoStackSize() {
73
public final int popUndo() {
74
return fUndo.pop().intValue();
79
* @param undo The undo to set
81
public void pushUndo(int undo) {
82
this.fUndo.push(new Integer(undo));