コード例 #1
0
        public void Parse()
        {
            CheckParse(
                "12345",
                ConstantTest.MakeArray(new DecimalConstant(12345)),
                TokenType.EndOfToken,
                "10 進定数");
            CheckParse(
                "#ABCD",
                ConstantTest.MakeArray(new HexaDecimalConstant(0xABCD)),
                TokenType.EndOfToken,
                "16 進定数");
            CheckParse(
                "'abc'",
                ConstantTest.MakeArray(new StringConstant("abc")),
                TokenType.EndOfToken,
                "文字定数");
            CheckParse(
                "L001",
                ConstantTest.MakeArray(new AddressConstant("L001")),
                TokenType.EndOfToken,
                "アドレス定数");
            CheckParse(
                "12345,#ABCD,'StrConst',L001",
                ConstantTest.MakeArray(
                    new DecimalConstant(12345),
                    new HexaDecimalConstant(0xABCD),
                    new StringConstant("StrConst"),
                    new AddressConstant("L001")),
                TokenType.EndOfToken,
                "定数の並び");

            CheckParse(
                String.Empty, null, DontCare,
                "空文字列でオペランドなし => エラー, 1 つ以上の定数が必要");
            CheckParse(
                "123,", null, DontCare,
                "コンマに続く定数なし => エラー, コンマがあれば続いて定数が必要");
            CheckParse(
                "'abc'123",
                ConstantTest.MakeArray(new StringConstant("abc")),
                TokenType.DecimalConstant,
                "区切りのコンマがない => コンマがなければ、解釈はそこまで");
        }
コード例 #2
0
        public void ReadOperand()
        {
            const Constant[] DontCare = null;

            CheckReadOperand(
                "'StrConst',12345,L001,#ABCD", true,
                ConstantTest.MakeArray(
                    new StringConstant("StrConst"),
                    new DecimalConstant(12345),
                    new AddressConstant("L001"),
                    new HexaDecimalConstant(0xABCD)),
                "定数の並び");
            CheckReadOperand(
                String.Empty, false, DontCare,
                "空文字列でオペランドなし => エラー, 1 つ以上の定数が必要");
            CheckReadOperand(
                "; コメント", false, DontCare,
                "コメントでオペランドなし => エラー, 1 つ以上の定数が必要");
            CheckReadOperand(
                "'abc'123", false, DontCare,
                "区切りのコンマではなく別の字句要素がある => エラー");
        }