当前位置: 首页>>代码示例>>C#>>正文


C# Symbol.SetCustomValue方法代码示例

本文整理汇总了C#中Symbol.SetCustomValue方法的典型用法代码示例。如果您正苦于以下问题:C# Symbol.SetCustomValue方法的具体用法?C# Symbol.SetCustomValue怎么用?C# Symbol.SetCustomValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symbol的用法示例。


在下文中一共展示了Symbol.SetCustomValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSymbols

        public List<Symbol> GetSymbols(GraphPath<Token, Token> path)
        {
            List<Symbol> symbols = new List<Symbol>();
            foreach (var item in path.Nodes.Skip(1))
            {
                var terminal = Syn.Grammar.Terminals.FirstOrDefault(t =>
                        t.Name == item.Info.RecToken.Name);

                if (terminal != null)
                {
                    var symbol = new Symbol(terminal.Id, terminal.Name, true, terminal.Value);
                    symbol.SetCustomValue("Token", item.Info);
                    symbols.Add(symbol);
                }
            }

            return symbols;
        }
开发者ID:rodvieirasilva,项目名称:Compiler-With-Fuzzy,代码行数:18,代码来源:CompilerFuzzy.cs

示例2: CompilerXmlParser


//.........这里部分代码省略.........

                    if (symbolXml.Attributes("terminal").Any())
                    {
                        terminal = Convert.ToBoolean(symbolXml.Attribute("terminal").Value);
                    }

                    string tempTokenReference = string.Empty;
                    int recTokenId = 0;

                    if (symbolXml.Attributes("recTokenId").Any())
                    {
                        tempTokenReference = symbolXml.Attribute("recTokenId").Value;
                        if (!string.IsNullOrWhiteSpace(tempTokenReference))
                            recTokenId = Convert.ToInt32(tempTokenReference);
                    }

                    if (string.IsNullOrWhiteSpace(tempTokenReference) && symbolXml.Attributes("recTokenName").Any())
                    {
                        tempTokenReference = symbolXml.Attribute("recTokenName").Value;
                    }

                    string temp = symbolXml.Attribute("charValue").Value;
                    if (string.IsNullOrWhiteSpace(temp))
                    {
                        temp = "\0";
                    }
                    char value = temp[0];
                    Symbol symbol = new Symbol(id, name, terminal, value);

                    if (terminal)
                    {
                        if (recTokenId > 0)
                        {
                            symbol.SetCustomValue("RecToken", RecsTokens.First(rt => rt.Id == recTokenId));
                        }
                        else if (!string.IsNullOrWhiteSpace(tempTokenReference))
                        {
                            symbol.SetCustomValue("RecToken", RecsTokens.First(rt => rt.Name == tempTokenReference));
                        }

                        Grammar.Terminals.Add(symbol);
                    }
                    else
                    {
                        bool variableInitial = false;
                        if (symbolXml.Attribute("variableInitial") != null)
                            variableInitial = Convert.ToBoolean(symbolXml.Attribute("variableInitial").Value);

                        if (variableInitial)
                        {
                            Grammar.VariableStart = symbol;
                        }
                        Grammar.Variables.Add(symbol);
                    }
                }

                int idRules = 100;
                var rulesXml = xdoc.Element("Compiler").Element("Grammar").Element("Rules").Elements("Rule");

                foreach (var ruleXml in rulesXml)
                {

                    bool gotoEmpty = false;
                    string sourceName = ruleXml.Attribute("sourceName").Value;

                    if (sourceName.Contains("normalAnnotation"))
开发者ID:rodvieirasilva,项目名称:Compiler-With-Fuzzy,代码行数:67,代码来源:CompilerXmlParser.cs

示例3: Compiler4

        private CompilerFuzzy Compiler4()
        {
            //LR(1)
            //0. S
            //0 → S$
            //1. S → V = E
            //2. S → E
            //3. E → V
            //4. V → x
            //5. V → ∗E
            List<RecognitionToken> recs = new List<RecognitionToken>();
            var requal = new RecognitionToken(1, "equal", "=", "#7bf6b6", norm, conorm);
            var rast = new RecognitionToken(2, "ast", "*", "#f28686", norm, conorm);
            var rx = new RecognitionToken(3, "x", "x", "#fbdb65", norm, conorm);
            recs.Add(requal);
            recs.Add(rast);
            recs.Add(rx);

            Grammar grammar = new Grammar();
            var x = new Symbol(1, "x", true, 'x');
            x.SetCustomValue("RecToken", rx);

            var ast = new Symbol(2, "*", true, '*');
            ast.SetCustomValue("RecToken", rast);

            var equal = new Symbol(3, "=", true, '=');
            equal.SetCustomValue("RecToken", requal);

            var S = new Symbol(4, "S", false);
            var V = new Symbol(5, "V", false);
            var V1 = new Symbol(7, "V1", false);
            var E = new Symbol(6, "E", false);

            grammar.Terminals.AddRange(new SymbolList(x, ast, equal));

            grammar.Variables.AddRange(new SymbolList(S, V, E, V1));
            grammar.VariableStart = S;
            grammar.AddRule(S, V, equal, E);
            grammar.AddRule(S, E);
            grammar.AddRule(E, V);
            grammar.AddRule(E, V1).Pertinence = 0.8;
            var ruleV = grammar.AddRule(V, x);
            grammar.AddRule(V1, equal).Parent = ruleV;
            grammar.AddRule(V, ast, E);

            return new CompilerFuzzy(recs, grammar, null, null, norm, conorm);
        }
开发者ID:rodvieirasilva,项目名称:Compiler-With-Fuzzy,代码行数:47,代码来源:FrmCompilerWithFuzzy.cs


注:本文中的Symbol.SetCustomValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。