public bool Parse(TextReader reader) { //This procedure starts the GOLD Parser Engine and handles each of the //messages it returns. Each time a reduction is made, you can create new //custom object and reassign the .CurrentReduction property. Otherwise, //the system will use the Reduction object that was returned. // //The resulting tree will be a pure representation of the language //and will be ready to implement. GOLD.ParseMessage response; bool done; //Controls when we leave the loop bool accepted = false; //Was the parse successful? parser.Open(reader); parser.TrimReductions = false; //Please read about this feature before enabling done = false; while (!done) { response = parser.Parse(); switch (response) { case GOLD.ParseMessage.LexicalError: //Cannot recognize token done = true; break; case GOLD.ParseMessage.SyntaxError: //Expecting a different token done = true; break; case GOLD.ParseMessage.Reduction: //Create a customized object to store the reduction parser.CurrentReduction = CreateNewObject(parser.CurrentReduction as GOLD.Reduction); break; case GOLD.ParseMessage.Accept: //Accepted! //program = parser.CurrentReduction //The root node! done = true; accepted = true; break; case GOLD.ParseMessage.TokenRead: //You don't have to do anything here. break; case GOLD.ParseMessage.InternalError: //INTERNAL ERROR! Something is horribly wrong. done = true; break; case GOLD.ParseMessage.NotLoadedError: //This error occurs if the CGT was not loaded. done = true; break; case GOLD.ParseMessage.GroupError: //GROUP ERROR! Unexpected end of file done = true; break; } } //while if (!accepted) { Expected = parser.ExpectedSymbols(); } return(accepted); }
public LexicalErrorException(GOLD.SymbolList symbolList) : this(string.Format("Se esperaba: {0}", symbolList)) { // TODO: Complete member initialization this.symbolList = symbolList; }
public bool Parse(TextReader reader) { //This procedure starts the GOLD Parser Engine and handles each of the //messages it returns. Each time a reduction is made, you can create new //custom object and reassign the .CurrentReduction property. Otherwise, //the system will use the Reduction object that was returned. // //The resulting tree will be a pure representation of the language //and will be ready to implement. GOLD.ParseMessage response; bool done; //Controls when we leave the loop bool accepted = false; //Was the parse successful? parser.Open(reader); parser.TrimReductions = false; //Please read about this feature before enabling done = false; while (!done) { response = parser.Parse(); switch (response) { case GOLD.ParseMessage.LexicalError: //Cannot recognize token done = true; break; case GOLD.ParseMessage.SyntaxError: //Expecting a different token done = true; break; case GOLD.ParseMessage.Reduction: //Create a customized object to store the reduction parser.CurrentReduction = CreateNewObject(parser.CurrentReduction as GOLD.Reduction); break; case GOLD.ParseMessage.Accept: //Accepted! //program = parser.CurrentReduction //The root node! done = true; accepted = true; break; case GOLD.ParseMessage.TokenRead: //You don't have to do anything here. break; case GOLD.ParseMessage.InternalError: //INTERNAL ERROR! Something is horribly wrong. done = true; break; case GOLD.ParseMessage.NotLoadedError: //This error occurs if the CGT was not loaded. done = true; break; case GOLD.ParseMessage.GroupError: //GROUP ERROR! Unexpected end of file done = true; break; } } //while if (!accepted) Expected = parser.ExpectedSymbols(); return accepted; }