Esempio n. 1
0
        public void ParseVarBindAssignmentTest()
        {
            //Create parser
            StatementParser   statementParser     = new StatementParser(Init("var1 = \"test\";"));
            VarBindAssignment parsedVarAssignment = statementParser.ParseVarBindAssignment();

            //Test VarBindAssignment
            Assert.AreEqual("var1", parsedVarAssignment.GetIdentifier());
            Assert.AreEqual(typeof(TextExpression), parsedVarAssignment.GetExpression().GetType());
            Assert.AreEqual("\"test\"", parsedVarAssignment.GetExpression().ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// Parser for VarBindAssignment
        /// </summary>
        /// <returns>Parsed VarBindAssignment</returns>
        public VarBindAssignment ParseVarBindAssignment()
        {
            VarBindAssignment varBindAssignment = new VarBindAssignment();

            //Parse identifier
            CurrentToken = TokenStream.NextToken();
            varBindAssignment.SetIdentifier(CurrentToken.GetValue().ToString());

            //Skip = token
            NextToken("=", "identifier = expression;", '=');

            //Parse expression
            varBindAssignment.SetExpression(expressionParser.ParseExpression());

            //Skip ; token
            NextToken(";", "identifier = expression;", ';');

            return(varBindAssignment);
        }
Esempio n. 3
0
 /// <summary>
 /// Interpret VarBindAssignment
 /// </summary>
 /// <param name="assignment">VarBindAssignment to interpret</param>
 public override void Visit(VarBindAssignment assignment)
 {   //Add variable to SymbolTable
     SymbolTable.AddVariableDefinition(assignment.GetIdentifier(), assignment.GetExpression());
 }
Esempio n. 4
0
 public virtual void Visit(VarBindAssignment assignment)
 {
     VisitSubNodes(assignment);
 }
Esempio n. 5
0
 /// <summary>
 /// Visit VarBindAssignment
 /// </summary>
 /// <param name="assignment">VarBindAssignment to check</param>
 public override void Visit(VarBindAssignment assignment)
 {
     assignment.GetExpression().AcceptVisitor(this);
     SymbolTable.AddVariableDefinition(assignment.GetIdentifier(), assignment.GetExpression());
 }