PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/src/orc/error/compiletime/CompilationExceptions.scala

https://github.com/laurenyew/cOrcS
Scala | 133 lines | 56 code | 23 blank | 54 comment | 0 complexity | d724e96f53eecac5caad9f725bcc74ff MD5 | raw file
Possible License(s): BSD-3-Clause
  1. //
  2. // CompilationExceptions.scala -- Scala child classes of CompilationException
  3. // Project OrcScala
  4. //
  5. // $Id: CompilationExceptions.scala 2924 2011-12-09 18:42:53Z jthywissen $
  6. //
  7. // Created by jthywiss on Aug 11, 2010.
  8. //
  9. // Copyright (c) 2011 The University of Texas at Austin. All rights reserved.
  10. //
  11. // Use and redistribution of this file is governed by the license terms in
  12. // the LICENSE file found in the project's top-level directory and also found at
  13. // URL: http://orc.csres.utexas.edu/license.shtml .
  14. //
  15. package orc.error.compiletime
  16. import scala.util.parsing.input.Position
  17. import orc.error.compiletime.CompileLogger.Severity
  18. // Severity marker traits
  19. trait CompilationExceptionSeverity
  20. trait ContinuableSeverity extends CompilationExceptionSeverity
  21. trait HaltingSeverity extends CompilationExceptionSeverity
  22. /** Severity of this exception is internal, for tool debugging -- users don't care. */
  23. trait SeverityDebug extends ContinuableSeverity
  24. /** Severity of this exception is completely routine. For example, counts of output size. */
  25. trait SeverityInfo extends ContinuableSeverity
  26. /** Severity of this exception is not routine, but not a problem. */
  27. trait SeverityNotice extends ContinuableSeverity
  28. /** Severity of this exception is a potential problem, but not bad enough to cause output to be disregarded -- it may still be usable. */
  29. trait SeverityWarning extends ContinuableSeverity
  30. /** Severity of this exception is a problem that is severe enough that output was discarded or should be discarded -- it is not usable. */
  31. trait SeverityError extends ContinuableSeverity
  32. /** Severity of this exception is a problem that has caused input processing to be stopped. */
  33. trait SeverityFatal extends HaltingSeverity
  34. /** Severity of this exception is an internal failure of the tool (not the user's fault). */
  35. trait SeverityInternal extends HaltingSeverity
  36. /** This Orc program is not syntactically valid.
  37. */
  38. abstract class SyntacticException(message: String) extends CompilationException(message)
  39. /** Problem parsing the text of an Orc program. Mostly this
  40. * is a wrapper around the exceptions thrown by whatever
  41. * parsing library we use.
  42. */
  43. class ParsingException(val message: String, val errorPos: Position)
  44. extends SyntacticException(message)
  45. with SeverityFatal { this.resetPosition(errorPos) }
  46. /** A record expression maps the same key more than once.
  47. */
  48. case class DuplicateKeyException(val duplicateKey: String)
  49. extends SyntacticException("Duplicate mapping for key " + duplicateKey + " in record. The rightmost mapping will be used.")
  50. with SeverityWarning
  51. /** A pattern, or set of pattern arguments, mentions the same variable more than once.
  52. */
  53. case class NonlinearPatternException(val repeatedName: String)
  54. extends SyntacticException("Nonlinear pattern: variable " + repeatedName + " occurs more than once.")
  55. with SeverityError
  56. /** A list of type formals mentions the same variable more than once.
  57. */
  58. case class DuplicateTypeFormalException(val repeatedName: String)
  59. extends SyntacticException("Duplicate type formal: " + repeatedName + " occurs more than once.")
  60. with SeverityError
  61. /** A clause of a function has a different number of parameters than
  62. * earlier clauses.
  63. *
  64. * @author dkitchin
  65. */
  66. case class ClauseArityMismatch()
  67. extends SyntacticException("Not all clauses of this function have the same number of arguments.")
  68. with SeverityFatal
  69. /** A clause can never be reached because the preceding clause matches all possible arguments.
  70. */
  71. case class RedundantMatch()
  72. extends SyntacticException("Redundant match; this clause can never be reached.")
  73. with SeverityWarning
  74. /** A clause has redundant type information.
  75. */
  76. abstract class RedundantTypeInformationException(message: String) extends SyntacticException(message) with SeverityWarning
  77. case class RedundantTypeParameters() extends RedundantTypeInformationException("Redundant type parameters")
  78. case class RedundantArgumentType() extends RedundantTypeInformationException("Redundant argument type")
  79. case class RedundantReturnType() extends RedundantTypeInformationException("Redundant return type")
  80. case class UnusedFunctionSignature() extends RedundantTypeInformationException("Unused function signature")
  81. case class ClassDefInNonclassContext()
  82. extends SyntacticException("Cannot declare this clause as 'class'; preceding clauses were not declared as 'class'")
  83. with SeverityError
  84. case class NonclassDefInClassContext()
  85. extends SyntacticException("This clause must be declared as 'class'; preceding clauses were declared as 'class'")
  86. with SeverityError
  87. /** A variable is unbound.
  88. */
  89. case class UnboundVariableException(val varName: String)
  90. extends SyntacticException("Variable " + varName + " is unbound")
  91. with SeverityError
  92. case class UnboundTypeVariableException(val typevarName: String)
  93. extends SyntacticException("Type variable " + typevarName + " is unbound")
  94. with SeverityError
  95. /** The compilation process has produced a malformed expression;
  96. * this is a fatal internal error, and not the fault of the user.
  97. */
  98. case class MalformedExpression(complaint: String)
  99. extends SyntacticException(complaint)
  100. with SeverityInternal
  101. /** Unguarded recursion.
  102. */
  103. case class UnguardedRecursionException() extends SyntacticException("Unguarded recursion") with SeverityWarning
  104. /** Indicate a problem with site resolution. Ideally
  105. * this would be a loadtime error, but currently site
  106. * resolution is done at compile time.
  107. */
  108. case class SiteResolutionException(val siteName: String, cause: Throwable)
  109. extends CompilationException("Problem loading site " + siteName, cause)
  110. with SeverityFatal