001/* 002 * Anarres C Preprocessor 003 * Copyright (c) 2007-2015, Shevek 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 014 * or implied. See the License for the specific language governing 015 * permissions and limitations under the License. 016 */ 017package org.anarres.cpp; 018 019import javax.annotation.Nonnull; 020 021/** 022 * A handler for preprocessor events, primarily errors and warnings. 023 * 024 * If no PreprocessorListener is installed in a Preprocessor, all 025 * error and warning events will throw an exception. Installing a 026 * listener allows more intelligent handling of these events. 027 */ 028public interface PreprocessorListener { 029 030 /** 031 * Handles a warning. 032 * 033 * The behaviour of this method is defined by the 034 * implementation. It may simply record the error message, or 035 * it may throw an exception. 036 */ 037 public void handleWarning(@Nonnull Source source, int line, int column, 038 @Nonnull String msg) 039 throws LexerException; 040 041 /** 042 * Handles an error. 043 * 044 * The behaviour of this method is defined by the 045 * implementation. It may simply record the error message, or 046 * it may throw an exception. 047 */ 048 public void handleError(@Nonnull Source source, int line, int column, 049 @Nonnull String msg) 050 throws LexerException; 051 052 public enum SourceChangeEvent { 053 054 SUSPEND, PUSH, POP, RESUME; 055 } 056 057 public void handleSourceChange(@Nonnull Source source, @Nonnull SourceChangeEvent event); 058 059}