Beispiel #1
0
        public IOReadNode CreateIOReadNode(VariableIdNode idNode, StatementsNode statementsNode, Token t)
        {
            IOReadNode ioReadNode = new IOReadNode(idNode, symbolTable, t);

            statementsNode.Statement = ioReadNode;

            return(ioReadNode);
        }
Beispiel #2
0
        /// <summary>
        /// Visits the IO read node.
        /// </summary>
        /// <returns>An ISemanticCheckValue.</returns>
        /// <param name="node">Node.</param>
        public ISemanticCheckValue VisitIOReadNode(IOReadNode node)
        {
            // read an input
            string input = reader.readLine();

            // select the first word of the input
            input = input.Split(new[] { ' ', '\t', '\n' })[0];

            // set the input to the ioreadnode's assignment
            AssignNode assignNode = node.AssignNode;

            setAssignValue(input, assignNode);
            // execute the assign node
            assignNode.Accept(this);

            return(voidProperty);
        }
Beispiel #3
0
        /// <summary>
        /// Checks the static semantic constraints of an IOReadNode.
        /// </summary>
        /// <returns>An ISemanticCheckValue.</returns>
        /// <param name="node">Node.</param>
        public ISemanticCheckValue VisitIOReadNode(IOReadNode node)
        {
            // check that the id property is ok
            IProperty property = getVariableProperty(node);

            if (property == voidProperty)
            {
                return(voidProperty);
            }

            VariableIdNode idNode = node.IDNode;

            // check that the variable we're about to read into is declared
            checkPropertyDeclared(node, property, true);

            // check that we don't try to read a boolean value
            if (checkPropertyType(property, TokenType.BOOL_VAL))
            {
                analyzer.notifyError(new IllegalTypeError(idNode));
            }

            return(voidProperty);
        }
Beispiel #4
0
 /// <summary>
 /// Visits the IO read node.
 /// </summary>
 /// <returns>An ISemanticCheckValue.</returns>
 /// <param name="node">Node.</param>
 public ISemanticCheckValue VisitIOReadNode(IOReadNode node)
 {
     // nothing to evaluate here, it's done from the ExecutionVisitor
     return(voidProperty);
 }
Beispiel #5
0
 /// <summary>
 /// Visits the IO read node.
 /// </summary>
 /// <returns>An ISemanticCheckValue.</returns>
 /// <param name="node">Node.</param>
 public ISemanticCheckValue VisitIOReadNode(IOReadNode node)
 {
     // return the node's variable's evaluation
     return(node.IDNode.Accept(this));
 }