Class AppParser

java.lang.Object
org.infosmid.stream.dsl.AppParser
Direct Known Subclasses:
StreamParser

public class AppParser extends Object
Parser for generating AppNodes from Tokens. This class may serve as a base for higher level app processing, for instance streams or tasks.
  • Field Details

    • tokens

      protected final Tokens tokens
      Tokens resulting from DSL parsing.
  • Constructor Details

    • AppParser

      public AppParser(Tokens tokens)
      Construct a AppParser based on the provided Tokens.
      Parameters:
      tokens - tokens from which to construct this parser
  • Method Details

    • getTokens

      public Tokens getTokens()
      Return the Tokens this parser is using.
      Returns:
      tokens for this parser
    • eatApp

      protected AppNode eatApp()
      Return a AppNode from the next token and advance the token position.

      Expected format: app: [label':']? identifier (appArguments)*

      Returns:
      an app node resulting from the next token
    • eatAppArgs

      protected ArgumentNode[] eatAppArgs()
      Return an array of ArgumentNode and advance the token position if the next token(s) contain arguments.

      Expected format: appArguments : DOUBLE_MINUS identifier(name) EQUALS identifier(value)

      Returns:
      array of arguments or null if the next token(s) do not contain arguments
    • eatArgValue

      protected String eatArgValue()
      Return the argument value from the next token and advance the token position.

      Expected format: argValue: identifier | literal_string

      Returns:
      argument value
    • eatDottedName

      protected List<Token> eatDottedName()
      Return an array of Token that are separated by a dot.

      Expected format: identifier [DOT identifier]*

      Returns:
      array of tokens separated by a dot
    • toLabelNode

      protected LabelNode toLabelNode(Token label)
      Create a new LabelNode based on the provided token.
      Parameters:
      label - token containing the label; may be null
      Returns:
      new LabelNode instance based on the provided token, or null if the provided token is null
    • toData

      protected String toData(Iterable<Token> iterable)
      Return the concatenation of the data of multiple tokens.
      Parameters:
      iterable - the tokens to concatenate into the result.
      Returns:
      string containing the data of multiple tokens
    • tokenListToStringList

      protected List<String> tokenListToStringList(List<Token> tokens)
      Return a list of string representations of Tokens.
      Parameters:
      tokens - list of tokens to convert to a list of strings
      Returns:
      list of strings for the provided tokens
    • toString

      protected String toString(Token t)
      Return the string representation of a Token.
      Parameters:
      t - token
      Returns:
      string representation of the provided token
    • isValidName

      protected boolean isValidName(String name)
      Verify the supplied name is a valid name. Valid names must follow the same rules as Java identifiers, with the additional option to use a hyphen ('-') after the first character.
      Parameters:
      name - the name to validate
      Returns:
      true if name is valid
    • makeAppNode

      protected AppNode makeAppNode(LabelNode label, String appName, int startPos, int endPos, ArgumentNode[] arguments)