예제 #1
0
        public Language(ParseBlock Block)
        {
            Block.AddParser <Sound>("sound",
                                    i =>
            {
                var s = new Sound(i);
                AddSound(s);
                return(s);
            });
            Block.AddParser <Generator <Sound> >("generator",
                                                 i =>
            {
                var g = new SingleGenerator <Sound>(i, OPERATORS, _Generators);
                _Generators.Add(i.Name, g);
                return(g);
            });
            Block.AddParser <ReplaceRule <Sound> >("replacer", i => new ReplaceRule <Sound>(i, OPERATORS, _Generators));
            Block.AddParser <PrintRule <Sound> >("orthography", i => new PrintRule <Sound>(i, OPERATORS, _Generators));

            object[] attributes = Block.BreakToAttributes <object>(typeof(Attribute));
            _Replacers = (List <ReplaceRule <Sound> >)attributes[(int)Attribute.REPLACERS];
            _Printers  = (List <PrintRule <Sound> >)attributes[(int)Attribute.ORTHOGRAPHY];
            _Primary   = _Generators.Last().Value;
        }
예제 #2
0
 public ReplaceRule(ParseBlock Block, List <Operator <T> > Operators, Dictionary <string, Generator <T> > Generators)
 {
     string[] def = Block.String.Split(new string[] { "=>" }, StringSplitOptions.None);
     _Match       = new MatchRule <T>(def[0], Operators, Generators);
     _Replacement = new SingleGenerator <T>(def[1], Operators, Generators);
 }