void AntlrParser::rethrow(antlr::SemanticException& e, string new_message)
throw (antlr::SemanticException) {
throw antlr::SemanticException(new_message, getFilename(),
- LT(0).get()->getLine(),
- LT(0).get()->getColumn());
+ LT(1).get()->getLine(),
+ LT(1).get()->getColumn());
}
-bool AntlrParser::checkDeclation(string varName, DeclarationCheck check) {
+bool AntlrParser::checkDeclaration(string varName, DeclarationCheck check) {
switch(check) {
case CHECK_DECLARED:
return isDeclared(varName, SYM_VARIABLE);
* @oaram check the kind of check to perform
* @return true if the check holds
*/
- bool checkDeclation(std::string varName, DeclarationCheck check);
+ bool checkDeclaration(std::string varName, DeclarationCheck check);
/**
* Types of symbols.
* Matches an identifier and returns a string.
*/
identifier[DeclarationCheck check = CHECK_NONE] returns [std::string id]
- : x:IDENTIFIER { checkDeclation(x->getText(), check) }?
- {
- id = x->getText();
- }
+ : x:IDENTIFIER
+ { id = x->getText(); }
+ { checkDeclaration(id, check) }?
exception catch [antlr::SemanticException& ex] {
switch (check) {
case CHECK_DECLARED: rethrow(ex, "Symbol " + id + " not declared");
* @return the id string
*/
identifier[DeclarationCheck check = CHECK_NONE] returns [std::string id]
- : x:IDENTIFIER { checkDeclation(x->getText(), check) }?
- {
- id = x->getText();
- }
+ : x:IDENTIFIER
+ { id = x->getText(); }
+ { checkDeclaration(id, check) }?
exception catch [antlr::SemanticException& ex] {
switch (check) {
case CHECK_DECLARED: rethrow(ex, "Symbol " + id + " not declared");