Ejemplo n.º 1
0
 void AddSemanticRule(Rule rule, SemanticRule semanticRule)
 {
     if (rule != null)
     {
         rule.SemanticRules.Add(semanticRule);
     }
 }
Ejemplo n.º 2
0
        public Production(SemanticRule rule)
            : base()
        {
#if GATHERING_STATS
            InstanceCount++;
#endif
            this.rule = rule;
        }
Ejemplo n.º 3
0
 public Production(Production p)
     : this()
 {
     this.rule = p.rule;
     for (int i = 0; i < p.Count; i++)
     {
         Add(p[i]);
     }
 }
Ejemplo 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)
 {
 }
Ejemplo 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)
 {
 }
Ejemplo 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)
 {
 }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo n.º 9
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));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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)
 {
 }
Ejemplo 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)
 {
 }
Ejemplo n.º 17
0
 public void AddSemanticRule(SemanticRule semanticRule)
 {
     AddSemanticRule(this, semanticRule);
 }
Ejemplo n.º 18
0
 public EnhancedLR1Parser(EnhancedGrammar g, EnhancedParsingTable table, SemanticRule r) : this(g, DEFAULT_TERMINATE_SYMBOL, table, r)
 {
 }
Ejemplo 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]);
 }
Ejemplo n.º 20
0
 public LR1Parser(Cortex.Grammar.Grammar g, LR1ParsingTable table, LR1GotoTable gotoTable, SemanticRule r) : this(g, DEFAULT_TERMINATE_SYMBOL, table, gotoTable, r)
 {
 }
Ejemplo n.º 21
0
		void AddSemanticRule (Rule rule, SemanticRule semanticRule)
		{
			if (rule != null)
				rule.SemanticRules.Add (semanticRule);
		}
Ejemplo n.º 22
0
 public void Identifier_DoesntMatch_Rule(string sample)
 {
     Assert.False(SemanticRule.MatchesRule(sample).HasPassed);
 }
Ejemplo n.º 23
0
 public LR1Parser(Cortex.Grammar.Grammar g, string terminateSymbol, SemanticRule r, bool supressMessages)
     : base(g, terminateSymbol, r, supressMessages, true)
 {
 }
Ejemplo 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;
 }
Ejemplo n.º 25
0
 public LR1Parser(Cortex.Grammar.Grammar g, string terminateSymbol, SemanticRule r) : this(g, terminateSymbol, r, false)
 {
 }
Ejemplo n.º 26
0
		public void AddSemanticRule (string addToRuleName, SemanticRule semanticRule)
		{
			AddSemanticRule (GetRule (addToRuleName), semanticRule);
		}
Ejemplo 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]);
 }
Ejemplo n.º 28
0
 public void AddSemanticRule(string addToRuleName, SemanticRule semanticRule)
 {
     AddSemanticRule(GetRule(doc, addToRuleName), semanticRule);
 }
Ejemplo n.º 29
0
 public void Identifier_Matches_Rule(string sample)
 {
     Assert.True(SemanticRule.MatchesRule(sample).HasPassed);
 }
Ejemplo n.º 30
0
 public EnhancedLR1Parser(EnhancedGrammar g, string terminateSymbol, SemanticRule r, bool supressMessages)
     : base(g, terminateSymbol, r, supressMessages, true)
 {
 }
Ejemplo n.º 31
0
 public void NullIdentifier_ThrowsException()
 {
     Assert.False(SemanticRule.MatchesRule(null).HasPassed);
 }
Ejemplo n.º 32
0
 public EnhancedLR1Parser(EnhancedGrammar g, string terminateSymbol, SemanticRule r) : this(g, terminateSymbol, r, false)
 {
 }
Ejemplo n.º 33
0
		public void AddSemanticRule (SemanticRule semanticRule)
		{
			AddSemanticRule (this, semanticRule);
		}
Ejemplo n.º 34
0
 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));
		}
Ejemplo n.º 36
0
 public static void AddSemanticRule(string mime, string ruleName, SemanticRule rule)
 {
     semanticRules.Add(Tuple.Create(mime, ruleName, rule));
 }