コード例 #1
0
ファイル: SimpleIfStatement.cs プロジェクト: Rolf321/p4
 public SimpleIfStatement(SimpleContext context, SimpleExpression ifClause,
                          SimpleStatement thenClause, SimpleStatement elseClause) : base(context)
 {
     m_ifClause   = ifClause;
     m_thenClause = thenClause;
     m_elseClause = elseClause;
 }
コード例 #2
0
 public SimpleBinaryExpression(SimpleContext context,
                               SimpleExpression leftOperand, string op, SimpleExpression rightOperand)
     : base(context)
 {
     m_leftOperand  = leftOperand;
     m_operator     = op;
     m_rightOperand = rightOperand;
 }
コード例 #3
0
 public SimpleSyntaxNode(SimpleContext context)
 {
     m_context = context;
 }
コード例 #4
0
ファイル: SimpleID.cs プロジェクト: Rolf321/p4
 public SimpleID(SimpleContext context, string name) : base(context)
 {
     m_name = name;
 }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: Rolf321/p4
        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;
                }
            }
        }
コード例 #6
0
 public SimpleAssignmentStatement(SimpleContext context,
                                  string name, SimpleExpression assignValue) : base(context)
 {
     m_name        = name;
     m_assignValue = assignValue;
 }
コード例 #7
0
ファイル: SimpleStatementList.cs プロジェクト: Rolf321/p4
 public SimpleStatementList(SimpleContext context,
                            SimpleStatement currentStatement, SimpleStatement nextStatement) : base(context)
 {
     m_currentStatement = currentStatement;
     m_nextStatement    = nextStatement;
 }
コード例 #8
0
ファイル: SimpleWhileStatement.cs プロジェクト: Rolf321/p4
 public SimpleWhileStatement(SimpleContext context, SimpleExpression whileClause,
                             SimpleStatement doClause) : base(context)
 {
     m_whileClause = whileClause;
     m_doClause    = doClause;
 }
コード例 #9
0
		public SimpleString(SimpleContext context, string text) : base(context)
		{	
			m_value = text;
		}
コード例 #10
0
 public SimpleExpression(SimpleContext context) : base(context)
 {
 }
コード例 #11
0
 public SimpleDisplayStatement(SimpleContext context,
                               SimpleExpression displayClause, string readID) : base(context)
 {
     m_displayClause = displayClause;
     m_readID        = readID;
 }
コード例 #12
0
ファイル: SimpleNegate.cs プロジェクト: Rolf321/p4
 public SimpleNegate(SimpleContext context, SimpleExpression expression)
     : base(context)
 {
     m_expr = expression;
 }
コード例 #13
0
 public SimpleNumber(SimpleContext context, double value) : base(context)
 {
     m_value = value;
 }
コード例 #14
0
ファイル: SimpleStatement.cs プロジェクト: Rolf321/p4
 public SimpleStatement(SimpleContext context) : base(context)
 {
 }