Beispiel #1
0
 public static void AddVars(List <KeywordUsage> keywordUsages)
 {
     keywordUsages.Add(new KeywordUsage(Glossary.Macros[VariableKeyword.VARS], Glossary.Macros[FunctionKeyword.CLASS_INFO])
     {
         arguments      = ArgumentRange.AtLeast(1),
         onFeedCodeFile = (fileData, codeFile, codeInfos, arguments, data) =>
         {
             return(codeInfos.SetClassVars(arguments));
         }
     });
 }
Beispiel #2
0
 ///-------------------------------------------------------------
 public KeywordUsage(string keyword, string scope)
 {
     this.keyword           = keyword;
     this.scope             = scope;
     keywordUsageType       = KeywordUsageType.Match;
     arguments              = 0;
     needOpenScope          = false;
     needScopeData          = false;
     createNewScriptContent = false;
     onFeedCodeFile         = null;
     onCloseScope           = null;
 }
Beispiel #3
0
 public static void AddDefault(List <KeywordUsage> keywordUsages, string codeBlock)
 {
     keywordUsages.Add(new KeywordUsage(Glossary.Macros[FunctionKeyword.DEFAULT], codeBlock)
     {
         arguments      = ArgumentRange.Between(2, 3),
         onFeedCodeFile = (fileData, codeFile, codeInfos, arguments, data) =>
         {
             codeInfos.classDefaultType       = arguments[0].Content;
             codeInfos.classDefaultValue      = arguments[1].Content;
             codeInfos.classDefaultExportOnly = (arguments.Count == 2 || arguments[2].Content == "false") ? false : true;
             return(true);
         }
     });
 }
Beispiel #4
0
        public static DataTypeSpecification ParseArgument(DataTypeSpecification dataTypeSpecification)
        {
            if (string.IsNullOrEmpty(dataTypeSpecification.Args) || dataTypeSpecification.Arugments.Count > 0)
            {
                return(dataTypeSpecification);
            }

            if (!string.IsNullOrEmpty(dataTypeSpecification.Range))
            {
                string[] argItems   = dataTypeSpecification.Args.Split(ArugumentRangeItemDelimiter);
                string[] rangeItems = dataTypeSpecification.Range.Split(ArugumentRangeItemDelimiter);

                int i = 0;
                foreach (string argItem in argItems)
                {
                    DataTypeArgument argument = new DataTypeArgument()
                    {
                        Name = argItem
                    };

                    if (i < rangeItems.Length)
                    {
                        ArgumentRange range = new ArgumentRange();

                        string[] rangeValues = rangeItems[i].Split(ArugumentRangeValueDelimiter);

                        range.Min = int.Parse(rangeValues[0]);

                        if (rangeValues.Length > 1)
                        {
                            range.Max = int.Parse(rangeValues[1]);
                        }
                        else
                        {
                            range.Max = range.Min;
                        }

                        argument.Range = range;
                    }

                    dataTypeSpecification.Arugments.Add(argument);

                    i++;
                }
            }

            return(dataTypeSpecification);
        }
Beispiel #5
0
        public static void AddDefineContainer(List <KeywordUsage> keywordUsages, string codeBlock)
        {
            keywordUsages.Add(new KeywordUsage(Glossary.Macros[FunctionKeyword.DEFINE_CONTAINER], codeBlock)
            {
                arguments      = 1,
                needOpenScope  = true,
                onFeedCodeFile = (fileData, codeFile, codeInfos, arguments, data) =>
                {
                    codeInfos.blockClassName = arguments[0].Content;
                    return(true);
                }
            });

            keywordUsages.Add(new KeywordUsage(Glossary.Macros[FunctionKeyword.TYPE], Glossary.Macros[FunctionKeyword.DEFINE_CONTAINER])
            {
                arguments      = ArgumentRange.Between(1, 2),
                onFeedCodeFile = (fileData, codeFile, codeInfos, arguments, data) =>
                {
                    codeInfos.blockClassPrefix.Add(arguments[0].Content);
                    if (arguments.Count == 2)
                    {
                        codeInfos.blockClassParent = arguments[1].Content;
                    }
                    return(true);
                }
            });

            keywordUsages.Add(new KeywordUsage(Glossary.Macros[FunctionKeyword.ATTRIBUTES], Glossary.Macros[FunctionKeyword.DEFINE_CONTAINER])
            {
                arguments      = ArgumentRange.AtLeast(1),
                onFeedCodeFile = (fileData, codeFile, codeInfos, arguments, data) =>
                {
                    for (int a = arguments.Count - 1; a >= 0; a--)
                    {
                        codeInfos.blockClassPrefix.Insert(0, arguments[a].Content);
                    }
                    return(true);
                }
            });
        }
Beispiel #6
0
        public static void AddUsing(List <KeywordUsage> keywordUsages, string codeBlock)
        {
            Func <List <IKeyword>, string> feedMethod = (arguments) =>
            {
                var content = string.Empty;
                foreach (var argument in arguments)
                {
                    if (string.IsNullOrEmpty(content))
                    {
                        content += " ";
                    }

                    content += argument.Content;
                }

                return(content);
            };

            keywordUsages.Add(new KeywordUsage(Glossary.Macros[FunctionKeyword.USING], Glossary.Macros[FunctionKeyword.FILE_INFO])
            {
                arguments      = ArgumentRange.AtLeast(1),
                onFeedCodeFile = (fileData, codeFile, codeInfos, arguments, data) =>
                {
                    codeFile.AddNamespace(feedMethod(arguments));
                    return(true);
                }
            });

            keywordUsages.Add(new KeywordUsage(Glossary.Macros[FunctionKeyword.USING], codeBlock)
            {
                arguments      = ArgumentRange.AtLeast(1),
                onFeedCodeFile = (fileData, codeFile, codeInfos, arguments, data) =>
                {
                    codeInfos.AddNamespace(feedMethod(arguments));
                    return(true);
                }
            });
        }