~ubuntu-branches/ubuntu/hardy/gnue-common/hardy

« back to all changes in this revision

Viewing changes to src/external/plex/Errors.py

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-03-09 11:06:31 UTC
  • Revision ID: james.westby@ubuntu.com-20050309110631-8gvvn39q7tjz1kj6
Tags: upstream-0.5.14
ImportĀ upstreamĀ versionĀ 0.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#=======================================================================
 
2
#
 
3
#   Python Lexical Analyser
 
4
#
 
5
#   Exception classes
 
6
#
 
7
#=======================================================================
 
8
 
 
9
import exceptions
 
10
 
 
11
class PlexError(exceptions.Exception):
 
12
  message = ""
 
13
 
 
14
class PlexTypeError(PlexError, TypeError):
 
15
  pass
 
16
 
 
17
class PlexValueError(PlexError, ValueError):
 
18
  pass
 
19
 
 
20
class InvalidRegex(PlexError):
 
21
  pass
 
22
 
 
23
class InvalidToken(PlexError):
 
24
 
 
25
  def __init__(self, token_number, message):
 
26
    PlexError.__init__(self, "Token number %d: %s" % (token_number, message))
 
27
 
 
28
class InvalidScanner(PlexError):
 
29
  pass
 
30
 
 
31
class AmbiguousAction(PlexError):
 
32
  message = "Two tokens with different actions can match the same string"
 
33
 
 
34
  def __init__(self):
 
35
    pass
 
36
 
 
37
class UnrecognizedInput(PlexError):
 
38
  scanner = None
 
39
  position = None
 
40
  state_name = None
 
41
 
 
42
  def __init__(self, scanner, state_name):
 
43
    self.scanner = scanner
 
44
    self.position = scanner.position()
 
45
    self.state_name = state_name
 
46
 
 
47
  def __str__(self):
 
48
    return ("'%s', line %d, char %d: Token not recognised in state %s" 
 
49
            % (self.position + (repr(self.state_name),)))
 
50
 
 
51
 
 
52