Package icyllis.arc3d.compiler

# Class Parser

java.lang.Object
icyllis.arc3d.compiler.Parser

public class Parser extends Object
Consumes Arc3D shading language source text and invokes DSL functions to instantiate the AST (parsed IR). A Parser object is not reusable.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Parser(ShaderCompiler compiler, ShaderKind kind, CompileOptions options, char[] source, int offset, int length)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `TranslationUnit`
  `parse(ModuleUnit parent)`
  `ModuleUnit`
  `parseModule(ModuleUnit parent)`
  `List<Map.Entry<String,Boolean>>`
  `preprocess()`
  Preprocess directives.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Parser

    public Parser(ShaderCompiler compiler, ShaderKind kind, CompileOptions options, char[] source, int offset, int length)

- ## Method Details

  - ### preprocess

    @Nullable public List<Map.Entry<String,Boolean>> preprocess()
    Preprocess directives. A directive can only appear before any declaration.

    #version 3-digits (core|es)?
    The version number has no semantics impact, but must be 300 at least.

    #extension extension_name : behavior
    The extension has no semantics impact when generating SPIR-V, but it's retained when generating GLSL for some GLSL only extensions. A new behavior will override the earlier one for the same extension name.

    #include <file>
    #include "file"
    #import <file>
    #import "file"
    This method returns the include files as a list of (file,boolean) pairs. The second boolean value of true represents it's angle-bracketed (system include), otherwise it's double-quoted (local include). An implementation should normalize the file name and compile the include files first (via a new Parser's `parseModule(icyllis.arc3d.compiler.ModuleUnit)`). The return list is not deduplicated.

    #pragma
    The whole line is silently ignored.

    Note that version, extension, and include must appear in order. Other directives can cause compilation errors. This process is optional.

    Returns:
      include files (can be empty) or null if there's an error

  - ### parse

    @Nullable public TranslationUnit parse(ModuleUnit parent)

  - ### parseModule

    @Nullable public ModuleUnit parseModule(ModuleUnit parent)