SyntaxError

public struct SyntaxError : Error
extension SyntaxError: CustomStringConvertible

A syntax error which was generated during parsing or tokenization

  • The reason for the syntax error

    • emptyNotAllowed: An empty string was provided but the grammar does not allow empty productions
    • unknownToken: The tokenization could not be completed because no matching token was found
    • unmatchedPattern: A pattern was found which could not be merged
    • unexpectedToken: A token was found that was not expected
    See more

    Declaration

    Swift

    public enum Reason
    extension SyntaxError.Reason: CustomStringConvertible
  • Range in which the error occurred

    Declaration

    Swift

    public let range: Range<String.Index>
  • Reason for the error

    Declaration

    Swift

    public let reason: Reason
  • The context around the error

    Declaration

    Swift

    public let context: [NonTerminal]
  • The string for which the parsing was unsuccessful.

    Declaration

    Swift

    public let string: String
  • The line in which the error occurred.

    The first line of the input string is line 0.

    Declaration

    Swift

    public var line: Int { get }
  • Undocumented

    Declaration

    Swift

    public var column: Int { get }
  • Creates a new syntax error with a given range and reason

    Declaration

    Swift

    public init(range: Range<String.Index>, in string: String, reason: Reason, context: [NonTerminal] = [])

    Parameters

    range

    String range in which the syntax error occurred

    string

    String which was unsuccessfully parsed

    reason

    Reason why the syntax error occurred

    context

    Non-terminals which were expected at the location of the error.

  • Declaration

    Swift

    public var description: String { get }