Package errors

Class LexicalError


  • public final class LexicalError
    extends Error
    The LexicalError class is used to represent an error that occurred during the lexical analysis stage of compilation.

    Static methods for generating LexicalErrors are stored here, each of which uses a set of pre-defined input Strings.

    Since:
    1.0
    • Constructor Summary

      Constructors 
      Constructor Description
      LexicalError​(SourceSpan span, java.lang.String problem, java.lang.String solution)  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static LexicalError badCharacter​(java.lang.String syntax, int start, int length)
      Generate and return a LexicalError for an invalid character.
      static LexicalError incompleteString​(java.lang.String syntax, int start, int length)
      Generate and return a LexicalError for an incomplete string.
      static LexicalError invalidDouble​(java.lang.String syntax, int start, int length)
      Generate and return a LexicalError for an invalid double.
      static LexicalError invalidInt​(java.lang.String syntax, int start, int length)
      Generate and return a LexicalError for an invalid integer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LexicalError

        public LexicalError​(SourceSpan span,
                            java.lang.String problem,
                            java.lang.String solution)
    • Method Detail

      • invalidInt

        public static LexicalError invalidInt​(java.lang.String syntax,
                                              int start,
                                              int length)
        Generate and return a LexicalError for an invalid integer.
        Parameters:
        syntax - The syntax of the integer
        start - The start position of the syntax
        length - The length of the syntax
        Returns:
        A LexicalError containing information about an error that occurred
      • invalidDouble

        public static LexicalError invalidDouble​(java.lang.String syntax,
                                                 int start,
                                                 int length)
        Generate and return a LexicalError for an invalid double.
        Parameters:
        syntax - The syntax of the double
        start - The start position of the syntax
        length - The length of the syntax
        Returns:
        A LexicalError containing information about an error that occurred
      • badCharacter

        public static LexicalError badCharacter​(java.lang.String syntax,
                                                int start,
                                                int length)
        Generate and return a LexicalError for an invalid character.
        Parameters:
        syntax - The syntax of the character
        start - The start position of the syntax
        length - The length of the syntax
        Returns:
        A LexicalError containing information about an error that occurred
      • incompleteString

        public static LexicalError incompleteString​(java.lang.String syntax,
                                                    int start,
                                                    int length)
        Generate and return a LexicalError for an incomplete string.
        Parameters:
        syntax - The syntax of the string
        start - The start position of the syntax
        length - The length of the syntax
        Returns:
        A LexicalError containing information about an error that occurred