\section{Error handling} All syntactic and semantic errors throw exceptions. In particular, the methods used to match tokens in the parser base class (match etc) throw §EdpgMismatchedToken§. The methods in the lexer base class used to match characters (match etc) throw exceptions similarly. \subsection{DPG exception hierarchy} DPG-generated parsers throw exceptions to signal recognition errors or other stream problems. All exceptions derive from EdpgException. The hierarchy is as follows: \begin{verbatim} EdpgException EdpgMismatchedChar EdpgMismatchedToken EdpgSemantic \end{verbatim} \subsection{EdpgException} The §EdpgException§ is the base class for all DPG exceptions. It defines the following read-only properties: \begin{alltt} FileName : string; Line : integer; Column : integer; \end{alltt} These properties contain information about the location where the exception occurred. \subsection{EdpgMismatchedChar} The §EdpgMismatchedChar§ exception is thrown by the lexer when it is looking for a character, but finds a different one on the input stream than expected. It defines the following properties in addition to those of §EdpgException§. \begin{alltt} FoundChar : char; FoundString : string; CharSet : TdpgCharSet; Str : string; Inverted : boolean; \end{alltt} The §FoundChar§ and §FoundString§ properties contain the character or string that was found on the input stream. The §CharSet§ and §Str§ properties contain the values which the lexer expected to find. The §Inverted§ property is set only if the exception came from a §MatchNot(...)§ operation. In this case, the §CharSet§ property contains the values, that the lexer must §not§ match. The validity of pro\-per\-ti\-es are shown in the next table, depending on the kind of exception. \begin{table}[H] \small \begin{center} \begin{tabular}{lcc} & Mismatched char & Mismatched string \\ \hline FoundChar & valid & - \\ FoundString & - & valid \\ CharSet & valid & - \\ Str & - & valid \\ Inverted & valid & - \\ \hline \end{tabular} \end{center} \end{table} \subsection{EdpgMismatchedToken} The §EdpgMismatchedToken§ exception is thrown by the parser when it is looking for a token, but finds a different one on the input token stream than expected. It defines the following properties in addition to those of §EdpgException§. \begin{alltt} FoundToken : IdpgToken; TokenSet : TdpgByteSet; Inverted : boolean; \end{alltt} The §FoundToken§ property contains the token the parser received from the lexer. The §TokenSet§ property contains the vaules the parser expected to get. The §Inverted§ property is set only if the exception came from a §MatchNot(...)§ operation. In this case, the §TokenSet§ property contains the values the parser must §not§ get. \subsection{EdpgSemantic} This exception is thrown by a validating semantic predicate. It defines the following property in addition to those of §EdpgException§. \begin{alltt} Assert : string; \end{alltt} The §Assert§ property contains the validating expression that caused the exception.