Module dev.civl.abc

Interface Preprocessor


public interface Preprocessor

A Preprocessor is used to preprocess source files. A single Preprocessor object can be used to preprocess multiple files.

A Preprocessor does have some state: it keeps track of all the files it has preprocessed. This includes files that were preprocessed because they were (recursively) included by #include directives. It maintains an ordered list in which each of these files occurs exactly once. This essentially assigned a unique integer ID (numbered from 0) to all the files that the preprocessor has encountered.

  • Field Details

    • ABC_INCLUDE_PATH

      static final File ABC_INCLUDE_PATH
      The path containing the ABC header files. This is internal to the project. The path is interpreted relative to the directories in the class path. The directory "/include" is in the class path. Therefore "abc" will be found in "/include/headers".
    • civlcHeaderName

      static final String civlcHeaderName
      The name of the CIVL-C header file, which is included automatically at the beginning of any CIVL-C input file.
      See Also:
    • defaultSystemIncludes

      static final File[] defaultSystemIncludes
      Default value for system include path list.
    • defaultUserIncludes

      static final File[] defaultUserIncludes
      Default value for user include path list. Currently, it consists of one directory, namely, the working directory.
  • Method Details

    • preprocess

      CivlcTokenSource preprocess(File[] systemIncludePaths, File[] userIncludePaths, Map<String,String> predefinedMacros, File[] sourceFiles) throws PreprocessorException
      Given preprocessor source files, this returns a Token Source that emits the tokens resulting from preprocessing the file.
      Parameters:
      systemIncludePaths - the system include paths to search for included system headers
      userIncludePaths - the user include paths to search for included user headers
      predefinedMacros - the predefined macros, such as those specified in command line
      sourceFiles - the file sequence to be preprocessed as a single translation unit
      Returns:
      the token source which is the output of the preprocessor, i.e., the result of tokenizing the files, applying the preprocessing directives, etc.
      Throws:
      PreprocessorException - if an I/O error occurs
    • preprocessLibrary

      CivlcTokenSource preprocessLibrary(Map<String,String> predefinedMacros, String libraryFileName) throws PreprocessorException
      Throws:
      PreprocessorException
    • getFileIndexer

      FileIndexer getFileIndexer()