Public Member Functions | Public Attributes | Private Member Functions | List of all members
vhdl::parser::ParseException Class Reference

#include <ParseException.h>

Public Member Functions

 ParseException (Token currentTokenVal, int **expectedTokenSequencesVal, JAVACC_STRING_TYPE *tokenImageVal)
 
 ParseException ()
 
 ParseException (JAVACC_STRING_TYPE message)
 

Public Attributes

Token currentToken
 
int ** expectedTokenSequences
 
JAVACC_STRING_TYPEtokenImage
 

Private Member Functions

JAVACC_STRING_TYPE initialise (Token currentToken, int **expectedTokenSequences, JAVACC_STRING_TYPE *tokenImage)
 
JAVACC_STRING_TYPE add_escapes (JAVACC_STRING_TYPE str)
 

Detailed Description

This exception is thrown when parse errors are encountered. You can explicitly create objects of this exception type by calling the method generateParseException in the generated parser.

You can modify this class to customize your error reporting mechanisms so long as you retain the fields.

Definition at line 20 of file ParseException.h.

Constructor & Destructor Documentation

vhdl::parser::ParseException::ParseException ( Token  currentTokenVal,
int **  expectedTokenSequencesVal,
JAVACC_STRING_TYPE tokenImageVal 
)

This constructor is used by the method "generateParseException" in the generated parser. Calling this constructor generates a new object of this type with the fields "currentToken", "expectedTokenSequences", and "tokenImage" set.

This exception is thrown when parse errors are encountered. You can explicitly create objects of this exception type by calling the method generate_ParseException in the generated parser.

You can modify this class to customize your error reporting mechanisms so long as you retain the fields. This constructor is used by the method "generate_ParseException" in the generated parser. Calling this constructor generates a new object of this type with the fields "currentToken", "expectedTokenSequences", and "tokenImage" set.

Definition at line 24 of file ParseException.cc.

28  {
29  initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal);
30  currentToken = currentTokenVal;
31  expectedTokenSequences = expectedTokenSequencesVal;
32  tokenImage = tokenImageVal;
33  }
JAVACC_STRING_TYPE * tokenImage
JAVACC_STRING_TYPE initialise(Token currentToken, int **expectedTokenSequences, JAVACC_STRING_TYPE *tokenImage)
vhdl::parser::ParseException::ParseException ( )

The following constructors are for use by you for whatever purpose you can think of. Constructing the exception in this manner makes the exception behave in the normal way - i.e., as documented in the class "Throwable". The fields "errorToken", "expectedTokenSequences", and "tokenImage" do not contain relevant information. The JavaCC generated code does not use these constructors.

Definition at line 45 of file ParseException.cc.

45  {
46  }
vhdl::parser::ParseException::ParseException ( JAVACC_STRING_TYPE  message)

Constructor with message.

Definition at line 49 of file ParseException.cc.

49  {
50  }

Member Function Documentation

JAVACC_STRING_TYPE vhdl::parser::ParseException::add_escapes ( JAVACC_STRING_TYPE  str)
private

Used to convert raw characters to their escaped version when these raw version cannot be used as part of an ASCII string literal.

Definition at line 137 of file ParseException.cc.

137  {
138 /*
139  JAVACC_STRING_TYPE *retval = new JAVACC_STRING_TYPE();
140  JAVACC_CHAR_TYPE ch;
141  for (int i = 0; i < str.length(); i++) {
142  switch (str.charAt(i))
143  {
144  case '\b':
145  retval.append("\\b");
146  continue;
147  case '\t':
148  retval.append("\\t");
149  continue;
150  case '\n':
151  retval.append("\\n");
152  continue;
153  case '\f':
154  retval.append("\\f");
155  continue;
156  case '\r':
157  retval.append("\\r");
158  continue;
159  case '\"':
160  retval.append("\\\"");
161  continue;
162  case '\'':
163  retval.append("\\\'");
164  continue;
165  case '\\':
166  retval.append("\\\\");
167  continue;
168  default:
169  if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
170  JAVACC_STRING_TYPE s = "0000" + Integer.toString(ch, 16);
171  retval.append("\\u" + s.substring(s.length() - 4, s.length()));
172  } else {
173  retval.append(ch);
174  }
175  continue;
176  }
177  }
178  return retval.toString();
179 */ return str;
180  }
static QCString str
JAVACC_STRING_TYPE vhdl::parser::ParseException::initialise ( Token  currentToken,
int **  expectedTokenSequences,
JAVACC_STRING_TYPE tokenImage 
)
private

It uses "currentToken" and "expectedTokenSequences" to generate a parse error message and returns it. If this object has been created due to a parse error, and you do not catch it (it gets thrown from the parser) the correct error message gets displayed.

Definition at line 81 of file ParseException.cc.

83  {
84 #if 0
85  //JAVACC_STRING_TYPE eol = System.getProperty("line.separator", "\n");
87  int maxSize = 0;
88  for (int i = 0; i < expectedTokenSequences.length; i++) {
89  if (maxSize < expectedTokenSequences[i].length) {
90  maxSize = expectedTokenSequences[i].length;
91  }
92  for (int j = 0; j < expectedTokenSequences[i].length; j++) {
93  expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
94  }
95  if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
96  expected.append((JAVACC_CHAR_TYPE*)"...");
97  }
98  expected.append(eol).append(" ");
99  }
100  JAVACC_STRING_TYPE retval = (JAVACC_CHAR_TYPE*)"Encountered \"";
101  Token tok = currentToken.next;
102  for (int i = 0; i < maxSize; i++) {
103  if (i != 0) retval += (JAVACC_CHAR_TYPE*)" ";
104  if (tok.kind == 0) {
105  retval += tokenImage[0];
106  break;
107  }
108  retval += (JAVACC_CHAR_TYPE*)" " + tokenImage[tok.kind];
109  retval += (JAVACC_CHAR_TYPE*)" \"";
110  retval += add_escapes(tok.image);
111  retval += (JAVACC_CHAR_TYPE*)" \"";
112  tok = tok.next;
113  }
114  retval += (JAVACC_CHAR_TYPE*)"\" at line " + currentToken.next.beginLine + (JAVACC_CHAR_TYPE*)", column " + currentToken.next.beginColumn;
115  retval += (JAVACC_CHAR_TYPE*)"." + eol;
116  if (expectedTokenSequences.length == 1) {
117  retval += (JAVACC_CHAR_TYPE*)"Was expecting:" + eol + (JAVACC_CHAR_TYPE*)" ";
118  } else {
119  retval += (JAVACC_CHAR_TYPE*)"Was expecting one of:" + eol + (JAVACC_CHAR_TYPE*)" ";
120  }
121  retval += expected.toString();
122  return retval;
123 #endif
124  return (JAVACC_CHAR_TYPE*)"Parse exception";
125  }
JAVACC_STRING_TYPE * tokenImage
Token * next
Definition: Token.h:48
#define JAVACC_STRING_TYPE
Definition: JavaCC.h:16
const char expected[]
Definition: Exception_t.cc:22
JAVACC_STRING_TYPE add_escapes(JAVACC_STRING_TYPE str)
#define eol
#define JAVACC_CHAR_TYPE
Definition: JavaCC.h:12

Member Data Documentation

Token vhdl::parser::ParseException::currentToken

This is the last token that has been consumed successfully. If this object has been created due to a parse error, the token followng this token will (therefore) be the first error token.

Definition at line 55 of file ParseException.h.

int** vhdl::parser::ParseException::expectedTokenSequences

Each entry in this array is an array of integers. Each array of integers represents a sequence of tokens (by their ordinal values) that is expected at this point of the parse.

Definition at line 62 of file ParseException.h.

JAVACC_STRING_TYPE* vhdl::parser::ParseException::tokenImage

This is a reference to the "tokenImage" array of the generated parser within which the parse error occurred. This array is defined in the generated ...Constants class.

Definition at line 69 of file ParseException.h.


The documentation for this class was generated from the following files: