IRule IGrammar.CreateRule(string id, RulePublic publicRule, RuleDynamic dynamic, bool hasScript)
        {
            SPCFGRULEATTRIBUTES sPCFGRULEATTRIBUTES = (SPCFGRULEATTRIBUTES)0;

            if (id == _sRoot)
            {
                sPCFGRULEATTRIBUTES |= (SPCFGRULEATTRIBUTES.SPRAF_TopLevel | SPCFGRULEATTRIBUTES.SPRAF_Active | SPCFGRULEATTRIBUTES.SPRAF_Root);
                _hasRoot             = true;
            }
            if (publicRule == RulePublic.True)
            {
                sPCFGRULEATTRIBUTES |= (SPCFGRULEATTRIBUTES.SPRAF_TopLevel | SPCFGRULEATTRIBUTES.SPRAF_Export);
            }
            if (dynamic == RuleDynamic.True)
            {
                sPCFGRULEATTRIBUTES |= SPCFGRULEATTRIBUTES.SPRAF_Dynamic;
            }
            Rule rule = GetRule(id, sPCFGRULEATTRIBUTES);

            if (publicRule == RulePublic.True || id == _sRoot || hasScript)
            {
                _cg._rules.Add(rule);
            }
            return(rule);
        }
Exemple #2
0
        IRule IGrammar.CreateRule(string id, RulePublic publicRule, RuleDynamic dynamic, bool hasScript)
        {
            SrgsRule rule = new(id);

            if (publicRule != RulePublic.NotSet)
            {
                rule.Scope = publicRule == RulePublic.True ? SrgsRuleScope.Public : SrgsRuleScope.Private;
            }
            rule.Dynamic = dynamic;
            return(rule);
        }
        IRule IGrammar.CreateRule(string id, RulePublic publicRule, RuleDynamic dynamic, bool hasScript)
        {
            SrgsRule srgsRule = new SrgsRule(id);

            if (publicRule != RulePublic.NotSet)
            {
                srgsRule.Scope = ((publicRule != 0) ? SrgsRuleScope.Private : SrgsRuleScope.Public);
            }
            srgsRule.Dynamic = dynamic;
            return(srgsRule);
        }
Exemple #4
0
        IRule IGrammar.CreateRule(string id, RulePublic publicRule, RuleDynamic dynamic, bool hasScript)
        {
            SPCFGRULEATTRIBUTES dwRuleAttributes = 0;

            // Determine rule attributes to apply based on RuleScope, IsDynamic, and IsRootRule.
            //  IsRootRule  RuleScope   IsDynamic   Rule Attributes
            //  ----------------------------------------------------------------------
            //  true        *           true        Root | Active | TopLevel | Export | Dynamic
            //  true        *           false       Root | Active | TopLevel | Export
            //  false       internal    true        TopLevel | Export | Dynamic
            //  false       internal    false       TopLevel | Export
            //  false       private     true        Dynamic
            //  false       private     false       0
            if (id == _sRoot)
            {
                dwRuleAttributes |= SPCFGRULEATTRIBUTES.SPRAF_Root | SPCFGRULEATTRIBUTES.SPRAF_Active | SPCFGRULEATTRIBUTES.SPRAF_TopLevel;
                _hasRoot          = true;
            }

            if (publicRule == RulePublic.True)
            {
                dwRuleAttributes |= SPCFGRULEATTRIBUTES.SPRAF_TopLevel | SPCFGRULEATTRIBUTES.SPRAF_Export;
            }

            if (dynamic == RuleDynamic.True)
            {
                // BackEnd supports exported dynamic rules for SRGS grammars.
                dwRuleAttributes |= SPCFGRULEATTRIBUTES.SPRAF_Dynamic;
            }

            // Create rule with specified attributes
            Rule rule = GetRule(id, dwRuleAttributes);

            // Add this rule to the list of rules of the STG list
            if (publicRule == RulePublic.True || id == _sRoot || hasScript)
            {
                _cg._rules.Add(rule);
            }
            return(rule);
        }