예제 #1
0
 public void Interpret(ContextH ContextH)
 {
     if (ContextH.HexValue.Contains("C"))
     {
         ContextH.OndalikValue += 12;
     }
 }
예제 #2
0
    { //Nonterminal değerlendirmeye alınmadı
        public static void Main(string[] args)
        {
            ContextH c = new ContextH {
                HexValue = "ABCABB"
            };
            List <ITerminalExpression> ExpList = new List <ITerminalExpression>();

            foreach (char item in c.HexValue.ToCharArray())
            {
                switch (item)
                {
                case 'A':
                    ExpList.Add(new TerminalIExpA());
                    break;

                case 'B':
                    ExpList.Add(new TerminalIExpB());
                    break;

                case 'C':
                    ExpList.Add(new TerminalIExpC());
                    break;

                default:
                    throw new Exception("Geçersiz karakter" + item);
                }
            }

            foreach (ITerminalExpression item in ExpList)
            {
                item.Interpret(c);
            }
            Console.WriteLine(c.OndalikValue);

            Console.ReadKey();
        }