Example #1
0
 /// <summary>
 /// Reads grammar header information.
 /// </summary>
 /// <param name="context"></param>
 private void ReadHeader(LoadContext context)
 {
     properties.Add(NameProperty, context.ReadStringEntry());
     properties.Add(VersionProperty, context.ReadStringEntry());
     properties.Add(AuthorProperty, context.ReadStringEntry());
     properties.Add(AboutProperty, context.ReadStringEntry());
     caseSensitive            = context.ReadBoolEntry();
     context.StartSymbolIndex = context.ReadIntegerEntry();
 }
Example #2
0
        private void ReadProperty(LoadContext context)
        {
            int    index = context.ReadIntegerEntry();
            string name  = context.ReadStringEntry();

            // override the name for the well-known constants, so that we have the right name for sure
            switch (index)
            {
            case 0:
                name = NameProperty;
                break;

            case 1:
                name = VersionProperty;
                break;

            case 2:
                name = AuthorProperty;
                break;

            case 3:
                name = AboutProperty;
                break;

            case 4:
                name = CharacterSetProperty;
                break;

            case 5:
                name = CharacterMappingProperty;
                break;

            case 6:
                name = GeneratedByProperty;
                break;

            case 7:
                name = GeneratedDateProperty;
                break;
            }
            properties.Add(name, context.ReadStringEntry());
        }
Example #3
0
        /// <summary>
        /// Read char set information.
        /// </summary>
        /// <param name="context"></param>
        private void ReadPackedCharset(LoadContext context)
        {
            int           index         = context.ReadIntegerEntry();
            char          sequenceStart = (char)context.ReadIntegerEntry();
            char          sequenceEnd   = (char)context.ReadIntegerEntry();
            StringBuilder result        = new StringBuilder(context.ReadStringEntry());

            result.Capacity = result.Length + (sequenceEnd - sequenceStart) + 1;
            for (char c = sequenceStart; c <= sequenceEnd; c++)
            {
                result.Append(c);
            }
            charSetTable[index] = new DfaCharset(this, index, result.ToString());
        }
Example #4
0
        /// <summary>
        /// Read symbol information.
        /// </summary>
        /// <param name="context"></param>
        private void ReadSymbol(LoadContext context)
        {
            int        index      = context.ReadIntegerEntry();
            string     name       = context.ReadStringEntry();
            SymbolKind symbolKind = (SymbolKind)context.ReadIntegerEntry();
            Symbol     symbol     = new Symbol(this, index, name, symbolKind);

            switch (symbolKind)
            {
            case SymbolKind.Error:
                errorSymbol = symbol;
                break;

            case SymbolKind.End:
                endSymbol = symbol;
                break;
            }
            symbolTable[index] = symbol;
        }
Example #5
0
        private void ReadGroup(LoadContext context)
        {
            int              index          = context.ReadIntegerEntry();
            string           name           = context.ReadStringEntry();
            int              containerIndex = context.ReadIntegerEntry();
            int              startIndex     = context.ReadIntegerEntry();
            int              endIndex       = context.ReadIntegerEntry();
            GroupAdvanceMode advanceMode    = (GroupAdvanceMode)context.ReadIntegerEntry();
            GroupEndingMode  endingMode     = (GroupEndingMode)context.ReadIntegerEntry();

            context.ReadEmptyEntry();
            int nestingCount = context.ReadIntegerEntry();

            Debug.Assert(nestingCount == context.EntryCount);
            int[] nesting = new int[nestingCount];
            for (int i = 0; i < nesting.Length; i++)
            {
                nesting[i] = context.ReadIntegerEntry();
            }
            groupTable[index] = new Group(this, index, name, advanceMode, endingMode);
            context.GroupInfos.Add(index, new GroupInfo(containerIndex, startIndex, endIndex, nesting));
        }
Example #6
0
		private void ReadProperty(LoadContext context) {
			int index = context.ReadIntegerEntry();
			string name = context.ReadStringEntry();
			// override the name for the well-known constants, so that we have the right name for sure
			switch (index) {
			case 0:
				name = NameProperty;
				break;
			case 1:
				name = VersionProperty;
				break;
			case 2:
				name = AuthorProperty;
				break;
			case 3:
				name = AboutProperty;
				break;
			case 4:
				name = CharacterSetProperty;
				break;
			case 5:
				name = CharacterMappingProperty;
				break;
			case 6:
				name = GeneratedByProperty;
				break;
			case 7:
				name = GeneratedDateProperty;
				break;
			}
			properties.Add(name, context.ReadStringEntry());
		}
Example #7
0
		/// <summary>
		/// Read char set information.
		/// </summary>
		/// <param name="context"></param>
		private void ReadPackedCharset(LoadContext context) {
			int index = context.ReadIntegerEntry();
			char sequenceStart = (char)context.ReadIntegerEntry();
			char sequenceEnd = (char)context.ReadIntegerEntry();
			StringBuilder result = new StringBuilder(context.ReadStringEntry());
			result.Capacity = result.Length+(sequenceEnd-sequenceStart)+1;
			for (char c = sequenceStart; c <= sequenceEnd; c++) {
				result.Append(c);
			}
			charSetTable[index] = new DfaCharset(this, index, result.ToString());
		}
Example #8
0
		/// <summary>
		/// Reads grammar header information.
		/// </summary>
		/// <param name="context"></param>
		private void ReadHeader(LoadContext context) {
			properties.Add(NameProperty, context.ReadStringEntry());
			properties.Add(VersionProperty, context.ReadStringEntry());
			properties.Add(AuthorProperty, context.ReadStringEntry());
			properties.Add(AboutProperty, context.ReadStringEntry());
			caseSensitive = context.ReadBoolEntry();
			context.StartSymbolIndex = context.ReadIntegerEntry();
		}
Example #9
0
		private void ReadGroup(LoadContext context) {
			int index = context.ReadIntegerEntry();
			string name = context.ReadStringEntry();
			int containerIndex = context.ReadIntegerEntry();
			int startIndex = context.ReadIntegerEntry();
			int endIndex = context.ReadIntegerEntry();
			GroupAdvanceMode advanceMode = (GroupAdvanceMode)context.ReadIntegerEntry();
			GroupEndingMode endingMode = (GroupEndingMode)context.ReadIntegerEntry();
			context.ReadEmptyEntry();
			int nestingCount = context.ReadIntegerEntry();
			Debug.Assert(nestingCount == context.EntryCount);
			int[] nesting = new int[nestingCount];
			for (int i = 0; i < nesting.Length; i++) {
				nesting[i] = context.ReadIntegerEntry();
			}
			groupTable[index] = new Group(this, index, name, advanceMode, endingMode);
			context.GroupInfos.Add(index, new GroupInfo(containerIndex, startIndex, endIndex, nesting));
		}
Example #10
0
		/// <summary>
		/// Read char set information.
		/// </summary>
		/// <param name="context"></param>
		private void ReadCharset(LoadContext context) {
			int index = context.ReadIntegerEntry();
			charSetTable[index] = new DfaCharset(this, index, context.ReadStringEntry());
		}
Example #11
0
		/// <summary>
		/// Read symbol information.
		/// </summary>
		/// <param name="context"></param>
		private void ReadSymbol(LoadContext context) {
			int index = context.ReadIntegerEntry();
			string name = context.ReadStringEntry();
			SymbolKind symbolKind = (SymbolKind)context.ReadIntegerEntry();
			Symbol symbol = new Symbol(this, index, name, symbolKind);
			switch (symbolKind) {
			case SymbolKind.Error:
				errorSymbol = symbol;
				break;
			case SymbolKind.End:
				endSymbol = symbol;
				break;
			}
			symbolTable[index] = symbol;
		}
Example #12
0
        /// <summary>
        /// Read char set information.
        /// </summary>
        /// <param name="context"></param>
        private void ReadCharset(LoadContext context)
        {
            int index = context.ReadIntegerEntry();

            charSetTable[index] = new DfaCharset(this, index, context.ReadStringEntry());
        }