Class GlslParser

java.lang.Object
io.github.ocelot.glslprocessor.api.GlslParser

public final class GlslParser extends Object
Parses GLSL source code strings into a mutable AST.
Since:
1.0.0
  • Method Details

    • preprocessParse

      public static GlslTree preprocessParse(String input, Map<String,String> macros) throws GlslSyntaxException, LexerException
      Runs the C preprocessor on the specified source before passing it off to the parser.
      Parameters:
      input - The source code input
      macros - All macros to evaluate during pre-processing
      Returns:
      A new tree of all nodes
      Throws:
      GlslSyntaxException - If there is a syntax error in the GLSL source code
      LexerException - If there is any issue pre-processing the code
    • parse

      public static GlslTree parse(String input) throws GlslSyntaxException
      Parses the specified input code into a GLSL tree.
      Parameters:
      input - The GLSL source input
      Returns:
      A new tree of all nodes
      Throws:
      GlslSyntaxException - If there is a syntax error in the GLSL source code
    • parseExpression

      public static GlslNode parseExpression(String input) throws GlslSyntaxException
      Parses the specified input code as a single GLSL expression.
      Parameters:
      input - The GLSL source input
      Returns:
      A single node
      Throws:
      GlslSyntaxException - If there is a syntax error in the GLSL source code
    • parseExpression

      @ScheduledForRemoval(inVersion="2.0.0") @Deprecated(since="0.2.0", forRemoval=true) public static GlslNode parseExpression(GlslLexer.Token... tokens) throws GlslSyntaxException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parses the specified token array as a single GLSL expression.
      Parameters:
      tokens - The tokens to parse
      Returns:
      A single node
      Throws:
      GlslSyntaxException - If there is a syntax error in the GLSL source code
    • parseExpressionList

      public static List<GlslNode> parseExpressionList(String input) throws GlslSyntaxException
      Parses the specified input code as multiple GLSL expressions. This only supports multiple statements in a list.
      Parameters:
      input - The GLSL source input
      Returns:
      A single node
      Throws:
      GlslSyntaxException - If there is a syntax error in the GLSL source code
    • parseExpressionList

      @ScheduledForRemoval(inVersion="2.0.0") @Deprecated(since="0.2.0", forRemoval=true) public static List<GlslNode> parseExpressionList(GlslLexer.Token[] tokens) throws GlslSyntaxException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parses the specified token array as multiple GLSL expressions. This only supports multiple statements in a list.
      Parameters:
      tokens - The tokens to parse
      Returns:
      A single node
      Throws:
      GlslSyntaxException - If there is a syntax error in the GLSL source code