Piethon  1.0
A Python-like interpreter using flex and bison.
exception.h
Go to the documentation of this file.
1 #ifndef EXCEPTION_H
2 #define EXCEPTION_H
3 
4 #include "number.h"
5 
6 extern int yylineno;
7 
9 public:
10  virtual int getLineNumber() const;
11  virtual const char* what() const throw();
12 
13 protected:
14  ParseException(const char* m) : msg(m), lineNumber(yylineno) { }
15  const char* msg;
17 };
18 
19 
20 class DivideByZero : public ParseException {
21 public:
22  DivideByZero() : ParseException("divide by zero") { }
23 };
24 
25 
26 class ModByZero : public ParseException {
27 public:
28  ModByZero() : ParseException("mod by zero") { }
29 };
30 
31 
33 public:
34  FloatingPointMod() : ParseException("mod on floating point value") { }
35 };
36 
37 
38 class UnknownType : public ParseException {
39 public:
40  UnknownType() : ParseException("operand has unknown type") { }
41 };
42 
43 
45 public:
46  ParameterMismatch() : ParseException("number of parameters passed differs from function signature") { }
47 };
48 
49 
51 public:
52  UnboundIdentifier() : ParseException("use of unbound identfier") { }
53 };
54 
55 
57 public:
58  UndefinedFunction() : ParseException("call of undefined function") { }
59 };
60 
61 
63 public:
64  ReturnStatementOutsideOfFunction() : ParseException("return statement exists outside of a function") { }
65 };
66 
67 
68 class ReturnValue {
69 public:
70  ReturnValue(const Number& num, int line) : value(num), lineNumber(line) { }
71 
72  const char* what() const throw();
73  Number getValue() const;
74  int getLineNumber() const;
75 
76 private:
77  Number value;
78  int lineNumber;
79 };
80 
81 #endif
int yylineno
virtual int getLineNumber() const
Definition: exception.cpp:7
ModByZero()
Definition: exception.h:28
ParseException(const char *m)
Definition: exception.h:14
Definition: number.h:21
virtual const char * what() const
Definition: exception.cpp:3
const char * msg
Definition: exception.h:15
ReturnValue(const Number &num, int line)
Definition: exception.h:70