Ejemplo n.º 1
0
 internal Group(CompiledGrammar owner, int index, string name, GroupAdvanceMode advanceMode, GroupEndingMode endingMode) : base(owner, index)
 {
     this.name        = name;
     this.advanceMode = advanceMode;
     this.endingMode  = endingMode;
     nesting          = new GrammarObjectSet <Group>();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of <c>Rule</c> class.
 /// </summary>
 /// <param name="index">Index of the rule in the grammar rule table.</param>
 internal Rule(CompiledGrammar owner, int index) : base(owner, index)
 {
     if (owner == null)
     {
         throw new ArgumentNullException("owner");
     }
 }
 public RuleDeclarationParser(CompiledGrammar grammar)
 {
     if (grammar == null) {
         throw new ArgumentNullException("grammar");
     }
     this.grammar = grammar;
 }
Ejemplo n.º 4
0
		public Rule Bind(CompiledGrammar grammar) {
			if (grammar == null) {
				throw new ArgumentNullException("grammar");
			}
			Rule rule;
			RuleDeclarationParser.TryBindGrammar(parsedRule, grammar, out rule);
			return rule;
		}
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a new instance of <c>Symbol</c> class.
 /// </summary>
 /// <param name="index">Symbol index in symbol table.</param>
 /// <param name="name">Name of the symbol.</param>
 /// <param name="kind">Type of the symbol.</param>
 internal Symbol(CompiledGrammar owner, int index, string name, SymbolKind kind) : base(owner, index)
 {
     if (owner == null)
     {
         throw new ArgumentNullException("owner");
     }
     this.name = string.IsInterned(name) ?? name;
     this.kind = kind;
 }
Ejemplo n.º 6
0
		protected GrammarXmlProcessor(CompiledGrammar grammar, XmlReader transform) {
			if (grammar == null) {
				throw new ArgumentNullException("grammar");
			}
			this.grammar = grammar;
			if (transform == null) {
				throw new ArgumentNullException("stylesheet");
			}
			this.transform = new XslCompiledTransform(false);
			this.transform.Load(transform, new XsltSettings(false, false), null);
			nametable = transform.NameTable;
		}
Ejemplo n.º 7
0
 public FormulaInterpreter(System.IO.BinaryReader reader)
 {
     grammar = CompiledGrammar.Load(reader);
     actions = new SemanticTypeActions<GCToken>(grammar);
     try
     {
         actions.Initialize(true);
     }
     catch (InvalidOperationException ex)
     {
         System.Diagnostics.Debug.Write(ex.Message);
     }
 }
Ejemplo n.º 8
0
 public FormulaInterpreter(System.IO.BinaryReader reader)
 {
     grammar = CompiledGrammar.Load(reader);
     actions = new SemanticTypeActions<GCToken>(grammar);
     try
     {
         actions.Initialize(true);
     }
     catch (System.Exception e)
     {
         Core.ApplicationData.Instance.Logger.AddLog(this, e);
     }
 }
Ejemplo n.º 9
0
        public void load() {
            log.Debug("Loading grammar...");
            grammar = CompiledGrammar.Load(typeof(MathToken), "math-grammar.cgt");
            log.Debug("Loading actions...");
            actions = new SemanticTypeActions<MathToken>(grammar);
            try {
                actions.Initialize(true);
            } catch (InvalidOperationException e) {
                log.Error("Error initializing actions", e);
                return;
            }

            log.Info("Plugin successfully loaded.");
        }
Ejemplo n.º 10
0
        internal DfaCharset(CompiledGrammar owner, int index, string charset) : base(owner, index)
        {
            if (string.IsNullOrEmpty(charset))
            {
                throw new ArgumentException("Empty charsets are not supported", "charset");
            }
            charsetIncludingSequence = charset.ToCharArray();
            Array.Sort(charsetIncludingSequence);
            char currentStartChar = charsetIncludingSequence[0];
            char currentChar      = currentStartChar;

            sequenceStart = currentStartChar;
            sequenceEnd   = currentStartChar;
            int sequenceLength = 1;
            int currentLength  = 1;

            for (int i = 1; i < charsetIncludingSequence.Length; i++)
            {
                currentChar++;
                if (charsetIncludingSequence[i] == currentChar)
                {
                    currentLength++;
                    if (currentLength > sequenceLength)
                    {
                        sequenceLength = currentLength;
                        sequenceStart  = currentStartChar;
                        sequenceEnd    = currentChar;
                    }
                }
                else
                {
                    currentLength    = 1;
                    currentStartChar = charsetIncludingSequence[i];
                    currentChar      = currentStartChar;
                }
            }
            charsetExcludingSequence = new char[charsetIncludingSequence.Length - sequenceLength];
            int charsetIndex = 0;

            foreach (char c in charsetIncludingSequence)
            {
                if ((c < sequenceStart) || (c > sequenceEnd))
                {
                    charsetExcludingSequence[charsetIndex++] = c;
                }
            }
            Debug.Assert(charsetIndex == charsetExcludingSequence.Length);
        }
		public RuleTrimAttributeTest() {
			grammar = EgtCompiledGrammarTest.LoadEgtTestGrammar();
		}
Ejemplo n.º 12
0
		public GrammarObjectSetTest() {
			grammar = EgtCompiledGrammarTest.LoadEgtTestGrammar();
		}
Ejemplo n.º 13
0
 public override void Warmup(XmlTestSuite suite)
 {
     grammar = CompiledGrammar.Load(new BinaryReader(GetType().Assembly.GetManifestResourceStream("Eto.Parse.TestSpeed.Tests.Xml.Gold.XML.egt")));
     Parse(suite);
 }
Ejemplo n.º 14
0
 internal static CompiledGrammar GetGrammar()
 {
     lock (sync) {
         if (compiledGrammar == null) {
             compiledGrammar = CompiledGrammar.Load(typeof(ScriptParser), "ModuleStoreSQL.egt");
         }
         return compiledGrammar;
     }
 }
Ejemplo n.º 15
0
		public LalrProcessorTest() {
			grammar = EgtCompiledGrammarTest.LoadEgtTestGrammar();
		}
		public TerminalAttributeTest() {
			grammar = EgtCompiledGrammarTest.LoadEgtTestGrammar();
		}
Ejemplo n.º 17
0
		public CgtTokenizerTest() {
			grammar = CgtCompiledGrammarTest.LoadCgtTestGrammar();
		}
		public SemanticTypeActionsTest() {
			grammar = EgtCompiledGrammarTest.LoadEgtTestGrammar();
		}
Ejemplo n.º 19
0
		public ParameterMatching() {
			grammar = EgtCompiledGrammarTest.LoadEgtTestGrammar();
		}
Ejemplo n.º 20
0
		public EgtTokenizerTest() {
			grammar = EgtCompiledGrammarTest.LoadEgtTestGrammar();
		}
Ejemplo n.º 21
0
		public Tests() {
			grammar = EgtCompiledGrammarTest.LoadEgtTestGrammar();
		}
Ejemplo n.º 22
0
 static GoldGrammarTable()
 {
     goldGrammarV1 = loadFromResource (v1Resource);
     goldGrammarV5 = loadFromResource (v5Resource);
 }
Ejemplo n.º 23
0
 public BsnGoldBenchmark()
 {
     grammar = CompiledGrammar.Load(new BinaryReader(GetType().Assembly.GetManifestResourceStream("Eto.Parse.TestSpeed.Tests.Json.Gold.JSON.egt")));
 }
Ejemplo n.º 24
0
 public void SetUp()
 {
     grammar = ScriptParser.GetGrammar();
 }
 public Symbol Bind(CompiledGrammar grammar)
 {
     if (grammar == null) {
         throw new ArgumentNullException("grammar");
     }
     Symbol result;
     grammar.TryGetSymbol(symbolName, out result);
     return result;
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GrammarObject&lt;TSelf&gt;"/> class.
 /// </summary>
 /// <param name="owner">The owner grammar.</param>
 /// <param name="index">The index.</param>
 protected GrammarObject(CompiledGrammar owner, int index)
 {
     this.owner = owner;
     this.index = index;
 }
Ejemplo n.º 27
0
		public TestEmpty(CompiledGrammar dummy) {
			if (dummy != null) {
				throw new InvalidOperationException("Expected a null dummy");
			}
		}
Ejemplo n.º 28
0
 public TestBsnGold()
 {
     grammar = CompiledGrammar.Load(new BinaryReader(GetType().Assembly.GetManifestResourceStream("Eto.Parse.TestSpeed.Tests.Xml.Gold.XML.egt")));
 }
Ejemplo n.º 29
0
		public SymbolTypeMapTest() {
			grammar = EgtCompiledGrammarTest.LoadEgtTestGrammar();
		}
 internal static bool TryBindGrammar(Reduction ruleDeclaration, CompiledGrammar grammar, out Rule rule)
 {
     Symbol ruleSymbol;
     if (grammar.TryGetSymbol(GetRuleSymbolName(ruleDeclaration), out ruleSymbol)) {
         ReadOnlyCollection<Rule> rules;
         if (grammar.TryGetRulesForSymbol(ruleSymbol, out rules)) {
             List<Symbol> symbols = new List<Symbol>();
             foreach (string handleName in GetRuleHandleNames(ruleDeclaration)) {
                 Symbol symbol;
                 if (!grammar.TryGetSymbol(handleName, out symbol)) {
                     symbols = null;
                     break;
                 }
                 symbols.Add(symbol);
             }
             if (symbols != null) {
                 foreach (Rule currentRule in rules) {
                     if (currentRule.Matches(symbols)) {
                         rule = currentRule;
                         return true;
                     }
                 }
             }
         }
     }
     rule = null;
     return false;
 }
Ejemplo n.º 31
0
 static GrammarParser()
 {
     goldGrammar = GoldGrammarTable.GetCompiledGrammar (CgtVersion.None);
 }
		public RuleDeclarationParserTest() {
			grammar = EgtCompiledGrammarTest.LoadEgtTestGrammar();
		}