Example #1
0
		public static void Run(Rule rule, IMessageSink sink, IDictionary<Symbol, Rule> rules, IPGCodeGenHelper codeGen)
		{
			// 1. Scan for a list of code blocks that use $labels, and a list of rules referenced.
			var data = new DataGatheringVisitor(rules, rule);
			if (data.RulesReferenced.Count != 0 || data.OtherReferences.Count != 0 || data.ProperLabels.Count != 0)
			{
				var vsv = new AutoValueSaverVisitor(data, sink, rules, codeGen);
				// 2. Create $result variable if it was used
				// 3. Scan for predicates with labels, and RuleRefs referenced by 
				//    code blocks. For each such predicate, generate a variable at 
				//    the beginning of the rule and set the ResultSaver.
				vsv.Process(rule);
				// 4. Replace recognized $substitutions in code blocks
				vsv.ReplaceSubstitutionsInCodeBlocks();
			}
		}
Example #2
0
        public static void Run(Rule rule, IMessageSink sink, IDictionary <Symbol, Rule> rules, IPGCodeGenHelper codeGen)
        {
            // 1. Scan for a list of code blocks that use $labels, and a list of rules referenced.
            var data = new DataGatheringVisitor(rules, rule);

            if (data.RulesReferenced.Count != 0 || data.OtherReferences.Count != 0 || data.ProperLabels.Count != 0)
            {
                var vsv = new AutoValueSaverVisitor(data, sink, rules, codeGen);
                // 2. Create $result variable if it was used
                // 3. Scan for predicates with labels, and RuleRefs referenced by
                //    code blocks. For each such predicate, generate a variable at
                //    the beginning of the rule and set the ResultSaver.
                vsv.Process(rule);
                // 4. Replace recognized $substitutions in code blocks
                vsv.ReplaceSubstitutionsInCodeBlocks();
            }
        }
Example #3
0
 AutoValueSaverVisitor(DataGatheringVisitor data, IMessageSink sink, IDictionary <Symbol, Rule> rules, IPGCodeGenHelper codeGen)
 {
     _data = data; _sink = sink; _rules = rules; _codeGen = codeGen;
 }
Example #4
0
		AutoValueSaverVisitor(DataGatheringVisitor data, IMessageSink sink, IDictionary<Symbol, Rule> rules, IPGCodeGenHelper codeGen)
			{ _data = data; _sink = sink; _rules = rules; _codeGen = codeGen; }