예제 #1
0
        private G.MainEntity                    AddComp(G.Contexts contexts, String id, IEnumerable <IComponent> comps)
        {
            var ent = _contexts.main.CreateEntity(  );
            var generatedNamespace = contexts.settings.hasGeneratedNamespace
                                ? contexts.settings.generatedNamespace.Value
                                : "";
            var fullNamePrefix = String.IsNullOrEmpty(generatedNamespace)
                                ? ""
                                : generatedNamespace + ".";

            ent.AddComp(id, fullNamePrefix + id);
            ent.isParsedByGenEntitasLang = true;
            if (comps == null)
            {
                return(ent);
            }
            foreach (var comp in comps)
            {
                if (comp == null)
                {
                    Console.WriteLine("comp == null");
                    continue;
                }
                var compI = _mainTypesToI[comp.GetType(  )];
                ent.AddComponent(compI, comp);
            }
            return(ent);
        }
예제 #2
0
        private G.MainEntity                    AddAlias(G.Contexts contexts, String key, String value)
        {
            if (!contexts.main.hasAliasComp)
            {
                contexts.main.SetAliasComp(new Dictionary <String, String>(  ));
            }

            var values = _contexts.main.aliasComp.Values;

            values[key] = value;
            _contexts.main.ReplaceAliasComp(values);
            return(_contexts.main.aliasCompEntity);
        }
예제 #3
0
        public GenEntitasLangParser(G.Contexts contexts)
        {
            _contexts = contexts;
            for (var i = 0; i < _contexts.main.contextInfo.componentTypes.Length; i++)
            {
                _mainTypesToI[_contexts.main.contextInfo.componentTypes[i]] = i;
            }

            Comments = new CommentParser(  );

            Identifier =
                from first in Parse.Letter.Once()
                from rest in Parse.LetterOrDigit.XOr(Parse.Char('_')).Many()
                select new string(first.Concat(rest).ToArray());

            QuotedString =
                from openQuote in Parse.Char('"')
                from content in Parse.AnyChar.Except(Parse.Char('"')).Many(  )
                from closeQuote in Parse.Char('"')
                select new String(content.ToArray(  ));

            QuotedIdentifier =
                from openQuote in Parse.Char('"')
                from content in Identifier
                from closeQuote in Parse.Char('"')
                select new String(content.ToArray(  ));

            AliasGet =
                (from aliasKey in Identifier
                 select aliasKey)
                .Select(key =>
            {
                if (!_contexts.main.hasAliasComp || !_contexts.main.aliasComp.Values.ContainsKey(key))
                {
                    throw new KeyNotFoundException($"Alias '{key}' not found");
                }
                return(_contexts.main.aliasComp.Values[key]);
            });

            CompContextNames =
                from contextsKeyword in Parse.String("in")
                from ws in Parse.WhiteSpace.AtLeastOnce(  )
                from contextNames in Identifier.DelimitedBy(Parse.Char(',').Token(  )).Token(  )
                select new G.ContextNamesComp
            {
                Values = contextNames.ToList(  )
            };

            FieldInfo =
                from fieldName in Identifier
                from colon in Parse.Char(':').Token(  )
                from typeName in AliasGet.Or(QuotedString)
                select new G.FieldInfo(typeName, fieldName);

            CompPublicFields =
                from ws in Parse.WhiteSpace.Many(  )
                from publicFieldsKeyword in Parse.String("publicFields")
                from colon in Parse.Char(':').Token(  )
                from fieldInfos in FieldInfo.Token(  ).AtLeastOnce(  )
                select new G.PublicFieldsComp
            {
                Values = fieldInfos.ToList(  )
            };

            CompUnique =
                from uniqueKeyword in Parse.String("unique").Token(  )
                select new G.UniqueComp(  );

            CompParam =
                CompContextNames
                .Or(CompPublicFields)
                .Or(CompUnique)
            ;

            CompEnt =
                from ws11 in Parse.WhiteSpace.Many(  )
                from compKeyword in Parse.String("comp")
                from ws in Parse.WhiteSpace.AtLeastOnce(  )
                from id in Identifier.Token(  )
                from comps in CompParam.XMany(  )
                select AddComp(_contexts, id, comps);

            AliasRule =
                from key in Identifier
                from colon in Parse.Char(':').Token(  )
                from value in QuotedString
                select new KeyValuePair <String, String>(key, value);

            Alias =
                (from ws11 in Parse.WhiteSpace.Many(  )
                 from aliasKeyword in Parse.String("alias")
                 from ws in Parse.WhiteSpace.AtLeastOnce(  )
                 from aliasKvs in AliasRule.Token(  ).AtLeastOnce(  )
                 select aliasKvs)
                .Select(keyValues =>
            {
                foreach (var kv in keyValues)
                {
                    AddAlias(_contexts, kv.Key, kv.Value);
                }
                return(_contexts.main.aliasCompEntity);
            });

            AliasBlock =
                from aliasList in Alias.Many(  )
                select _contexts.main.aliasCompEntity;

            CompBlock =
                from comps in CompEnt.AtLeastOnce(  )
                select comps;

            var anyCharTillComment =
                Parse.AnyChar.Until(Comments.AnyComment).Text(  );

            var anyCharTillLineEnd =
                from s in Parse.AnyChar.Until(Parse.LineEnd).Text(  )
                select s + '\n';

            RemoveCommentsParser =
                (from nonComment in
                 anyCharTillComment
                 .Or(anyCharTillLineEnd)
                 .Or(Parse.AnyChar.Many(  ).Text(  ))
                 select nonComment).Many(  )
                .Select(values => String.Concat(values));

            Root =
                from aliases in AliasBlock.Optional(  )
                from comps in CompBlock
                select _contexts;
        }
 public GenContextsSystem(Contexts contexts) : base(contexts.Get <Main>())
 {
     _contexts = contexts;
 }
예제 #5
0
 public RoslynFixPathToSolutionSystem(Contexts contexts) : base(contexts.Get <Settings>())
 {
 }
예제 #6
0
 public GenCompContextApiSystem(Contexts contexts) : base(contexts.main)
 {
     _contexts = contexts;
 }
 public GenEntitasLangToCompsSystem(Contexts contexts) : base(contexts.main)
 {
     _contexts = contexts;
 }
 public PostProcWriteGenPathsToCsprojSystem(Contexts contexts) : base(contexts.settings)
 {
     _contexts       = contexts;
     _generatedGroup = contexts.main.GetGroup(MainMatcher.AllOf(MainMatcher.GeneratedFileComp).NoneOf(MainMatcher.Destroy));
 }
예제 #9
0
 public SettingsReadFileSystem(Contexts contexts) : base(contexts.settings)
 {
     _contexts = contexts;
 }
 public SettingsSetCoreSettingsSystem(Contexts contexts) : base(contexts.settings)
 {
     _contexts = contexts;
 }
예제 #11
0
 public GenEntitySystem(Contexts contexts) : base(contexts.main)
 {
     _contexts = contexts;
 }
예제 #12
0
 public ReflectionToEntityIndexSystem(Contexts contexts) : base(contexts.main)
 {
     _contexts = contexts;
 }