Esempio n. 1
0
        private MyAutomatonNode createForRrRmRi()
        {
            var rootR = new MyAutomatonNode(
                new List <Enum> {
                TT.Register
            }, OST.NotAccepting, Resources.CommaExpectedMsgFormat);

            var rootRComma = new MyAutomatonNode(
                new List <Enum> {
                TT.Comma
            }, OST.NotAccepting, Resources.Valid2ndOpExpectedMsgFormat);

            var rootRCommaR = new MyAutomatonNode(
                new List <Enum> {
                TT.Register
            }, OST.RR, Resources.EndOfCmdExpectedMsgFormat);

            var rootRCommaM = new MyAutomatonNode(
                new List <Enum> {
                TT.Identifier
            }, OST.RM, Resources.EndOfCmdExpectedMsgFormat);

            var rootRCommaConst = new MyAutomatonNode(
                new List <Enum> {
                TT.BinConstant,
                TT.DecConstant,
                TT.HexConstant
            },
                OST.RI, Resources.EndOfCmdExpectedMsgFormat);

            rootRComma.AddChildren(rootRCommaR, rootRCommaM, rootRCommaConst);
            rootR.AddChild(rootRComma);

            return(rootR);
        }
Esempio n. 2
0
        public void Construct()
        {
            _constructedInstance = new MyAutomatonNode(
                null, OST.NotAccepting, Resources.IdfCmdExpectedMsgFormat);

            // Label:
            var labelNode = createForIdentifier();
            var colonNode = createForColon();

            var dbNode = createForDirectives(DT.DB);

            dbNode.AddChild(createForDbMemCellInitializer());

            var dwNode = createForDirectives(DT.DW);

            dwNode.AddChild(createForDwMemCellInitializer());

            labelNode.AddChildren(colonNode, dbNode, dwNode);

            _constructedInstance.AddChild(labelNode);

            constructMovAddSubAndOrXor(colonNode);
            constructImul(colonNode);
            constructIdiv(colonNode);
            constructNot(colonNode);
            constructJmp(colonNode);
            constructJe(colonNode);
            constructJne(colonNode);
            constructInt(colonNode);
            constructLea(colonNode);
        }
Esempio n. 3
0
        private void constructLea(MyAutomatonNode colonNode)
        {
            var leaNode = createForCommands(CommandType.LEA);

            leaNode.AddChild(createForRm());

            colonNode.AddChild(leaNode);
            _constructedInstance.AddChild(leaNode);
        }
Esempio n. 4
0
        private void constructJne(MyAutomatonNode colonNode)
        {
            var jneNode = createForCommands(CommandType.JNE);

            jneNode.AddChild(createForM());

            colonNode.AddChild(jneNode);
            _constructedInstance.AddChild(jneNode);
        }
Esempio n. 5
0
        private void constructInt(MyAutomatonNode colonNode)
        {
            var intNode = createForCommands(CommandType.INT);

            intNode.AddChild(createForI());

            colonNode.AddChild(intNode);
            _constructedInstance.AddChild(intNode);
        }
Esempio n. 6
0
        private void constructNot(MyAutomatonNode colonNode)
        {
            var notNode = createForCommands(CommandType.NOT);

            notNode.AddChildren(createForR(), createForM());

            colonNode.AddChild(notNode);
            _constructedInstance.AddChild(notNode);
        }
Esempio n. 7
0
        private void constructJmp(MyAutomatonNode colonNode)
        {
            var jmpNode = createForCommands(CommandType.JMP);

            jmpNode.AddChild(createForM());

            colonNode.AddChild(jmpNode);
            _constructedInstance.AddChild(jmpNode);
        }
Esempio n. 8
0
        private void constructMovAddSubAndOrXor(MyAutomatonNode colonNode)
        {
            Enum[] commands = new Enum[] {
                CommandType.MOV,
                CommandType.ADD, CommandType.SUB,
                CommandType.AND, CommandType.OR, CommandType.XOR
            };

            var movAddSubAndOrXorNode = createForCommands(commands);

            movAddSubAndOrXorNode.AddChildren(createForRrRmRi(), createForMrMi());

            colonNode.AddChild(movAddSubAndOrXorNode);
            _constructedInstance.AddChild(movAddSubAndOrXorNode);
        }
Esempio n. 9
0
        private void constructIdiv(MyAutomatonNode colonNode)
        {
            var idivNode = createForCommands(CommandType.IDIV);

            //idivNode.AddChildren(createForAR(), createForAM());
            idivNode.AddChildren(createForR(), createForM());

            colonNode.AddChild(idivNode);
            _constructedInstance.AddChild(idivNode);
        }
Esempio n. 10
0
        private void constructImul(MyAutomatonNode colonNode)
        {
            var imulNode = createForCommands(CommandType.IMUL);

            imulNode.AddChild(createForArRrRriRmRmi());
            imulNode.AddChild(createForAM());

            colonNode.AddChild(imulNode);
            _constructedInstance.AddChild(imulNode);
        }
Esempio n. 11
0
        private MyAutomatonNode createForRm()
        {
            var rootR = new MyAutomatonNode(
                new List <Enum> {
                TT.Register
            }, OST.NotAccepting, Resources.CommaExpectedMsgFormat);

            var rootRComma = new MyAutomatonNode(
                new List <Enum> {
                TT.Comma
            }, OST.NotAccepting, Resources.Valid2ndOpExpectedMsgFormat);

            var rootRCommaM = new MyAutomatonNode(
                new List <Enum> {
                TT.Identifier
            }, OST.RM, Resources.EndOfCmdExpectedMsgFormat);

            rootRComma.AddChildren(rootRCommaM);
            rootR.AddChild(rootRComma);

            return(rootR);
        }
Esempio n. 12
0
        private MyAutomatonNode createForArRrRriRmRmi()
        {
            var rootR = new MyAutomatonNode(
                new List <Enum> {
                TT.Register
            }, OST.AR, Resources.CommaExpectedMsgFormat);

            var rootRComma = new MyAutomatonNode(
                new List <Enum> {
                TT.Comma
            }, OST.NotAccepting, Resources.Valid2ndOpExpectedMsgFormat);

            rootR.AddChild(rootRComma);

            // First branch.
            var rootRCommaR = new MyAutomatonNode(
                new List <Enum> {
                TT.Register
            }, OST.RR, Resources.CommaExpectedMsgFormat);

            var rootRCommaRComma = new MyAutomatonNode(
                new List <Enum> {
                TT.Comma
            }, OST.NotAccepting, Resources.Valid3rdOpExpectedMsgFormat);

            var rootRCommaRCommaI = new MyAutomatonNode(
                new List <Enum> {
                TT.BinConstant,
                TT.DecConstant,
                TT.HexConstant
            },
                OST.RRI, Resources.EndOfCmdExpectedMsgFormat);

            rootRCommaR.AddChild(rootRCommaRComma);
            rootRCommaRComma.AddChild(rootRCommaRCommaI);

            // Second branch.
            var rootRCommaM = new MyAutomatonNode(
                new List <Enum> {
                TT.Identifier
            }, OST.RM, Resources.CommaExpectedMsgFormat);

            var rootRCommaMComma = new MyAutomatonNode(
                new List <Enum> {
                TT.Comma
            }, OST.NotAccepting, Resources.Valid3rdOpExpectedMsgFormat);

            var rootRCommaMCommaI = new MyAutomatonNode(
                new List <Enum> {
                TT.BinConstant,
                TT.DecConstant,
                TT.HexConstant
            },
                OST.RMI, Resources.EndOfCmdExpectedMsgFormat);

            rootRCommaM.AddChild(rootRCommaMComma);
            rootRCommaMComma.AddChild(rootRCommaMCommaI);

            // Final.
            rootRComma.AddChildren(rootRCommaR, rootRCommaM);

            return(rootR);
        }