Class Expression

    • Constructor Detail

    • Method Detail

      • of

        public static Literal of​(boolean value)
      • of

        public static Literal of​(int value)
        Construct an integer literal for the given value, and returns it as an expression.
        Parameters:
        value - the integer value.
        Returns:
        the integer value as a literal expression.
      • of

        public static Literal of​(java.lang.String value)
        Constructs a string literal for the given values.
        Parameters:
        value - the string value.
        Returns:
        the string value as a literal.
      • fromNode

        public static Expression fromNode​(Node node)
        Constructs an expression from the provided Node.
        Parameters:
        node - the node to construct the expression from.
        Returns:
        the expression.
      • parseShortform

        public static Expression parseShortform​(java.lang.String shortForm,
                                                FromSourceLocation context)
        Parse a value from a "short form" used within a template.
        Parameters:
        shortForm - the shortform value
        Returns:
        the parsed expression
      • getLiteral

        public static Literal getLiteral​(StringNode node)
        Constructs a Literal from the given StringNode.
        Parameters:
        node - the node to construct the literal from.
        Returns:
        the string node as a literal.
      • accept

        public abstract <R> R accept​(ExpressionVisitor<R> visitor)
        Invoke the ExpressionVisitor functions for this expression.
        Type Parameters:
        R - the visitor return type.
        Parameters:
        visitor - the visitor to be invoked.
        Returns:
        the return value of the visitor.
      • type

        public Type type()
        Returns the type for this expression, throws a runtime exception if typeCheck has not been invoked.
        Returns:
        the type.
      • hashCode

        public abstract int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public abstract boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • typeCheck

        public Type typeCheck​(Scope<Type> scope)
        Description copied from interface: TypeCheck
        Checks whether the given types within a scope satisfy the constraints.
        Specified by:
        typeCheck in interface TypeCheck
        Parameters:
        scope - the scope to evaluate.
        Returns:
        the type validated by the scope check.