public SimpleStatementList(SimpleContext context, SimpleStatement currentStatement, SimpleStatement nextStatement) : base(context) { m_currentStatement = currentStatement; m_nextStatement = nextStatement; }
private bool DoParse() { //This procedure starts the GOLD Parser Engine and handles each of the //messages it returns. Each time a reduction is made, a new instance of a //"Simple" object is created and stored in the parse tree. The resulting tree //will be a pure representation of the Simple language and will be ready to //implement. StringReader reader = new StringReader(txtProgram.Text); Parser parser = new Parser(reader, m_grammar); parser.TrimReductions = true; m_context = new SimpleContext(parser); while (true) { switch (parser.Parse()) { case ParseMessage.LexicalError: Log("LEXICAL ERROR. Line " + parser.LineNumber + ". Cannot recognize token: " + parser.TokenText); return(false); case ParseMessage.SyntaxError: StringBuilder text = new StringBuilder(); foreach (Symbol tokenSymbol in parser.GetExpectedTokens()) { text.Append(' '); text.Append(tokenSymbol.ToString()); } Log("SYNTAX ERROR. Line " + parser.LineNumber + ". Expecting:" + text.ToString()); return(false); case ParseMessage.Reduction: //== Create a new customized object and replace the //== CurrentReduction with it. This saves memory and allows //== easier interpretation parser.TokenSyntaxNode = m_context.GetSimpleObject(); break; case ParseMessage.Accept: //=== Success! m_program = (SimpleStatement)parser.TokenSyntaxNode; Log("-- Program Accepted --"); return(true); case ParseMessage.TokenRead: //=== Make sure that we store token string for needed tokens. parser.TokenSyntaxNode = m_context.GetTokenText(); break; case ParseMessage.InternalError: Log("INTERNAL ERROR! Something is horribly wrong"); return(false); case ParseMessage.NotLoadedError: //=== Due to the if-statement above, this case statement should never be true Log("NOT LOADED ERROR! Compiled Grammar Table not loaded"); return(false); case ParseMessage.CommentError: Log("COMMENT ERROR! Unexpected end of file"); return(false); case ParseMessage.CommentBlockRead: //=== Do nothing break; case ParseMessage.CommentLineRead: //=== Do nothing break; } } }
public SimpleWhileStatement(SimpleContext context, SimpleExpression whileClause, SimpleStatement doClause) : base(context) { m_whileClause = whileClause; m_doClause = doClause; }