public SimpleIfStatement(SimpleContext context, SimpleExpression ifClause, SimpleStatement thenClause, SimpleStatement elseClause) : base(context) { m_ifClause = ifClause; m_thenClause = thenClause; m_elseClause = elseClause; }
public SimpleBinaryExpression(SimpleContext context, SimpleExpression leftOperand, string op, SimpleExpression rightOperand) : base(context) { m_leftOperand = leftOperand; m_operator = op; m_rightOperand = rightOperand; }
public SimpleSyntaxNode(SimpleContext context) { m_context = context; }
public SimpleID(SimpleContext context, string name) : base(context) { m_name = name; }
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 SimpleAssignmentStatement(SimpleContext context, string name, SimpleExpression assignValue) : base(context) { m_name = name; m_assignValue = assignValue; }
public SimpleStatementList(SimpleContext context, SimpleStatement currentStatement, SimpleStatement nextStatement) : base(context) { m_currentStatement = currentStatement; m_nextStatement = nextStatement; }
public SimpleWhileStatement(SimpleContext context, SimpleExpression whileClause, SimpleStatement doClause) : base(context) { m_whileClause = whileClause; m_doClause = doClause; }
public SimpleString(SimpleContext context, string text) : base(context) { m_value = text; }
public SimpleExpression(SimpleContext context) : base(context) { }
public SimpleDisplayStatement(SimpleContext context, SimpleExpression displayClause, string readID) : base(context) { m_displayClause = displayClause; m_readID = readID; }
public SimpleNegate(SimpleContext context, SimpleExpression expression) : base(context) { m_expr = expression; }
public SimpleNumber(SimpleContext context, double value) : base(context) { m_value = value; }
public SimpleStatement(SimpleContext context) : base(context) { }