예제 #1
0
 internal TerminalSymbol(UnifiedString identifier, Int32 Position, Int32 symbolNumber, Int64 enumValue)
     : base(identifier, Position, symbolNumber)
 {
     EnumValue = enumValue;
     _EmptyComputationResult = EmptyComputationResultEnum.NotEmpty; // Terminal symbols are never empty
     FlagName = MakeFlagIdentifier(EnumValue, identifier.ToString());
 }
예제 #2
0
 internal Symbol(UnifiedString identifier, Int32 position, Int32 symbolNumber)
 {
     this.Identifier           = identifier;
     this.FirstPosition        = position;
     this.SymbolNumber         = symbolNumber;
     this.AttributetypeStrings = Array.Empty <UnifiedString>();
     this.AttributenameStrings = Array.Empty <UnifiedString>();
 }
예제 #3
0
 /// <summary>
 /// returns an attribute struct with <see cref="LeftSide"/> == false,
 ///  <see cref="OverlayType"/> == inAttribute (to be updated later)
 ///  and <see cref="Implementation"/> == <see cref="ParameterImplementation.NotAssigned"/>
 /// </summary>
 /// <param name="type">The type of the attribute (e.g. Int32)</param>
 /// <param name="name">The name / identifier  of the attribute</param>
 /// <param name="level">the level of parenthesis (lowest level is level 0)</param>
 /// <param name="positionInProduction">first attribute of left side has position 1, 1st attribute of right side equally has position 1</param>
 internal AttributeStruct(UnifiedString typeString, UnifiedString nameString, Int32 level, Int32 positionInProduction)
 {
     TypeString           = typeString;
     NameString           = nameString;
     PositionInProduction = positionInProduction;
     LeftSide             = false; // has to be added later (as soon as the left side is recognized)
     Level          = level;       // may be changed if in left side within parentheses
     OverlayType    = OverlayEnum.inAttribute;
     Implementation = ParameterImplementation.NotAssigned;
 }
예제 #4
0
        public static void ResetGlobalVariables(
            Action <MessageTypeOrDestinationEnum, String> outputMessage,
            Action <MessageTypeOrDestinationEnum, String, Int32> outputMessageAndPosition)
        {
            // Reset all settings
            GlobalSettings.Reset();

            UnifiedString.Reset();

            // Reset all static variables
            NumberOfActions            = 0;
            OutputMessage              = outputMessage;
            OutputMessageAndPosition   = outputMessageAndPosition;
            NumberOfTerminalSymbols    = 0;
            NumberOfNonterminalSymbols = 0;
            Startsymbol = new NonterminalSymbol(new UnifiedString("*Startsymbol"),
                                                position: 0,
                                                symbolNumber: 0,
                                                attributetypeStringList: Array.Empty <UnifiedString>(),
                                                attributenameStringList: Array.Empty <UnifiedString>()
                                                // trivalDefinitionsArray: Array.Empty<Symbol>(), // the startsymbol will not have any trival definitions: default
                                                // nontrivalDefinitionsList: ... // will be set after the startsymbol: default (empty list)
                                                );


            ListOfAllHaltActions.Clear();
            ListOfAllHaltActions.Capacity = InitialCapacityOfListOfAllHaltActions;
            ListOfAllHaltActions.Add(new HaltAction(IdNumber: 0, AttributestackAdjustement: 0));

            TerminalSymbols    = Array.Empty <TerminalSymbol>();
            AllTerminalSymbols = EmptyBitarray;

            ListOfAllStates.Clear();
            ListOfAllStates.Capacity = InitialCapacityOfListOfAllStates;

            ListOfAllErrorhandlingActions.Clear();
            ListOfAllErrorhandlingActions.Capacity = InitialCapacityOfListOfAllStates;

            ListOfAllReductions.Clear();
            ListOfAllReductions.Capacity = InitialCapacityOfListOfAllReductions;

            ListOfAllBranchActions.Clear();
            ListOfAllBranchActions.Capacity = InitialCapacityOfListOfAllBranchActions;

            ListOfAllPushStateActions.Clear();
            ListOfAllPushStateActions.Capacity = InitialCapacityOfListOfAllPushStateActions;

            ListOfAllPrioritySelectActions.Clear();
            ListOfAllPrioritySelectActions.Capacity = InitialCapacityOfListOfAllPrioritySelectActions;

            ListOfAllPriorityBranchActions.Clear();
            ListOfAllPriorityBranchActions.Capacity = InitialCapacityOfListOfAllPriorityBranchActions;
        }
예제 #5
0
 internal NonterminalSymbol(
     UnifiedString identifier,
     Int32 position,
     Int32 symbolNumber,
     UnifiedString[] attributetypeStringList,
     UnifiedString[] attributenameStringList
     )
     : base(identifier, position, symbolNumber, attributetypeStringList, attributenameStringList)
 {
     NontrivialDefinitionsList = EmptyDefinitionsList;
     TrivalDefinitionsArray    = Array.Empty <Symbol>();
 }
예제 #6
0
 internal NonterminalSymbol(
     UnifiedString identifier,
     Int32 position,
     Int32 symbolNumber,
     UnifiedString[] attributetypeStringList,
     UnifiedString[] attributenameStringList,
     ListOfDefinitions nontrivalDefinitionsList,
     Symbol[] trivalDefinitionsArray
     )
     : base(identifier, position, symbolNumber, attributetypeStringList, attributenameStringList)
 {
     NontrivialDefinitionsList = nontrivalDefinitionsList;
     TrivalDefinitionsArray    = trivalDefinitionsArray;
 }
예제 #7
0
 internal Symbol(
     UnifiedString identifier,
     Int32 position,
     Int32 symbolNumber,
     UnifiedString[] attributetypeStringIndexList,
     UnifiedString[] attributenameStringIndexList
     )
 {
     this.Identifier           = identifier;
     this.FirstPosition        = position;
     this.SymbolNumber         = symbolNumber;
     this.AttributetypeStrings = attributetypeStringIndexList;
     this.AttributenameStrings = attributenameStringIndexList;
 }
 //|
 //| *= QuotationMark, Space*,
 //|    TerminalIdentifier, Space*,
 //|    OpenParenthesis, Space*,
 //|    Attributes?,
 //|    CloseParenthesis, Space*
 //|    OptionalWeight
 void AssignAttributes()
 {
     if (!TerminalHasBeenDefined)
     {
         var TypeStrings = new UnifiedString[AttributeTypes.Count];
         var NameStrings = new UnifiedString[AttributeIdentifiers.Count];
         for (int i = 0; i < AttributeTypes.Count; i++)
         {
             TypeStrings[i] = new UnifiedString(AttributeTypes[i]);
             NameStrings[i] = new UnifiedString(AttributeIdentifiers[i]);
         }
         Terminal !.AttributetypeStrings = TypeStrings;
         Terminal !.AttributenameStrings = NameStrings;
     }
 }
예제 #9
0
        /// <summary>
        /// Returns an array of the type identifiers of the last count attributes.  The array may be empty.
        /// </summary>
        /// <param name="count">The number of attributes to copy from the end of the ListOfAttributes, may be 0</param>
        /// <returns>array of the type identifiers</returns>
        internal UnifiedString[] GetAttributeTypeStringIndexes(Int32 count)
        {
            if (count == 0)
            {
                return(Array.Empty <UnifiedString>());
            }

            var AttributeTypesString = new UnifiedString[count];

            for (Int32 i = 0; i < count; i++)
            {
                AttributeTypesString[i] = this[Count - count + i].TypeString;
            }

            return(AttributeTypesString);
        }