Esempio n. 1
0
 void AddSemanticRule(Rule rule, SemanticRule semanticRule)
 {
     if (rule != null)
     {
         rule.SemanticRules.Add(semanticRule);
     }
 }
Esempio n. 2
0
        public Production(SemanticRule rule)
            : base()
        {
#if GATHERING_STATS
            InstanceCount++;
#endif
            this.rule = rule;
        }
Esempio n. 3
0
 public Production(Production p)
     : this()
 {
     this.rule = p.rule;
     for (int i = 0; i < p.Count; i++)
     {
         Add(p[i]);
     }
 }
Esempio n. 4
0
 public LR1ParsableLanguage(
     Language l,
     TypedShakeSelector <string> selector,
     Cortex.Grammar.Grammar g,
     string terminateSymbol,
     SemanticRule onAccept,
     bool supressMessages,
     Func <Token <string>, bool> shouldKeep)
     : this(l, selector,
            new LR1Parser(g, terminateSymbol, onAccept, supressMessages),
            shouldKeep)
 {
 }
Esempio n. 5
0
 public EnhancedLR1ParsableLanguage(
     Language l,
     TypedShakeSelector <string> selector,
     EnhancedGrammar g,
     string terminateSymbol,
     EnhancedParsingTable table,
     SemanticRule onAccept,
     Func <Token <string>, bool> shouldKeep)
     : this(l, selector,
            new EnhancedLR1Parser(g, terminateSymbol, table, onAccept),
            shouldKeep)
 {
 }
Esempio n. 6
0
 public LR1ParsableLanguage(
     Language l,
     TypedShakeSelector <string> selector,
     Cortex.Grammar.Grammar g,
     string terminateSymbol,
     LR1ParsingTable table,
     LR1GotoTable gotoTable,
     SemanticRule onAccept,
     Func <Token <string>, bool> shouldKeep)
     : this(l, selector,
            new LR1Parser(g, terminateSymbol, table, gotoTable, onAccept),
            shouldKeep)
 {
 }
Esempio n. 7
0
        public void Define_rule()
        {
            var conditions = new[]
                {
                    Conditions.NotNull((Order x) => x.Customer),
                };

            var consequences = new[]
                {
                    Consequences.Delegate((Order o) => _result = o),
                };

            Rule rule = new SemanticRule("RuleA", conditions, consequences);

            _engine = RulesEngineFactory.New(x => x.Add(rule));
        }
Esempio n. 8
0
        public void Define_rule()
        {
            var conditions = new[]
            {
                Conditions.NotNull((Order x) => x.Customer),
            };

            var consequences = new[]
            {
                Consequences.Delegate((Order o) => _result = o),
            };

            Rule rule = new SemanticRule("RuleA", conditions, consequences);

            _engine = RulesEngineFactory.New(x => x.Add(rule));
        }
        public void Define_rule()
        {
            var conditions = new[]
            {
                Conditions.GreaterThan((Order x) => x.Amount, 10000.0m),
            };

            var consequences = new[]
            {
                Consequences.Delegate((Order o) => _result = o),
            };

            Rule rule = new SemanticRule("RuleA", conditions, consequences);

            _engine = RulesEngineFactory.New(x => x.Add(rule));
        }
Esempio n. 10
0
        public void Define_rule()
        {
            var conditions = new[]
                {
                    Conditions.GreaterThan((Order x) => x.Amount, 10000.0m),
                };

            var consequences = new[]
                {
                    Consequences.Delegate((Order o) => _result = o),
                };

            Rule rule = new SemanticRule("RuleA", conditions, consequences);

            _engine = RulesEngineFactory.New(x => x.Add(rule));
        }
Esempio n. 11
0
        public void Define_rule()
        {
            _results = new List<Tuple<OrderLine, int>>();

            var conditions = new[]
                {
                    Conditions.Each<Order, IList<OrderLine>, OrderLine>(x => x.Lines),
                };

            var consequences = new[]
                {
                    Consequences.Delegate((Token<Token<Order, IList<OrderLine>>, Tuple<OrderLine, int>> x) => _results.Add(x.Item2))
                };

            Rule rule = new SemanticRule("RuleA", conditions, consequences);

            _engine = RulesEngineFactory.New(x => x.Add(rule));
        }
Esempio n. 12
0
        public void Define_rule()
        {
            _results = new List <Tuple <OrderLine, int> >();

            var conditions = new[]
            {
                Conditions.Each <Order, IList <OrderLine>, OrderLine>(x => x.Lines),
            };

            var consequences = new[]
            {
                Consequences.Delegate((Token <Token <Order, IList <OrderLine> >, Tuple <OrderLine, int> > x) => _results.Add(x.Item2))
            };

            Rule rule = new SemanticRule("RuleA", conditions, consequences);

            _engine = RulesEngineFactory.New(x => x.Add(rule));
        }
Esempio n. 13
0
        public void Define_rule()
        {
            _results = new List <Order>();

            var conditions = new[]
            {
                Conditions.Exists((Order x) => x.Lines),
            };

            var consequences = new[]
            {
                Consequences.Delegate((Order o) => _results.Add(o)),
            };

            Rule rule = new SemanticRule("RuleA", conditions, consequences);

            _engine = RulesEngineFactory.New(x => x.Add(rule));
        }
Esempio n. 14
0
        public void Define_rule()
        {
            _results = new List<Order>();

            var conditions = new[]
                {
                    Conditions.Exists((Order x) => x.Lines),
                };

            var consequences = new[]
                {
                    Consequences.Delegate((Order o) => _results.Add(o)),
                };

            Rule rule = new SemanticRule("RuleA", conditions, consequences);

            _engine = RulesEngineFactory.New(x => x.Add(rule));
        }
Esempio n. 15
0
 public EnhancedLR1ParsableLanguage(
     string name,
     string version,
     string idType,
     IEnumerable <Comment> comments,
     IEnumerable <Symbol> symbols,
     IEnumerable <RegexSymbol> regexSymbols,
     IEnumerable <Keyword> keywords,
     TypedShakeSelector <string> selector,
     EnhancedGrammar g,
     string terminateSymbol,
     SemanticRule onAccept,
     bool supressMessages,
     Func <Token <string>, bool> shouldKeep)
     : this(new Language(name, version, idType,
                         comments, symbols, regexSymbols,
                         keywords), selector, g, terminateSymbol, onAccept, supressMessages,
            shouldKeep)
 {
 }
Esempio n. 16
0
 public LR1ParsableLanguage(
     string name,
     string version,
     string idType,
     IEnumerable <Comment> comments,
     IEnumerable <Symbol> symbols,
     IEnumerable <RegexSymbol> regexSymbols,
     IEnumerable <Keyword> keywords,
     TypedShakeSelector <string> selector,
     Cortex.Grammar.Grammar g,
     string terminateSymbol,
     LR1ParsingTable table,
     LR1GotoTable gotoTable,
     SemanticRule onAccept,
     Func <Token <string>, bool> shouldKeep)
     : this(new Language(name, version, idType,
                         comments, symbols, regexSymbols,
                         keywords), selector, g, terminateSymbol, table, gotoTable, onAccept,
            shouldKeep)
 {
 }
Esempio n. 17
0
 public void AddSemanticRule(SemanticRule semanticRule)
 {
     AddSemanticRule(this, semanticRule);
 }
Esempio n. 18
0
 public EnhancedLR1Parser(EnhancedGrammar g, EnhancedParsingTable table, SemanticRule r) : this(g, DEFAULT_TERMINATE_SYMBOL, table, r)
 {
 }
Esempio n. 19
0
 public EnhancedLR1Parser(EnhancedGrammar g, string terminateSymbol, EnhancedParsingTable table, SemanticRule r)
     : base(g, terminateSymbol, r, true, false)
 {
     this.table = table;
     baseToken  = new Token <string>(TerminateSymbol, TerminateSymbol, TerminateSymbol.Length);
     stateStack = new Stack <object>();
     initial    = new LookaheadRule(TerminateSymbol, TargetGrammar[0]);
 }
Esempio n. 20
0
 public LR1Parser(Cortex.Grammar.Grammar g, LR1ParsingTable table, LR1GotoTable gotoTable, SemanticRule r) : this(g, DEFAULT_TERMINATE_SYMBOL, table, gotoTable, r)
 {
 }
Esempio n. 21
0
		void AddSemanticRule (Rule rule, SemanticRule semanticRule)
		{
			if (rule != null)
				rule.SemanticRules.Add (semanticRule);
		}
Esempio n. 22
0
 public void Identifier_DoesntMatch_Rule(string sample)
 {
     Assert.False(SemanticRule.MatchesRule(sample).HasPassed);
 }
Esempio n. 23
0
 public LR1Parser(Cortex.Grammar.Grammar g, string terminateSymbol, SemanticRule r, bool supressMessages)
     : base(g, terminateSymbol, r, supressMessages, true)
 {
 }
Esempio n. 24
0
 protected AbstractLR1Parser(AbstractGrammar <R, Encoding> g, string terminateSymbol,
                             SemanticRule r, bool suppressMessages, bool setupRequired)
     : base(g, terminateSymbol, suppressMessages, setupRequired)
 {
     this.onAccept = r;
 }
Esempio n. 25
0
 public LR1Parser(Cortex.Grammar.Grammar g, string terminateSymbol, SemanticRule r) : this(g, terminateSymbol, r, false)
 {
 }
Esempio n. 26
0
		public void AddSemanticRule (string addToRuleName, SemanticRule semanticRule)
		{
			AddSemanticRule (GetRule (addToRuleName), semanticRule);
		}
Esempio n. 27
0
 public LR1Parser(Cortex.Grammar.Grammar g, string terminateSymbol, LR1ParsingTable table, LR1GotoTable gotoTable, SemanticRule r)
     : base(g, terminateSymbol, r, true, false)
 {
     this.actionTable = table;
     this.gotoTable   = gotoTable;
     this.onAccept    = r;
     baseToken        = new Token <string>(TerminateSymbol, TerminateSymbol, TerminateSymbol.Length);
     stateStack       = new Stack <object>();
     initial          = new LookaheadRule(TerminateSymbol, TargetGrammar[0]);
 }
Esempio n. 28
0
 public void AddSemanticRule(string addToRuleName, SemanticRule semanticRule)
 {
     AddSemanticRule(GetRule(doc, addToRuleName), semanticRule);
 }
Esempio n. 29
0
 public void Identifier_Matches_Rule(string sample)
 {
     Assert.True(SemanticRule.MatchesRule(sample).HasPassed);
 }
Esempio n. 30
0
 public EnhancedLR1Parser(EnhancedGrammar g, string terminateSymbol, SemanticRule r, bool supressMessages)
     : base(g, terminateSymbol, r, supressMessages, true)
 {
 }
Esempio n. 31
0
 public void NullIdentifier_ThrowsException()
 {
     Assert.False(SemanticRule.MatchesRule(null).HasPassed);
 }
Esempio n. 32
0
 public EnhancedLR1Parser(EnhancedGrammar g, string terminateSymbol, SemanticRule r) : this(g, terminateSymbol, r, false)
 {
 }
Esempio n. 33
0
		public void AddSemanticRule (SemanticRule semanticRule)
		{
			AddSemanticRule (this, semanticRule);
		}
 protected AbstractMemoizedLR1Parser(AbstractGrammar <R, Encoding> g,
                                     string terminateSymbol, SemanticRule r,
                                     bool suppressMessages, bool setupRequired)
     : base(g, terminateSymbol, r, suppressMessages, setupRequired)
 {
 }
		public static void AddSemanticRule (string mime, string ruleName, SemanticRule rule)
		{
			semanticRules.Add (Tuple.Create (mime, ruleName, rule));
		}
Esempio n. 36
0
 public static void AddSemanticRule(string mime, string ruleName, SemanticRule rule)
 {
     semanticRules.Add(Tuple.Create(mime, ruleName, rule));
 }