Class Preprocessor

java.lang.Object
io.github.protasm.jvmud.compiler.preproc.Preprocessor

public final class Preprocessor extends Object
Minimal LPC preprocessor for includes, macro definitions, conditional directives, comment stripping, and line splicing with backslash-newline.

It expands macros outside of string/char literals and respects a simple hideset to avoid recursive re-expansion.

  • Constructor Details

    • Preprocessor

      public Preprocessor(IncludeResolver resolver)
    • Preprocessor

      public Preprocessor(IncludeResolver resolver, Map<String,String> compatibilityPredefines)
      Creates a preprocessor with explicit compatibility predefines.

      The predefined values are replacement source text. This constructor is used by mudlib boundary profiles to expose driver-compatibility macros, for example LDMud-shaped version probes, without making those macros JVMud-native LPC.

      Parameters:
      resolver - include resolver for #include directives
      compatibilityPredefines - macro names and replacement source text supplied by the active mudlib boundary
    • Preprocessor

      public Preprocessor(IncludeResolver resolver, Map<String,String> compatibilityPredefines, Map<String, Map<String,String>> compatibilityFunctionPredefines)
      Creates a preprocessor with object-like and function-like compatibility predefines.

      Function-like entries are keyed by macro name and first-argument spelling. They let mudlib boundary profiles answer compile-time feature probes without hardcoding another driver's probe macro names in JVMud's compiler.

      Parameters:
      resolver - include resolver for #include directives
      compatibilityPredefines - object-like macro names and replacement source text supplied by the active mudlib boundary
      compatibilityFunctionPredefines - function-like macro replacements supplied by the active mudlib boundary
  • Method Details

    • preprocess

      public static String preprocess(String source)
      Preprocess source text without filesystem includes.

      This helper builds a Preprocessor that rejects any attempt to resolve #include directives, making it suitable for string-only compilation flows.

    • preprocessWithMapping

      public static PreprocessedSource preprocessWithMapping(String source)
    • preprocess

      public static String preprocess(Path sourcePath, String source, String sysInclPath, String quoteInclPath)
    • preprocess

      public static String preprocess(Path sourcePath, String source, Path baseIncludePath, List<Path> systemIncludePaths)
    • rejectingResolver

      public static IncludeResolver rejectingResolver()
    • preprocess

      public String preprocess(Path sourcePath, String source)
    • preprocessWithMapping

      public PreprocessedSource preprocessWithMapping(Path sourcePath, String source)
    • preprocessWithMapping

      public PreprocessedSource preprocessWithMapping(Path sourcePath, String source, String displayPath)