public static void AbortTranslation(ErrorCode err, message.MessageProducer mp) { string fatal = "FATAL ERROR: " + err.Message; var args = Tuple.Create(0, 0, "", fatal); Message msg = new Message(MessageType.SyntaxError, args); mp.Send(msg); Environment.Exit(-1); }
public static void Flag(Token token, ErrorCode err, message.MessageProducer mp) { var args = Tuple.Create(token.LineNumber, token.Position, token.Lexeme, err.Message); Message msg = new Message(MessageType.SyntaxError, args); mp.Send(msg); if (++errors > MAX_ERRORS) { AbortTranslation(ErrorCode.TOO_MANY_ERRORS, mp); } }
public void ParseList(Token token, ICodeNode parent, TokenType terminator, ErrorCode error) { var terminator_set = new HashSet<TokenType>(STMT_START_SET); terminator_set.Add(terminator); while(!token.IsEof && token.TokenType != terminator) { // parse a statement. The parent node adopts the statement node. ICodeNode statement_node = Parse(token); parent.Add(statement_node); token = InternalScanner.CurrentToken; // look for the semicolon between the statements. if (token.TokenType == TokenType.SEMICOLON) { token = InternalScanner.GetNextToken(); } else if (STMT_START_SET.Contains(token.TokenType)) { ErrorHandler.Flag(token, ErrorCode.MISSING_SEMICOLON, this); } // Synchronize at the start of the next statement // or at the terminator. token = Parser.Synchronize(terminator_set, InternalScanner, this); } // look for the terminator token if (token.TokenType == terminator) { token = InternalScanner.GetNextToken(); } else { ErrorHandler.Flag(token, error, this); } }