/// <summary>
        /// Processes the rule name reference.
        /// Depending on the current parser walker context this can be:
        ///  1) new rule definition;
        ///  2) reference to an existing rule from excluded global rules list;
        ///  3) reference to an existing rule from the rule body.
        /// </summary>
        /// <param name="match">Current parse tree node</param>
        private void EnterRuleName(ITextParseTreeNode match)
        {
            var ruleName = match.GetImage();

            if (match.Parent.RuleName == ExtGrammarRules.Rule)
            {
                rules.Add(new RuleInfo {
                    Name = ruleName
                });

                output.Write("{0}Rule", ruleName);
            }
            else
            {
                referencedRules.Add(ruleName);

                if (match.Parent.RuleName == ExtGrammarRules.ExcludedGlobalRules)
                {
                    excludedGlobalRules.Add(ruleName);
                }
                else
                {
                    ruleBodyExpression.AddChild(new RuleExpression(ruleName));
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Writes rule name with additional information (like string literal or character range)
 /// to the output and enters all the matched children rules.
 /// </summary>
 /// <param name="match">Match of the text parser rule</param>
 protected override void WriteMatch(ITextParseTreeNode match)
 {
     if (match.RuleName == ExtGrammarRules.RuleName)
     {
         Write(match.RuleName + " (" + match.GetImage() + ")");
     }
     else if (match.RuleName == ExtGrammarRules.LiteralValue ||
              match.RuleName == ExtGrammarRules.CharacterRange)
     {
         Write(match.RuleName + " " + match.GetImage());
     }
     else
     {
         base.WriteMatch(match);
     }
 }
 /// <summary>
 /// Adds literal value expression ("abc") to the expression tree for the current rule.
 /// </summary>
 /// <param name="match">Current parse tree node</param>
 private void EnterLiteralValue(ITextParseTreeNode match)
 {
     ruleBodyExpression.AddChild(
         new LiteralExpression(match.GetImage()));
 }